st/mesa: cleanup st_translate_geometry_program
Mostly dead code or code that didn't do anything. Computing gs_num_outputs at the end was also useless. It's already set correctly. Reviewed-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
@@ -869,11 +869,8 @@ st_translate_geometry_program(struct st_context *st,
|
|||||||
GLuint outputMapping[VARYING_SLOT_MAX];
|
GLuint outputMapping[VARYING_SLOT_MAX];
|
||||||
struct pipe_context *pipe = st->pipe;
|
struct pipe_context *pipe = st->pipe;
|
||||||
GLuint attr;
|
GLuint attr;
|
||||||
GLbitfield64 inputsRead;
|
|
||||||
|
|
||||||
uint gs_num_inputs = 0;
|
uint gs_num_inputs = 0;
|
||||||
uint gs_builtin_inputs = 0;
|
|
||||||
uint gs_array_offset = 0;
|
|
||||||
|
|
||||||
ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS];
|
ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS];
|
||||||
ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
|
ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
|
||||||
@@ -883,21 +880,15 @@ st_translate_geometry_program(struct st_context *st,
|
|||||||
uint gs_num_outputs = 0;
|
uint gs_num_outputs = 0;
|
||||||
|
|
||||||
GLint i;
|
GLint i;
|
||||||
GLuint maxSlot = 0;
|
|
||||||
struct ureg_program *ureg;
|
struct ureg_program *ureg;
|
||||||
struct pipe_shader_state state = {0};
|
struct pipe_shader_state state = {0};
|
||||||
|
|
||||||
struct st_gp_variant *gpv;
|
struct st_gp_variant *gpv;
|
||||||
|
|
||||||
gpv = CALLOC_STRUCT(st_gp_variant);
|
gpv = CALLOC_STRUCT(st_gp_variant);
|
||||||
if (!gpv)
|
if (!gpv)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!stgp->glsl_to_tgsi) {
|
ureg = ureg_create(TGSI_PROCESSOR_GEOMETRY);
|
||||||
_mesa_remove_output_reads(&stgp->Base.Base, PROGRAM_OUTPUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
ureg = ureg_create( TGSI_PROCESSOR_GEOMETRY );
|
|
||||||
if (ureg == NULL) {
|
if (ureg == NULL) {
|
||||||
free(gpv);
|
free(gpv);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -909,25 +900,12 @@ st_translate_geometry_program(struct st_context *st,
|
|||||||
/*
|
/*
|
||||||
* Convert Mesa program inputs to TGSI input register semantics.
|
* Convert Mesa program inputs to TGSI input register semantics.
|
||||||
*/
|
*/
|
||||||
inputsRead = stgp->Base.Base.InputsRead;
|
|
||||||
for (attr = 0; attr < VARYING_SLOT_MAX; attr++) {
|
for (attr = 0; attr < VARYING_SLOT_MAX; attr++) {
|
||||||
if ((inputsRead & BITFIELD64_BIT(attr)) != 0) {
|
if ((stgp->Base.Base.InputsRead & BITFIELD64_BIT(attr)) != 0) {
|
||||||
const GLuint slot = gs_num_inputs;
|
const GLuint slot = gs_num_inputs++;
|
||||||
|
|
||||||
gs_num_inputs++;
|
|
||||||
|
|
||||||
inputMapping[attr] = slot;
|
inputMapping[attr] = slot;
|
||||||
|
|
||||||
if (attr != VARYING_SLOT_PRIMITIVE_ID) {
|
|
||||||
gs_array_offset += 2;
|
|
||||||
} else
|
|
||||||
++gs_builtin_inputs;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
debug_printf("input map at %d = %d\n",
|
|
||||||
slot + gs_array_offset, stgp->input_map[slot + gs_array_offset]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
case VARYING_SLOT_PRIMITIVE_ID:
|
case VARYING_SLOT_PRIMITIVE_ID:
|
||||||
input_semantic_name[slot] = TGSI_SEMANTIC_PRIMID;
|
input_semantic_name[slot] = TGSI_SEMANTIC_PRIMID;
|
||||||
@@ -1002,10 +980,8 @@ st_translate_geometry_program(struct st_context *st,
|
|||||||
*/
|
*/
|
||||||
for (attr = 0; attr < VARYING_SLOT_MAX; attr++) {
|
for (attr = 0; attr < VARYING_SLOT_MAX; attr++) {
|
||||||
if (stgp->Base.Base.OutputsWritten & BITFIELD64_BIT(attr)) {
|
if (stgp->Base.Base.OutputsWritten & BITFIELD64_BIT(attr)) {
|
||||||
GLuint slot;
|
GLuint slot = gs_num_outputs++;
|
||||||
|
|
||||||
slot = gs_num_outputs;
|
|
||||||
gs_num_outputs++;
|
|
||||||
outputMapping[attr] = slot;
|
outputMapping[attr] = slot;
|
||||||
|
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
@@ -1088,86 +1064,38 @@ st_translate_geometry_program(struct st_context *st,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find max output slot referenced to compute gs_num_outputs */
|
|
||||||
for (attr = 0; attr < VARYING_SLOT_MAX; attr++) {
|
|
||||||
if (outputMapping[attr] != ~0U && outputMapping[attr] > maxSlot)
|
|
||||||
maxSlot = outputMapping[attr];
|
|
||||||
}
|
|
||||||
gs_num_outputs = maxSlot + 1;
|
|
||||||
|
|
||||||
#if 0 /* debug */
|
|
||||||
{
|
|
||||||
GLuint i;
|
|
||||||
printf("outputMapping? %d\n", outputMapping ? 1 : 0);
|
|
||||||
if (outputMapping) {
|
|
||||||
printf("attr -> slot\n");
|
|
||||||
for (i = 0; i < 16; i++) {
|
|
||||||
printf(" %2d %3d\n", i, outputMapping[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("slot sem_name sem_index\n");
|
|
||||||
for (i = 0; i < gs_num_outputs; i++) {
|
|
||||||
printf(" %2d %d %d\n",
|
|
||||||
i,
|
|
||||||
gs_output_semantic_name[i],
|
|
||||||
gs_output_semantic_index[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ureg_property(ureg, TGSI_PROPERTY_GS_INPUT_PRIM, stgp->Base.InputType);
|
ureg_property(ureg, TGSI_PROPERTY_GS_INPUT_PRIM, stgp->Base.InputType);
|
||||||
ureg_property(ureg, TGSI_PROPERTY_GS_OUTPUT_PRIM, stgp->Base.OutputType);
|
ureg_property(ureg, TGSI_PROPERTY_GS_OUTPUT_PRIM, stgp->Base.OutputType);
|
||||||
ureg_property(ureg, TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES,
|
ureg_property(ureg, TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES,
|
||||||
stgp->Base.VerticesOut);
|
stgp->Base.VerticesOut);
|
||||||
ureg_property(ureg, TGSI_PROPERTY_GS_INVOCATIONS, stgp->Base.Invocations);
|
ureg_property(ureg, TGSI_PROPERTY_GS_INVOCATIONS, stgp->Base.Invocations);
|
||||||
|
|
||||||
if (stgp->glsl_to_tgsi)
|
st_translate_program(st->ctx,
|
||||||
st_translate_program(st->ctx,
|
TGSI_PROCESSOR_GEOMETRY,
|
||||||
TGSI_PROCESSOR_GEOMETRY,
|
ureg,
|
||||||
ureg,
|
stgp->glsl_to_tgsi,
|
||||||
stgp->glsl_to_tgsi,
|
&stgp->Base.Base,
|
||||||
&stgp->Base.Base,
|
/* inputs */
|
||||||
/* inputs */
|
gs_num_inputs,
|
||||||
gs_num_inputs,
|
inputMapping,
|
||||||
inputMapping,
|
input_semantic_name,
|
||||||
input_semantic_name,
|
input_semantic_index,
|
||||||
input_semantic_index,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
/* outputs */
|
||||||
/* outputs */
|
gs_num_outputs,
|
||||||
gs_num_outputs,
|
outputMapping,
|
||||||
outputMapping,
|
gs_output_semantic_name,
|
||||||
gs_output_semantic_name,
|
gs_output_semantic_index,
|
||||||
gs_output_semantic_index,
|
FALSE,
|
||||||
FALSE,
|
FALSE);
|
||||||
FALSE);
|
|
||||||
else
|
|
||||||
st_translate_mesa_program(st->ctx,
|
|
||||||
TGSI_PROCESSOR_GEOMETRY,
|
|
||||||
ureg,
|
|
||||||
&stgp->Base.Base,
|
|
||||||
/* inputs */
|
|
||||||
gs_num_inputs,
|
|
||||||
inputMapping,
|
|
||||||
input_semantic_name,
|
|
||||||
input_semantic_index,
|
|
||||||
NULL,
|
|
||||||
/* outputs */
|
|
||||||
gs_num_outputs,
|
|
||||||
outputMapping,
|
|
||||||
gs_output_semantic_name,
|
|
||||||
gs_output_semantic_index,
|
|
||||||
FALSE,
|
|
||||||
FALSE);
|
|
||||||
|
|
||||||
state.tokens = ureg_get_tokens( ureg, NULL );
|
state.tokens = ureg_get_tokens(ureg, NULL);
|
||||||
ureg_destroy( ureg );
|
ureg_destroy(ureg);
|
||||||
|
|
||||||
if (stgp->glsl_to_tgsi) {
|
st_translate_stream_output_info(stgp->glsl_to_tgsi,
|
||||||
st_translate_stream_output_info(stgp->glsl_to_tgsi,
|
outputMapping,
|
||||||
outputMapping,
|
&state.stream_output);
|
||||||
&state.stream_output);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
|
if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
|
||||||
_mesa_print_program(&stgp->Base.Base);
|
_mesa_print_program(&stgp->Base.Base);
|
||||||
|
Reference in New Issue
Block a user