From fda533a4c0ebaf4f9e32bd911b0a5122b8b91aaa Mon Sep 17 00:00:00 2001 From: Neha Bhende Date: Tue, 25 May 2021 10:47:27 -0700 Subject: [PATCH] svga: Add target and sampler_return_type info into shader key Fixes: 584b1070372a0e ("st/mesa: Drop the TGSI paths for drawpixels and use nir-to-tgsi") Reviewed-by: Charmaine Lee Part-of: (cherry picked from commit 4b958ac7200d200d46d4b33c03182d8bab641eef) --- .pick_status.json | 2 +- src/gallium/drivers/svga/svga_shader.c | 25 +++++++++++++++++++++++++ src/gallium/drivers/svga/svga_shader.h | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 5b2fe9417e6..01a8b516f12 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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" }, diff --git a/src/gallium/drivers/svga/svga_shader.c b/src/gallium/drivers/svga/svga_shader.c index 52f1153fd61..1be8cf5dd8d 100644 --- a/src/gallium/drivers/svga/svga_shader.c +++ b/src/gallium/drivers/svga/svga_shader.c @@ -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 diff --git a/src/gallium/drivers/svga/svga_shader.h b/src/gallium/drivers/svga/svga_shader.h index 4fccde40535..f252c6cfa27 100644 --- a/src/gallium/drivers/svga/svga_shader.h +++ b/src/gallium/drivers/svga/svga_shader.h @@ -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.