diff options
author | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-05-10 20:44:51 +0200 |
---|---|---|
committer | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-05-14 23:40:30 +0200 |
commit | 49ae9b3748a2e2dc1d84a8078a0e3d4e6c7ffbdc (patch) | |
tree | c308287024e90c517453fe06e62e8a6a15d26cfe | |
parent | 62e610c0003aec66431f1166d4cc6081c19517a8 (diff) |
ac/radeonsi: move some aspects of sanity checking to ac_surface
-rw-r--r-- | src/amd/common/ac_surface.c | 33 | ||||
-rw-r--r-- | src/gallium/winsys/amdgpu/drm/amdgpu_surface.c | 16 |
2 files changed, 33 insertions, 16 deletions
diff --git a/src/amd/common/ac_surface.c b/src/amd/common/ac_surface.c index f0138b5f8b..3d04200cc1 100644 --- a/src/amd/common/ac_surface.c +++ b/src/amd/common/ac_surface.c @@ -30,6 +30,7 @@ #include "util/macros.h" #include "util/u_math.h" +#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <amdgpu.h> @@ -198,6 +199,32 @@ ADDR_HANDLE amdgpu_addr_create(enum radeon_family family, return addrCreateOutput.hLib; } +static int surf_config_sanity(const struct ac_surf_config *config) +{ + /* all dimension must be at least 1 ! */ + if (!config->info.width || !config->info.height || !config->info.depth || + !config->info.array_size || !config->info.levels) + return -EINVAL; + + switch (config->info.samples) { + case 0: + case 1: + case 2: + case 4: + case 8: + break; + default: + return -EINVAL; + } + + if (config->is_3d && config->info.array_size > 1) + return -EINVAL; + if (config->is_cube && config->info.depth > 1) + return -EINVAL; + + return 0; +} + static int gfx6_compute_level(ADDR_HANDLE addrlib, const struct ac_surf_config *config, struct radeon_surf *surf, bool is_stencil, @@ -1012,6 +1039,12 @@ int ac_compute_surface(ADDR_HANDLE addrlib, enum radeon_surf_mode mode, struct radeon_surf *surf) { + int r; + + r = surf_config_sanity(config); + if (r) + return r; + if (config->chip_class >= GFX9) return gfx9_compute_surface(addrlib, config, mode, surf); else diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_surface.c b/src/gallium/winsys/amdgpu/drm/amdgpu_surface.c index ca391e0c4e..cd403f5bfb 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_surface.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_surface.c @@ -34,22 +34,6 @@ static int amdgpu_surface_sanity(const struct pipe_resource *tex) { - /* all dimension must be at least 1 ! */ - if (!tex->width0 || !tex->height0 || !tex->depth0 || - !tex->array_size) - return -EINVAL; - - switch (tex->nr_samples) { - case 0: - case 1: - case 2: - case 4: - case 8: - break; - default: - return -EINVAL; - } - switch (tex->target) { case PIPE_TEXTURE_1D: if (tex->height0 > 1) |