svga: create svga_shader_info

This patch adds a new structure svga_shader_info which includes
shader info that is accessed outside of the shader translation
code. That's why it cannot be TGSI specific as we will later also
support NIR. This shader info structure, however, is derived
from the TGSI shader info or the NIR shader info.

Reviewed-by: Neha Bhende <bhenden@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16501>
This commit is contained in:
Charmaine Lee
2022-05-12 21:00:23 -07:00
committed by Marge Bot
parent ed77ac1eef
commit c291e685bc
20 changed files with 375 additions and 126 deletions
+2 -2
View File
@@ -36,7 +36,7 @@
#include "svga_shader.h"
#include "svga_streamout.h"
#include "svga_resource_buffer.h"
#include "svga_tgsi.h"
/**
* Create the compute program.
@@ -63,7 +63,7 @@ svga_create_compute_state(struct pipe_context *pipe,
}
/* Collect shader basic info */
tgsi_scan_shader(cs->base.tokens, &cs->base.info);
svga_tgsi_scan_shader(&cs->base);
cs->base.id = svga->debug.shader_id++;
+4 -2
View File
@@ -61,8 +61,10 @@ svga_create_fs_state(struct pipe_context *pipe,
tmp.type = PIPE_SHADER_IR_TGSI;
tmp.tokens = fs->base.tokens;
fs->generic_inputs = svga_get_generic_inputs_mask(&fs->base.info);
svga_remap_generics(fs->generic_inputs, fs->generic_remap_table);
fs->generic_inputs = svga_get_generic_inputs_mask(&fs->base.tgsi_info);
svga_remap_generics(fs->base.info.generic_inputs_mask,
fs->generic_remap_table);
fs->draw_shader = draw_create_fragment_shader(svga->swtnl.draw, &tmp);
-2
View File
@@ -63,8 +63,6 @@ svga_create_gs_state(struct pipe_context *pipe,
gs->draw_shader = draw_create_geometry_shader(svga->swtnl.draw, &tmp);
gs->generic_outputs = svga_get_generic_outputs_mask(&gs->base.info);
done:
SVGA_STATS_TIME_POP(svga_sws(svga));
return gs;
@@ -187,7 +187,7 @@ svga_create_stream_output(struct svga_context *svga,
unsigned reg_idx = info->output[i].register_index;
unsigned buf_idx = info->output[i].output_buffer;
const enum tgsi_semantic sem_name =
shader->info.output_semantic_name[reg_idx];
shader->tgsi_info.output_semantic_name[reg_idx];
assert(buf_idx <= PIPE_MAX_SO_BUFFERS);
@@ -238,7 +238,7 @@ svga_create_stream_output(struct svga_context *svga,
* Check if streaming out POSITION. If so, replace the
* register index with the index for NON_ADJUSTED POSITION.
*/
decls[numDecls].registerIndex = shader->info.num_outputs;
decls[numDecls].registerIndex = shader->tgsi_info.num_outputs;
/* Save this output index, so we can tell later if this stream output
* includes an output of a vertex position
@@ -253,8 +253,8 @@ svga_create_stream_output(struct svga_context *svga,
* clip planes.
*/
decls[numDecls].registerIndex =
shader->info.num_outputs + 1 +
shader->info.output_semantic_index[reg_idx];
shader->tgsi_info.num_outputs + 1 +
shader->tgsi_info.output_semantic_index[reg_idx];
}
else {
decls[numDecls].registerIndex = reg_idx;
-4
View File
@@ -71,8 +71,6 @@ svga_create_tcs_state(struct pipe_context *pipe,
if (!tcs)
goto done;
tcs->generic_outputs = svga_get_generic_outputs_mask(&tcs->base.info);
done:
SVGA_STATS_TIME_POP(svga_sws(svga));
return tcs;
@@ -150,8 +148,6 @@ svga_create_tes_state(struct pipe_context *pipe,
if (!tes)
goto done;
tes->generic_inputs = svga_get_generic_inputs_mask(&tes->base.info);
done:
SVGA_STATS_TIME_POP(svga_sws(svga));
return tes;
-2
View File
@@ -55,8 +55,6 @@ svga_create_vs_state(struct pipe_context *pipe,
if (!vs)
goto done;
vs->generic_outputs = svga_get_generic_outputs_mask(&vs->base.info);
{
/* Need to do construct a new template in case we substituted a
* debug shader.
+7 -4
View File
@@ -30,6 +30,7 @@
#include "svga_cmd.h"
#include "svga_format.h"
#include "svga_shader.h"
#include "svga_tgsi.h"
#include "svga_resource_texture.h"
#include "VGPU10ShaderTokens.h"
#include "tgsi/tgsi_parse.h"
@@ -468,8 +469,8 @@ svga_init_shader_key_common(const struct svga_context *svga,
}
if (svga_have_gl43(svga)) {
if (shader->info.images_declared || shader->info.hw_atomic_declared ||
shader->info.shader_buffers_declared) {
if (shader->info.uses_images || shader->info.uses_hw_atomic ||
shader->info.uses_shader_buffers) {
/* Save the uavSpliceIndex which is the index used for the first uav
* in the draw pipeline. For compute, uavSpliceIndex is always 0.
@@ -537,6 +538,8 @@ svga_init_shader_key_common(const struct svga_context *svga,
else
key->atomic_buf_uav_index[i] = SVGA3D_INVALID_ID;
}
key->image_size_used = shader->info.uses_image_size;
}
/* Save info about which constant buffers are to be viewed
@@ -928,8 +931,8 @@ svga_create_shader(struct pipe_context *pipe,
shader->tokens = pipe_shader_state_to_tgsi_tokens(pipe->screen, templ);
if (shader->type == PIPE_SHADER_IR_TGSI) {
/* Collect basic info that we'll need later */
tgsi_scan_shader(shader->tokens, &shader->info);
/* Collect basic info of the shader */
svga_tgsi_scan_shader(shader);
}
else {
debug_printf("Unexpected nir shader\n");
+57 -1
View File
@@ -29,6 +29,7 @@
#include "svga3d_reg.h"
#include "svga_context.h"
#include "svga_streamout.h"
#include "compiler/shader_enums.h"
/**
@@ -296,15 +297,70 @@ struct svga_cs_variant
};
struct svga_shader_info
{
ubyte num_inputs;
ubyte num_outputs;
ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS];
ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
ubyte input_usage_mask[PIPE_MAX_SHADER_INPUTS];
ubyte output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
ubyte output_usage_mask[PIPE_MAX_SHADER_OUTPUTS];
uint64_t generic_inputs_mask;
uint64_t generic_outputs_mask;
boolean writes_edgeflag;
boolean writes_layer;
boolean writes_position;
boolean writes_psize;
boolean writes_viewport_index;
boolean uses_grid_size;
boolean uses_const_buffers;
boolean uses_hw_atomic;
boolean uses_images;
boolean uses_image_size;
boolean uses_shader_buffers;
unsigned const_buffers_declared; /* bitmask of declared const buffers */
unsigned constbuf0_num_uniforms; /* number of uniforms in constbuf0 */
struct {
boolean color0_writes_all_cbufs;
} fs;
struct {
enum pipe_prim_type in_prim;
enum pipe_prim_type out_prim;
} gs;
struct {
unsigned vertices_out; /* number of vertices in tcs patch */
boolean writes_tess_factor;
} tcs;
struct {
enum pipe_prim_type prim_mode;
boolean reads_control_point;
boolean reads_tess_factor;
} tes;
};
struct svga_shader
{
enum pipe_shader_ir type; /* IR type */
enum pipe_shader_type stage; /* shader stage */
struct svga_shader_info info; /* shader info */
/* TGSI */
const struct tgsi_token *tokens;
struct svga_token_key token_key; /* token key for the token string */
struct tgsi_shader_info info;
struct tgsi_shader_info tgsi_info;
/* List of shaders with tokens derived from the same token string */
struct svga_shader *next;
@@ -1,6 +1,5 @@
/**********************************************************
* Copyright 2008-2009 VMware, Inc. All rights reserved.
* Copyright 2008-2022 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -605,7 +604,7 @@ emit_consts_vgpu9(struct svga_context *svga, enum pipe_shader_type shader)
}
assert(variant);
offset = variant->shader->info.file_max[TGSI_FILE_CONSTANT] + 1;
offset = variant->shader->info.constbuf0_num_uniforms;
assert(count <= ARRAY_SIZE(extras));
if (count > 0) {
-2
View File
@@ -90,8 +90,6 @@ make_cs_key(struct svga_context *svga,
memcpy(key->cs.grid_size, map, 3 * sizeof(uint));
pipe_buffer_unmap(&svga->pipe, transfer);
}
key->image_size_used = cs->base.info.opcode_count[TGSI_OPCODE_RESQ] ? 1 : 0;
}
+13 -14
View File
@@ -1,5 +1,5 @@
/**********************************************************
* Copyright 2008-2009 VMware, Inc. All rights reserved.
* Copyright 2008-2022 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -115,9 +115,9 @@ get_compiled_dummy_shader(struct svga_context *svga,
FREE((void *) fs->base.tokens);
fs->base.tokens = dummy;
tgsi_scan_shader(fs->base.tokens, &fs->base.info);
fs->generic_inputs = svga_get_generic_inputs_mask(&fs->base.info);
svga_remap_generics(fs->generic_inputs, fs->generic_remap_table);
svga_tgsi_scan_shader(&fs->base);
svga_remap_generics(fs->base.info.generic_inputs_mask,
fs->generic_remap_table);
variant = translate_fragment_program(svga, fs, key);
return variant;
@@ -194,11 +194,13 @@ make_fs_key(const struct svga_context *svga,
/* SVGA_NEW_GS, SVGA_NEW_VS
*/
if (svga->curr.gs) {
key->fs.gs_generic_outputs = svga->curr.gs->generic_outputs;
key->fs.layer_to_zero = !svga->curr.gs->base.info.writes_layer;
struct svga_geometry_shader *gs = svga->curr.gs;
struct svga_vertex_shader *vs = svga->curr.vs;
if (gs) {
key->fs.gs_generic_outputs = gs->base.info.generic_outputs_mask;
key->fs.layer_to_zero = !gs->base.info.writes_layer;
} else {
key->fs.vs_generic_outputs = svga->curr.vs->generic_outputs;
key->fs.vs_generic_outputs = vs->base.info.generic_outputs_mask;
key->fs.layer_to_zero = 1;
}
@@ -218,10 +220,10 @@ make_fs_key(const struct svga_context *svga,
*/
if (svga->curr.tes) {
shader = &svga->curr.tes->base;
prim_mode = shader->info.properties[TGSI_PROPERTY_TES_PRIM_MODE];
prim_mode = shader->info.tes.prim_mode;
} else if (svga->curr.gs) {
shader = &svga->curr.gs->base;
prim_mode = shader->info.properties[TGSI_PROPERTY_GS_OUTPUT_PRIM];
prim_mode = shader->info.gs.out_prim;
} else {
shader = &svga->curr.vs->base;
prim_mode = svga->curr.reduced_prim;
@@ -363,15 +365,12 @@ make_fs_key(const struct svga_context *svga,
}
/* SVGA_NEW_FRAME_BUFFER | SVGA_NEW_BLEND */
if (fs->base.info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS] ||
if (fs->base.info.fs.color0_writes_all_cbufs ||
svga->curr.blend->need_white_fragments) {
/* Replicate color0 output (or white) to N colorbuffers */
key->fs.write_color0_to_n_cbufs = svga->curr.framebuffer.nr_cbufs;
}
if (svga_have_gl43(svga))
key->image_size_used = fs->base.info.opcode_count[TGSI_OPCODE_RESQ] ? 1 : 0;
return PIPE_OK;
}
+2 -5
View File
@@ -1,5 +1,5 @@
/**********************************************************
* Copyright 2014 VMware, Inc. All rights reserved.
* Copyright 2014-2022 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -114,7 +114,7 @@ make_gs_key(struct svga_context *svga, struct svga_compile_key *key)
memcpy(key->generic_remap_table, gs->generic_remap_table,
sizeof(gs->generic_remap_table));
key->gs.vs_generic_outputs = svga->curr.vs->generic_outputs;
key->gs.vs_generic_outputs = svga->curr.vs->base.info.generic_outputs_mask;
key->gs.need_prescale = svga->state.hw_clear.prescale[0].enabled;
@@ -135,9 +135,6 @@ make_gs_key(struct svga_context *svga, struct svga_compile_key *key)
/* Mark this as the last shader in the vertex processing stage */
key->last_vertex_stage = 1;
if (svga_have_gl43(svga))
key->image_size_used = gs->base.info.opcode_count[TGSI_OPCODE_RESQ] ? 1 : 0;
}
@@ -1,5 +1,5 @@
/**********************************************************
* Copyright 2014 VMware, Inc. All rights reserved.
* Copyright 2014-2022 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -134,7 +134,7 @@ write_vpos(struct svga_context *svga,
struct svga_token_key key;
boolean use_existing = FALSE;
struct svga_shader *transform_shader;
const struct tgsi_shader_info *info = &shader->info;
const struct tgsi_shader_info *info = &shader->tgsi_info;
/* Create a token key */
memset(&key, 0, sizeof key);
@@ -181,7 +181,7 @@ transform_dynamic_indexing(struct svga_context *svga,
struct svga_token_key key;
boolean use_existing = FALSE;
struct svga_shader *transform_shader;
const struct tgsi_shader_info *info = &shader->info;
const struct tgsi_shader_info *info = &shader->tgsi_info;
/* Create a token key */
memset(&key, 0, sizeof key);
@@ -312,7 +312,7 @@ emulate_point_sprite(struct svga_context *svga,
if (pos_out_index != -1) {
assert(orig_gs != NULL);
templ.stream_output.output[pos_out_index].register_index =
orig_gs->base.info.num_outputs;
orig_gs->base.tgsi_info.num_outputs;
}
}
@@ -371,9 +371,9 @@ add_point_sprite_shader(struct svga_context *svga)
*/
orig_gs = (struct svga_geometry_shader *)
util_make_geometry_passthrough_shader(
&svga->pipe, vs->base.info.num_outputs,
vs->base.info.output_semantic_name,
vs->base.info.output_semantic_index);
&svga->pipe, vs->base.tgsi_info.num_outputs,
vs->base.tgsi_info.output_semantic_name,
vs->base.tgsi_info.output_semantic_index);
if (!orig_gs)
return NULL;
@@ -425,23 +425,23 @@ update_tgsi_transform(struct svga_context *svga, uint64_t dirty)
assert(svga_have_vgpu10(svga));
if (vs->base.info.num_outputs == 0) {
if (vs->base.tgsi_info.num_outputs == 0) {
write_vpos(svga, &vs->base);
}
if (vs && has_dynamic_indexing(&vs->base.info)) {
if (vs && has_dynamic_indexing(&vs->base.tgsi_info)) {
transform_dynamic_indexing(svga, &vs->base);
}
if (fs && has_dynamic_indexing(&fs->base.info)) {
if (fs && has_dynamic_indexing(&fs->base.tgsi_info)) {
transform_dynamic_indexing(svga, &fs->base);
}
if (gs && has_dynamic_indexing(&gs->base.info)) {
if (gs && has_dynamic_indexing(&gs->base.tgsi_info)) {
transform_dynamic_indexing(svga, &gs->base);
}
if (tcs && has_dynamic_indexing(&tcs->base.info)) {
if (tcs && has_dynamic_indexing(&tcs->base.tgsi_info)) {
transform_dynamic_indexing(svga, &tcs->base);
}
if (tes && has_dynamic_indexing(&tes->base.info)) {
if (tes && has_dynamic_indexing(&tes->base.tgsi_info)) {
transform_dynamic_indexing(svga, &tes->base);
}
@@ -452,7 +452,7 @@ update_tgsi_transform(struct svga_context *svga, uint64_t dirty)
* transform feedback is enabled.
*/
if (gs != NULL && !gs->base.stream_output &&
(gs->base.info.writes_psize || gs->wide_point)) {
(gs->base.tgsi_info.writes_psize || gs->wide_point)) {
orig_gs = gs->base.parent ? gs->base.parent : &gs->base;
new_gs = emulate_point_sprite(svga, orig_gs, orig_gs->tokens);
}
@@ -463,7 +463,7 @@ update_tgsi_transform(struct svga_context *svga, uint64_t dirty)
*/
else if (gs == NULL && !vs->base.stream_output &&
(svga->curr.rast->pointsize > 1.0 ||
vs->base.info.writes_psize)) {
vs->base.tgsi_info.writes_psize)) {
new_gs = add_point_sprite_shader(svga);
}
else {
+11 -45
View File
@@ -1,5 +1,5 @@
/**********************************************************
* Copyright 2018-2020 VMware, Inc. All rights reserved.
* Copyright 2018-2022 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -104,9 +104,6 @@ make_tcs_key(struct svga_context *svga, struct svga_compile_key *key)
/* tcs is always followed by tes */
key->last_vertex_stage = 0;
if (svga_have_gl43(svga))
key->image_size_used = tcs->base.info.opcode_count[TGSI_OPCODE_RESQ] ? 1 : 0;
}
@@ -220,7 +217,6 @@ static void
make_tes_key(struct svga_context *svga, struct svga_compile_key *key)
{
struct svga_tes_shader *tes = svga->curr.tes;
boolean has_control_point_inputs = FALSE;
memset(key, 0, sizeof *key);
@@ -231,22 +227,8 @@ make_tes_key(struct svga_context *svga, struct svga_compile_key *key)
assert(svga->curr.tcs);
/*
* Check if this tes expects any output control points from tcs.
*/
for (unsigned i = 0; i < tes->base.info.num_inputs; i++) {
switch (tes->base.info.input_semantic_name[i]) {
case TGSI_SEMANTIC_PATCH:
case TGSI_SEMANTIC_TESSOUTER:
case TGSI_SEMANTIC_TESSINNER:
break;
default:
has_control_point_inputs = TRUE;
}
}
key->tes.vertices_per_patch = has_control_point_inputs ?
svga->curr.tcs->base.info.properties[TGSI_PROPERTY_TCS_VERTICES_OUT] : 0;
key->tes.vertices_per_patch = tes->base.info.tes.reads_control_point ?
svga->curr.tcs->base.info.tcs.vertices_out : 0;
key->tes.need_prescale = svga->state.hw_clear.prescale[0].enabled &&
(svga->curr.gs == NULL);
@@ -264,24 +246,8 @@ make_tes_key(struct svga_context *svga, struct svga_compile_key *key)
/* This is the last vertex stage if there is no geometry shader. */
key->last_vertex_stage = !svga->curr.gs;
key->tes.need_tessinner = 0;
key->tes.need_tessouter = 0;
for (unsigned i = 0; i < svga->curr.tcs->base.info.num_outputs; i++) {
switch (svga->curr.tcs->base.info.output_semantic_name[i]) {
case TGSI_SEMANTIC_TESSOUTER:
key->tes.need_tessouter = 1;
break;
case TGSI_SEMANTIC_TESSINNER:
key->tes.need_tessinner = 1;
break;
default:
break;
}
}
if (svga_have_gl43(svga))
key->image_size_used = tes->base.info.opcode_count[TGSI_OPCODE_RESQ] ? 1 : 0;
key->tes.need_tessinner = svga->curr.tcs->base.info.tcs.writes_tess_factor;
key->tes.need_tessouter = svga->curr.tcs->base.info.tcs.writes_tess_factor;
}
@@ -306,12 +272,12 @@ get_passthrough_tcs(struct svga_context *svga)
new_tcs = (struct svga_tcs_shader *)
util_make_tess_ctrl_passthrough_shader(&svga->pipe,
svga->curr.vs->base.info.num_outputs,
svga->curr.tes->base.info.num_inputs,
svga->curr.vs->base.info.output_semantic_name,
svga->curr.vs->base.info.output_semantic_index,
svga->curr.tes->base.info.input_semantic_name,
svga->curr.tes->base.info.input_semantic_index,
svga->curr.vs->base.tgsi_info.num_outputs,
svga->curr.tes->base.tgsi_info.num_inputs,
svga->curr.vs->base.tgsi_info.output_semantic_name,
svga->curr.vs->base.tgsi_info.output_semantic_index,
svga->curr.tes->base.tgsi_info.input_semantic_name,
svga->curr.tes->base.tgsi_info.input_semantic_index,
svga->curr.vertices_per_patch);
svga->pipe.bind_tcs_state(&svga->pipe, new_tcs);
svga->tcs.passthrough_tcs = new_tcs;
+2 -2
View File
@@ -1,5 +1,5 @@
/**********************************************************
* Copyright 2008-2009 VMware, Inc. All rights reserved.
* Copyright 2008-2022 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -49,7 +49,7 @@ emit_hw_vs_vdecl(struct svga_context *svga, uint64_t dirty)
unsigned neg_bias = 0;
assert(svga->curr.velems->count >=
svga->curr.vs->base.info.file_count[TGSI_FILE_INPUT]);
svga->curr.vs->base.info.num_inputs);
/**
* We can't set the VDECL offset to something negative, so we
+8 -12
View File
@@ -1,5 +1,5 @@
/**********************************************************
* Copyright 2008-2009 VMware, Inc. All rights reserved.
* Copyright 2008-2022 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -105,8 +105,7 @@ get_compiled_dummy_vertex_shader(struct svga_context *svga,
FREE((void *) vs->base.tokens);
vs->base.tokens = dummy;
tgsi_scan_shader(vs->base.tokens, &vs->base.info);
vs->generic_outputs = svga_get_generic_outputs_mask(&vs->base.info);
svga_tgsi_scan_shader(&vs->base);
variant = translate_vertex_program(svga, vs, key);
return variant;
@@ -188,7 +187,7 @@ make_vs_key(struct svga_context *svga, struct svga_compile_key *key)
key->vs.allow_psiz = svga->curr.rast->templ.point_size_per_vertex;
/* SVGA_NEW_FS */
key->vs.fs_generic_inputs = svga->curr.fs->generic_inputs;
key->vs.fs_generic_inputs = svga->curr.fs->base.info.generic_inputs_mask;
svga_remap_generics(key->vs.fs_generic_inputs, key->generic_remap_table);
@@ -214,9 +213,6 @@ make_vs_key(struct svga_context *svga, struct svga_compile_key *key)
*/
key->last_vertex_stage = !(svga->curr.gs ||
svga->curr.tcs || svga->curr.tes);
if (svga_have_gl43(svga))
key->image_size_used = vs->base.info.opcode_count[TGSI_OPCODE_RESQ] ? 1 : 0;
}
@@ -285,7 +281,7 @@ compile_passthrough_vs(struct svga_context *svga,
assert(svga_have_vgpu10(svga));
assert(fs);
num_inputs = fs->base.info.num_inputs;
num_inputs = fs->base.tgsi_info.num_inputs;
ureg = ureg_create(PIPE_SHADER_VERTEX);
if (!ureg)
@@ -305,13 +301,13 @@ compile_passthrough_vs(struct svga_context *svga,
* number of inputs to the vertex shader.
*/
for (i = 0; i < num_inputs; i++) {
switch (fs->base.info.input_semantic_name[i]) {
switch (fs->base.tgsi_info.input_semantic_name[i]) {
case TGSI_SEMANTIC_COLOR:
case TGSI_SEMANTIC_GENERIC:
case TGSI_SEMANTIC_FOG:
dst[num_elements] = ureg_DECL_output(ureg,
fs->base.info.input_semantic_name[i],
fs->base.info.input_semantic_index[i]);
fs->base.tgsi_info.input_semantic_name[i],
fs->base.tgsi_info.input_semantic_index[i]);
src[num_elements] = ureg_DECL_vs_input(ureg, num_elements);
num_elements++;
break;
@@ -328,7 +324,7 @@ compile_passthrough_vs(struct svga_context *svga,
memset(&new_vs, 0, sizeof(new_vs));
new_vs.base.tokens = ureg_get_tokens(ureg, NULL);
tgsi_scan_shader(new_vs.base.tokens, &new_vs.base.info);
svga_tgsi_scan_shader(&new_vs.base);
memset(&key, 0, sizeof(key));
key.vs.undo_viewport = 1;
+2 -2
View File
@@ -248,8 +248,8 @@ svga_swtnl_update_vdecl(struct svga_context *svga)
nr_decls++;
for (i = 0; i < fs->base.info.num_inputs; i++) {
const enum tgsi_semantic sem_name = fs->base.info.input_semantic_name[i];
const unsigned sem_index = fs->base.info.input_semantic_index[i];
const enum tgsi_semantic sem_name = fs->base.tgsi_info.input_semantic_name[i];
const unsigned sem_index = fs->base.tgsi_info.input_semantic_index[i];
src = draw_find_shader_output(draw, sem_name, sem_index);
+239 -1
View File
@@ -1,5 +1,5 @@
/**********************************************************
* Copyright 2008-2009 VMware, Inc. All rights reserved.
* Copyright 2008-2022 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -277,3 +277,241 @@ done:
SVGA_STATS_TIME_POP(svga_sws(svga));
return variant;
}
/**
* Helper function to convert tgsi semantic name to vertex attribute
* semantic name.
*/
static gl_vert_attrib
svga_tgsi_to_gl_vert_attrib_semantic(unsigned sem_name,
unsigned sem_index)
{
switch (sem_name) {
case TGSI_SEMANTIC_POSITION:
return VERT_ATTRIB_POS;
case TGSI_SEMANTIC_COLOR:
assert(sem_index <= 1);
return VERT_ATTRIB_COLOR0;
case TGSI_SEMANTIC_FOG:
return VERT_ATTRIB_FOG;
case TGSI_SEMANTIC_PSIZE:
return VERT_ATTRIB_POINT_SIZE;
case TGSI_SEMANTIC_GENERIC:
return VERT_ATTRIB_GENERIC0;
case TGSI_SEMANTIC_EDGEFLAG:
return VERT_ATTRIB_EDGEFLAG;
case TGSI_SEMANTIC_TEXCOORD:
assert(sem_index <= 7);
return VERT_ATTRIB_TEX0;
default:
assert(0);
return VERT_ATTRIB_POS;
}
}
/**
* Helper function to convert tgsi semantic name to varying semantic name.
*/
static gl_varying_slot
svga_tgsi_to_gl_varying_semantic(unsigned sem_name,
unsigned sem_index)
{
switch (sem_name) {
case TGSI_SEMANTIC_POSITION:
return VARYING_SLOT_POS;
case TGSI_SEMANTIC_COLOR:
assert(sem_index <= 1);
return VARYING_SLOT_COL0;
case TGSI_SEMANTIC_BCOLOR:
assert(sem_index <= 1);
return VARYING_SLOT_BFC0;
case TGSI_SEMANTIC_FOG:
return VARYING_SLOT_FOGC;
case TGSI_SEMANTIC_PSIZE:
return VARYING_SLOT_PSIZ;
case TGSI_SEMANTIC_GENERIC:
return VARYING_SLOT_VAR0;
case TGSI_SEMANTIC_FACE:
return VARYING_SLOT_FACE;
case TGSI_SEMANTIC_EDGEFLAG:
return VARYING_SLOT_EDGE;
case TGSI_SEMANTIC_CLIPDIST:
assert(sem_index <= 1);
return VARYING_SLOT_CLIP_DIST0;
case TGSI_SEMANTIC_CLIPVERTEX:
return VARYING_SLOT_CLIP_VERTEX;
case TGSI_SEMANTIC_TEXCOORD:
assert(sem_index <= 7);
return VARYING_SLOT_TEX0;
case TGSI_SEMANTIC_PCOORD:
return VARYING_SLOT_PNTC;
case TGSI_SEMANTIC_VIEWPORT_INDEX:
return VARYING_SLOT_VIEWPORT;
case TGSI_SEMANTIC_LAYER:
return VARYING_SLOT_LAYER;
case TGSI_SEMANTIC_PATCH:
return VARYING_SLOT_PATCH0;
case TGSI_SEMANTIC_TESSOUTER:
return VARYING_SLOT_TESS_LEVEL_OUTER;
case TGSI_SEMANTIC_TESSINNER:
return VARYING_SLOT_TESS_LEVEL_INNER;
case TGSI_SEMANTIC_VIEWPORT_MASK:
return VARYING_SLOT_VIEWPORT_MASK;
case TGSI_SEMANTIC_PRIMID:
return VARYING_SLOT_PRIMITIVE_ID;
default:
assert(0);
return VARYING_SLOT_POS;
}
}
/**
* Helper function to convert tgsi semantic name to fragment result
* semantic name.
*/
static gl_frag_result
svga_tgsi_to_gl_frag_result_semantic(unsigned sem_name,
unsigned sem_index)
{
switch (sem_name) {
case TGSI_SEMANTIC_POSITION:
return FRAG_RESULT_DEPTH;
case TGSI_SEMANTIC_COLOR:
assert(sem_index <= 7);
return FRAG_RESULT_DATA0;
case TGSI_SEMANTIC_STENCIL:
return FRAG_RESULT_STENCIL;
case TGSI_SEMANTIC_SAMPLEMASK:
return FRAG_RESULT_SAMPLE_MASK;
default:
assert(0);
return FRAG_RESULT_DATA0;
}
}
/**
* svga_tgsi_scan_shader is called to collect information of the
* specified tgsi shader.
*/
void
svga_tgsi_scan_shader(struct svga_shader *shader)
{
struct tgsi_shader_info *tgsi_info = &shader->tgsi_info;
struct svga_shader_info *info = &shader->info;
tgsi_scan_shader(shader->tokens, tgsi_info);
/* Save some common shader info in IR neutral format */
info->num_inputs = tgsi_info->num_inputs;
info->num_outputs = tgsi_info->num_outputs;
info->writes_edgeflag = tgsi_info->writes_edgeflag;
info->writes_layer = tgsi_info->writes_layer;
info->writes_position = tgsi_info->writes_position;
info->writes_psize = tgsi_info->writes_psize;
info->writes_viewport_index = tgsi_info->writes_viewport_index;
info->uses_grid_size = tgsi_info->uses_grid_size;
info->uses_const_buffers = tgsi_info->const_buffers_declared != 0;
info->uses_hw_atomic = tgsi_info->hw_atomic_declared != 0;
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->const_buffers_declared = tgsi_info->const_buffers_declared;
info->generic_inputs_mask = svga_get_generic_inputs_mask(tgsi_info);
info->generic_outputs_mask = svga_get_generic_outputs_mask(tgsi_info);
/* Convert TGSI inputs semantic.
* Vertex shader does not have varying inputs but vertex attributes.
*/
if (shader->stage == PIPE_SHADER_VERTEX) {
for (unsigned i = 0; i < info->num_inputs; i++) {
info->input_semantic_name[i] =
svga_tgsi_to_gl_vert_attrib_semantic(
tgsi_info->input_semantic_name[i],
tgsi_info->input_semantic_index[i]);
info->input_semantic_index[i] = tgsi_info->input_semantic_index[i];
}
}
else {
for (unsigned i = 0; i < info->num_inputs; i++) {
info->input_semantic_name[i] =
svga_tgsi_to_gl_varying_semantic(
tgsi_info->input_semantic_name[i],
tgsi_info->input_semantic_index[i]);
info->input_semantic_index[i] = tgsi_info->input_semantic_index[i];
}
}
/* Convert TGSI outputs semantic.
* Fragment shader does not have varying outputs but fragment results.
*/
if (shader->stage == PIPE_SHADER_FRAGMENT) {
for (unsigned i = 0; i < info->num_outputs; i++) {
info->output_semantic_name[i] =
svga_tgsi_to_gl_frag_result_semantic(
tgsi_info->output_semantic_name[i],
tgsi_info->output_semantic_index[i]);
info->output_semantic_index[i] = tgsi_info->output_semantic_index[i];
}
}
else {
for (unsigned i = 0; i < info->num_outputs; i++) {
info->output_semantic_name[i] =
svga_tgsi_to_gl_varying_semantic(
tgsi_info->output_semantic_name[i],
tgsi_info->output_semantic_index[i]);
info->output_semantic_index[i] = tgsi_info->output_semantic_index[i];
}
}
info->constbuf0_num_uniforms = tgsi_info->const_file_max[0] + 1;
switch (tgsi_info->processor) {
case PIPE_SHADER_FRAGMENT:
info->fs.color0_writes_all_cbufs =
tgsi_info->properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS];
break;
case PIPE_SHADER_GEOMETRY:
info->gs.out_prim = tgsi_info->properties[TGSI_PROPERTY_GS_OUTPUT_PRIM];
info->gs.in_prim = tgsi_info->properties[TGSI_PROPERTY_GS_INPUT_PRIM];
break;
case PIPE_SHADER_TESS_CTRL:
info->tcs.vertices_out =
tgsi_info->properties[TGSI_PROPERTY_TCS_VERTICES_OUT];
for (unsigned i = 0; i < info->num_outputs; i++) {
switch (tgsi_info->output_semantic_name[i]) {
case TGSI_SEMANTIC_TESSOUTER:
case TGSI_SEMANTIC_TESSINNER:
info->tcs.writes_tess_factor = TRUE;
break;
default:
break;
}
}
break;
case PIPE_SHADER_TESS_EVAL:
info->tes.prim_mode =
tgsi_info->properties[TGSI_PROPERTY_TES_PRIM_MODE];
info->tes.reads_tess_factor = tgsi_info->reads_tess_factors;
for (unsigned i = 0; i < info->num_inputs; i++) {
switch (tgsi_info->input_semantic_name[i]) {
case TGSI_SEMANTIC_PATCH:
case TGSI_SEMANTIC_TESSOUTER:
case TGSI_SEMANTIC_TESSINNER:
break;
default:
info->tes.reads_control_point = TRUE;
}
}
break;
default:
break;
}
}
+4 -1
View File
@@ -1,5 +1,5 @@
/**********************************************************
* Copyright 2008-2009 VMware, Inc. All rights reserved.
* Copyright 2008-2022 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -76,4 +76,7 @@ svga_tgsi_vgpu10_translate(struct svga_context *svga,
boolean svga_shader_verify(const uint32_t *tokens, unsigned nr_tokens);
void
svga_tgsi_scan_shader(struct svga_shader *shader);
#endif
+3 -3
View File
@@ -12737,8 +12737,8 @@ compute_input_mapping(struct svga_context *svga,
}
if (prevShader != NULL) {
svga_link_shaders(&prevShader->info, &emit->info, &emit->linkage);
emit->prevShaderInfo = &prevShader->info;
svga_link_shaders(&prevShader->tgsi_info, &emit->info, &emit->linkage);
emit->prevShaderInfo = &prevShader->tgsi_info;
}
else {
/**
@@ -12978,7 +12978,7 @@ svga_tgsi_vgpu10_translate(struct svga_context *svga,
if (tokens != shader->tokens) {
tgsi_scan_shader(tokens, &emit->info);
} else {
emit->info = shader->info;
emit->info = shader->tgsi_info;
}
emit->num_outputs = emit->info.num_outputs;