Currently bound sampler view resources are relevant only if the
currently bound shaders also access them. So when checking for shader
resource collision, we only need to check those shader resources that
are actively used by the shaders.
This fixes a regression with manhattan on SVGA device when only the
active state changes are sent to the driver and a no longer relevant
shader resource is included in the shader resource collision check.
This causes a backing resource to be unnecessarily created and the content
never propagated to the original resource.
Fixes:
aaa4b0e6186 ("st/mesa: move check_program_state code into _mesa_update_state")
Reviewed-by: Neha Bhenden <bhenden@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25801>
struct pipe_clip_state clip;
struct pipe_viewport_state viewport[SVGA3D_DX_MAX_VIEWPORTS];
+ bool use_samplers[PIPE_SHADER_TYPES];
unsigned num_samplers[PIPE_SHADER_TYPES];
unsigned num_sampler_views[PIPE_SHADER_TYPES];
unsigned num_vertex_buffers;
num_sampler_states > SVGA3D_DX_MAX_SAMPLERS);
}
+
+static inline void
+svga_set_curr_shader_use_samplers_flag(struct svga_context *svga,
+ enum pipe_shader_type shader_type,
+ bool use_samplers)
+{
+ svga->curr.use_samplers[shader_type] = use_samplers;
+}
+
+
+static inline bool
+svga_curr_shader_use_samplers(const struct svga_context *svga,
+ enum pipe_shader_type shader_type)
+{
+ return svga->curr.use_samplers[shader_type];
+}
+
+
/**
* If the Gallium HUD is enabled, this will return the current time.
* Otherwise, just return zero.
svga->curr.cs = cs;
svga->dirty |= SVGA_NEW_CS;
+
+ /* Check if the shader uses samplers */
+ svga_set_curr_shader_use_samplers_flag(svga, PIPE_SHADER_COMPUTE,
+ svga_shader_use_samplers(&cs->base));
}
svga->curr.fs = fs;
svga->dirty |= SVGA_NEW_FS;
+
+ /* Check if shader uses samplers */
+ svga_set_curr_shader_use_samplers_flag(svga, PIPE_SHADER_FRAGMENT,
+ svga_shader_use_samplers(&fs->base));
}
svga->curr.user_gs = gs;
svga->dirty |= SVGA_NEW_GS;
+
+ /* Check if the shader uses samplers */
+ svga_set_curr_shader_use_samplers_flag(svga, PIPE_SHADER_GEOMETRY,
+ svga_shader_use_samplers(&gs->base));
}
svga->curr.tcs = tcs;
svga->dirty |= SVGA_NEW_TCS;
+
+ /* Check if the shader uses samplers */
+ svga_set_curr_shader_use_samplers_flag(svga, PIPE_SHADER_TESS_CTRL,
+ svga_shader_use_samplers(&tcs->base));
}
svga->curr.tes = tes;
svga->dirty |= SVGA_NEW_TES;
+
+ /* Check if the shader uses samplers */
+ svga_set_curr_shader_use_samplers_flag(svga, PIPE_SHADER_TESS_EVAL,
+ svga_shader_use_samplers(&tes->base));
}
svga->curr.vs = vs;
svga->dirty |= SVGA_NEW_VS;
+
+ /* Check if the shader uses samplers */
+ svga_set_curr_shader_use_samplers_flag(svga, PIPE_SHADER_VERTEX,
+ svga_shader_use_samplers(&vs->base));
}
key->num_textures = MAX2(svga->curr.num_sampler_views[shader_type],
svga->curr.num_samplers[shader_type]);
+ if (!shader->info.uses_samplers)
+ key->num_textures = 0;
+
key->num_samplers = 0;
/* Set sampler_state_mapping only if GL43 is supported and
bool uses_images;
bool uses_image_size;
bool uses_shader_buffers;
+ bool uses_samplers;
unsigned const_buffers_declared; /* bitmask of declared const buffers */
unsigned constbuf0_num_uniforms; /* number of uniforms in constbuf0 */
struct svga_shader *shader,
const struct svga_compile_key *key);
+static inline bool
+svga_shader_use_samplers(struct svga_shader *shader)
+{
+ return shader ? (shader->info.uses_samplers != 0) : false;
+}
+
#endif /* SVGA_SHADER_H */
return false;
}
+ if (!svga_curr_shader_use_samplers(svga, shader))
+ return false;
+
for (i = 0; i < svga->curr.num_sampler_views[shader]; i++) {
struct svga_pipe_sampler_view *sv =
svga_pipe_sampler_view(svga->curr.sampler_views[shader][i]);
unsigned count;
unsigned nviews;
unsigned i;
+ struct svga_compute_shader *cs = svga->curr.cs;
count = svga->curr.num_sampler_views[shader];
+ if (!cs || !cs->base.info.uses_samplers)
+ count = 0;
+
for (i = 0; i < count; i++) {
struct svga_pipe_sampler_view *sv =
svga_pipe_sampler_view(svga->curr.sampler_views[shader][i]);
info->uses_images = tgsi_info->images_declared != 0;
info->uses_image_size = tgsi_info->opcode_count[TGSI_OPCODE_RESQ] ? 1 : 0;
info->uses_shader_buffers = tgsi_info->shader_buffers_declared != 0;
+ info->uses_samplers = tgsi_info->samplers_declared != 0;
info->const_buffers_declared = tgsi_info->const_buffers_declared;
info->shader_buffers_declared = tgsi_info->shader_buffers_declared;