svga: Add target and sampler_return_type info into shader key

Fixes: 584b107037 ("st/mesa: Drop the TGSI paths for drawpixels and use nir-to-tgsi")

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11011>
(cherry picked from commit 4b958ac720)
This commit is contained in:
Neha Bhende 2021-05-25 10:47:27 -07:00 committed by Eric Engestrom
parent de318a580f
commit fda533a4c0
3 changed files with 28 additions and 1 deletions

View file

@ -787,7 +787,7 @@
"description": "svga: Add target and sampler_return_type info into shader key",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "584b1070372a0e010a0e9a221493e5042575abb1"
},

View file

@ -31,6 +31,7 @@
#include "svga_format.h"
#include "svga_shader.h"
#include "svga_resource_texture.h"
#include "VGPU10ShaderTokens.h"
/**
@ -223,6 +224,24 @@ static const enum pipe_swizzle set_XXXY[PIPE_SWIZZLE_MAX] = {
};
static VGPU10_RESOURCE_RETURN_TYPE
vgpu10_return_type(enum pipe_format format)
{
if (util_format_is_unorm(format))
return VGPU10_RETURN_TYPE_UNORM;
else if (util_format_is_snorm(format))
return VGPU10_RETURN_TYPE_SNORM;
else if (util_format_is_pure_uint(format))
return VGPU10_RETURN_TYPE_UINT;
else if (util_format_is_pure_sint(format))
return VGPU10_RETURN_TYPE_SINT;
else if (util_format_is_float(format))
return VGPU10_RETURN_TYPE_FLOAT;
else
return VGPU10_RETURN_TYPE_MAX;
}
/**
* Initialize the shader-neutral fields of svga_compile_key from context
* state. This is basically the texture-related state.
@ -252,6 +271,12 @@ svga_init_shader_key_common(const struct svga_context *svga,
assert(view->texture);
assert(view->texture->target < (1 << 4)); /* texture_target:4 */
enum pipe_texture_target target = view->target;
key->tex[i].target = target;
key->tex[i].sampler_return_type = vgpu10_return_type(view->format);
/* 1D/2D array textures with one slice and cube map array textures
* with one cube are treated as non-arrays by the SVGA3D device.
* Set the is_array flag only if we know that we have more than 1

View file

@ -138,6 +138,8 @@ struct svga_compile_key
unsigned swizzle_b:3;
unsigned swizzle_a:3;
unsigned num_samples:5; /**< Up to 16 samples */
unsigned target:4;
unsigned sampler_return_type:4;
} tex[PIPE_MAX_SAMPLERS];
/* Note: svga_compile_keys_equal() depends on the variable-size
* tex[] array being at the end of this structure.