radeonsi: "get_blitter_vs" shader in nir
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25782>
This commit is contained in:
committed by
Marge Bot
parent
4a3cebaffc
commit
4dd287308f
@@ -1647,7 +1647,7 @@ union si_compute_blit_shader_key {
|
||||
|
||||
void *si_create_blit_cs(struct si_context *sctx, const union si_compute_blit_shader_key *options);
|
||||
|
||||
/* si_shaderlib_tgsi.c */
|
||||
/* si_shaderlib_nir.c */
|
||||
void *si_get_blitter_vs(struct si_context *sctx, enum blitter_attrib_type type,
|
||||
unsigned num_layers);
|
||||
void *si_create_dma_compute_shader(struct si_context *sctx, unsigned num_dwords_per_thread,
|
||||
@@ -1656,6 +1656,8 @@ void *si_create_clear_buffer_rmw_cs(struct si_context *sctx);
|
||||
void *si_clear_render_target_shader(struct si_context *sctx, enum pipe_texture_target type);
|
||||
void *si_clear_12bytes_buffer_shader(struct si_context *sctx);
|
||||
void *si_create_fmask_expand_cs(struct si_context *sctx, unsigned num_samples, bool is_array);
|
||||
|
||||
/* si_shaderlib_tgsi.c */
|
||||
void *si_create_query_result_cs(struct si_context *sctx);
|
||||
void *gfx11_create_sh_query_result_cs(struct si_context *sctx);
|
||||
|
||||
|
||||
@@ -788,3 +788,77 @@ void *si_create_fmask_expand_cs(struct si_context *sctx, unsigned num_samples, b
|
||||
|
||||
return create_shader_state(sctx, b.shader);
|
||||
}
|
||||
|
||||
/* This is just a pass-through shader with 1-3 MOV instructions. */
|
||||
void *si_get_blitter_vs(struct si_context *sctx, enum blitter_attrib_type type, unsigned num_layers)
|
||||
{
|
||||
unsigned vs_blit_property;
|
||||
void **vs;
|
||||
|
||||
switch (type) {
|
||||
case UTIL_BLITTER_ATTRIB_NONE:
|
||||
vs = num_layers > 1 ? &sctx->vs_blit_pos_layered : &sctx->vs_blit_pos;
|
||||
vs_blit_property = SI_VS_BLIT_SGPRS_POS;
|
||||
break;
|
||||
case UTIL_BLITTER_ATTRIB_COLOR:
|
||||
vs = num_layers > 1 ? &sctx->vs_blit_color_layered : &sctx->vs_blit_color;
|
||||
vs_blit_property = SI_VS_BLIT_SGPRS_POS_COLOR;
|
||||
break;
|
||||
case UTIL_BLITTER_ATTRIB_TEXCOORD_XY:
|
||||
case UTIL_BLITTER_ATTRIB_TEXCOORD_XYZW:
|
||||
assert(num_layers == 1);
|
||||
vs = &sctx->vs_blit_texcoord;
|
||||
vs_blit_property = SI_VS_BLIT_SGPRS_POS_TEXCOORD;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (*vs)
|
||||
return *vs;
|
||||
|
||||
/* Add 1 for the attribute ring address. */
|
||||
if (sctx->gfx_level >= GFX11 && type != UTIL_BLITTER_ATTRIB_NONE)
|
||||
vs_blit_property++;
|
||||
|
||||
const nir_shader_compiler_options *options =
|
||||
sctx->b.screen->get_compiler_options(sctx->b.screen, PIPE_SHADER_IR_NIR, PIPE_SHADER_VERTEX);
|
||||
|
||||
nir_builder b =
|
||||
nir_builder_init_simple_shader(MESA_SHADER_VERTEX, options, "get_blitter_vs");
|
||||
|
||||
/* Tell the shader to load VS inputs from SGPRs: */
|
||||
b.shader->info.vs.blit_sgprs_amd = vs_blit_property;
|
||||
b.shader->info.vs.window_space_position = true;
|
||||
|
||||
const struct glsl_type *vec4 = glsl_vec4_type();
|
||||
|
||||
nir_copy_var(&b,
|
||||
nir_create_variable_with_location(b.shader, nir_var_shader_out,
|
||||
VARYING_SLOT_POS, vec4),
|
||||
nir_create_variable_with_location(b.shader, nir_var_shader_in,
|
||||
VERT_ATTRIB_GENERIC0, vec4));
|
||||
|
||||
if (type != UTIL_BLITTER_ATTRIB_NONE) {
|
||||
nir_copy_var(&b,
|
||||
nir_create_variable_with_location(b.shader, nir_var_shader_out,
|
||||
VARYING_SLOT_VAR0, vec4),
|
||||
nir_create_variable_with_location(b.shader, nir_var_shader_in,
|
||||
VERT_ATTRIB_GENERIC1, vec4));
|
||||
}
|
||||
|
||||
if (num_layers > 1) {
|
||||
nir_variable *out_layer =
|
||||
nir_create_variable_with_location(b.shader, nir_var_shader_out,
|
||||
VARYING_SLOT_LAYER, glsl_int_type());
|
||||
out_layer->data.interpolation = INTERP_MODE_NONE;
|
||||
|
||||
nir_copy_var(&b, out_layer,
|
||||
nir_create_variable_with_location(b.shader, nir_var_system_value,
|
||||
SYSTEM_VALUE_INSTANCE_ID, glsl_int_type()));
|
||||
}
|
||||
|
||||
*vs = create_shader_state(sctx, b.shader);
|
||||
return *vs;
|
||||
}
|
||||
|
||||
@@ -8,65 +8,6 @@
|
||||
#include "tgsi/tgsi_text.h"
|
||||
#include "tgsi/tgsi_ureg.h"
|
||||
|
||||
void *si_get_blitter_vs(struct si_context *sctx, enum blitter_attrib_type type, unsigned num_layers)
|
||||
{
|
||||
unsigned vs_blit_property;
|
||||
void **vs;
|
||||
|
||||
switch (type) {
|
||||
case UTIL_BLITTER_ATTRIB_NONE:
|
||||
vs = num_layers > 1 ? &sctx->vs_blit_pos_layered : &sctx->vs_blit_pos;
|
||||
vs_blit_property = SI_VS_BLIT_SGPRS_POS;
|
||||
break;
|
||||
case UTIL_BLITTER_ATTRIB_COLOR:
|
||||
vs = num_layers > 1 ? &sctx->vs_blit_color_layered : &sctx->vs_blit_color;
|
||||
vs_blit_property = SI_VS_BLIT_SGPRS_POS_COLOR;
|
||||
break;
|
||||
case UTIL_BLITTER_ATTRIB_TEXCOORD_XY:
|
||||
case UTIL_BLITTER_ATTRIB_TEXCOORD_XYZW:
|
||||
assert(num_layers == 1);
|
||||
vs = &sctx->vs_blit_texcoord;
|
||||
vs_blit_property = SI_VS_BLIT_SGPRS_POS_TEXCOORD;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
if (*vs)
|
||||
return *vs;
|
||||
|
||||
struct ureg_program *ureg = ureg_create(PIPE_SHADER_VERTEX);
|
||||
if (!ureg)
|
||||
return NULL;
|
||||
|
||||
/* Add 1 for the attribute ring address. */
|
||||
if (sctx->gfx_level >= GFX11 && type != UTIL_BLITTER_ATTRIB_NONE)
|
||||
vs_blit_property++;
|
||||
|
||||
/* Tell the shader to load VS inputs from SGPRs: */
|
||||
ureg_property(ureg, TGSI_PROPERTY_VS_BLIT_SGPRS_AMD, vs_blit_property);
|
||||
ureg_property(ureg, TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION, true);
|
||||
|
||||
/* This is just a pass-through shader with 1-3 MOV instructions. */
|
||||
ureg_MOV(ureg, ureg_DECL_output(ureg, TGSI_SEMANTIC_POSITION, 0), ureg_DECL_vs_input(ureg, 0));
|
||||
|
||||
if (type != UTIL_BLITTER_ATTRIB_NONE) {
|
||||
ureg_MOV(ureg, ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 0), ureg_DECL_vs_input(ureg, 1));
|
||||
}
|
||||
|
||||
if (num_layers > 1) {
|
||||
struct ureg_src instance_id = ureg_DECL_system_value(ureg, TGSI_SEMANTIC_INSTANCEID, 0);
|
||||
struct ureg_dst layer = ureg_DECL_output(ureg, TGSI_SEMANTIC_LAYER, 0);
|
||||
|
||||
ureg_MOV(ureg, ureg_writemask(layer, TGSI_WRITEMASK_X),
|
||||
ureg_scalar(instance_id, TGSI_SWIZZLE_X));
|
||||
}
|
||||
ureg_END(ureg);
|
||||
|
||||
*vs = ureg_create_shader_and_destroy(ureg, &sctx->b);
|
||||
return *vs;
|
||||
}
|
||||
|
||||
/* Create the compute shader that is used to collect the results.
|
||||
*
|
||||
* One compute grid with a single thread is launched for every query result
|
||||
|
||||
Reference in New Issue
Block a user