tgsi: simplify shader properties in tgsi_shader_info
Use an array of properties indexed by TGSI_PROPERTY_* definitions.
This commit is contained in:
parent
5233568861
commit
8908fae243
|
@ -750,9 +750,6 @@ draw_create_geometry_shader(struct draw_context *draw,
|
||||||
tgsi_scan_shader(state->tokens, &gs->info);
|
tgsi_scan_shader(state->tokens, &gs->info);
|
||||||
|
|
||||||
/* setup the defaults */
|
/* setup the defaults */
|
||||||
gs->input_primitive = PIPE_PRIM_TRIANGLES;
|
|
||||||
gs->output_primitive = PIPE_PRIM_TRIANGLE_STRIP;
|
|
||||||
gs->max_output_vertices = 32;
|
|
||||||
gs->max_out_prims = 0;
|
gs->max_out_prims = 0;
|
||||||
|
|
||||||
#ifdef HAVE_LLVM
|
#ifdef HAVE_LLVM
|
||||||
|
@ -768,17 +765,15 @@ draw_create_geometry_shader(struct draw_context *draw,
|
||||||
gs->vector_length = 1;
|
gs->vector_length = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < gs->info.num_properties; ++i) {
|
gs->input_primitive =
|
||||||
if (gs->info.properties[i].name ==
|
gs->info.properties[TGSI_PROPERTY_GS_INPUT_PRIM][0];
|
||||||
TGSI_PROPERTY_GS_INPUT_PRIM)
|
gs->output_primitive =
|
||||||
gs->input_primitive = gs->info.properties[i].data[0];
|
gs->info.properties[TGSI_PROPERTY_GS_OUTPUT_PRIM][0];
|
||||||
else if (gs->info.properties[i].name ==
|
gs->max_output_vertices =
|
||||||
TGSI_PROPERTY_GS_OUTPUT_PRIM)
|
gs->info.properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES][0];
|
||||||
gs->output_primitive = gs->info.properties[i].data[0];
|
if (!gs->max_output_vertices)
|
||||||
else if (gs->info.properties[i].name ==
|
gs->max_output_vertices = 32;
|
||||||
TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES)
|
|
||||||
gs->max_output_vertices = gs->info.properties[i].data[0];
|
|
||||||
}
|
|
||||||
/* Primitive boundary is bigger than max_output_vertices by one, because
|
/* Primitive boundary is bigger than max_output_vertices by one, because
|
||||||
* the specification says that the geometry shader should exit if the
|
* the specification says that the geometry shader should exit if the
|
||||||
* number of emitted vertices is bigger or equal to max_output_vertices and
|
* number of emitted vertices is bigger or equal to max_output_vertices and
|
||||||
|
|
|
@ -3855,8 +3855,8 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
|
||||||
* were forgetting so we're using MAX_VERTEX_VARYING from
|
* were forgetting so we're using MAX_VERTEX_VARYING from
|
||||||
* that spec even though we could debug_assert if it's not
|
* that spec even though we could debug_assert if it's not
|
||||||
* set, but that's a lot uglier. */
|
* set, but that's a lot uglier. */
|
||||||
uint max_output_vertices = 32;
|
uint max_output_vertices;
|
||||||
uint i = 0;
|
|
||||||
/* inputs are always indirect with gs */
|
/* inputs are always indirect with gs */
|
||||||
bld.indirect_files |= (1 << TGSI_FILE_INPUT);
|
bld.indirect_files |= (1 << TGSI_FILE_INPUT);
|
||||||
bld.gs_iface = gs_iface;
|
bld.gs_iface = gs_iface;
|
||||||
|
@ -3864,12 +3864,11 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm,
|
||||||
bld.bld_base.op_actions[TGSI_OPCODE_EMIT].emit = emit_vertex;
|
bld.bld_base.op_actions[TGSI_OPCODE_EMIT].emit = emit_vertex;
|
||||||
bld.bld_base.op_actions[TGSI_OPCODE_ENDPRIM].emit = end_primitive;
|
bld.bld_base.op_actions[TGSI_OPCODE_ENDPRIM].emit = end_primitive;
|
||||||
|
|
||||||
for (i = 0; i < info->num_properties; ++i) {
|
max_output_vertices =
|
||||||
if (info->properties[i].name ==
|
info->properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES][0];
|
||||||
TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES) {
|
if (!max_output_vertices)
|
||||||
max_output_vertices = info->properties[i].data[0];
|
max_output_vertices = 32;
|
||||||
}
|
|
||||||
}
|
|
||||||
bld.max_output_vertices_vec =
|
bld.max_output_vertices_vec =
|
||||||
lp_build_const_int_vec(gallivm, bld.bld_base.int_bld.type,
|
lp_build_const_int_vec(gallivm, bld.bld_base.int_bld.type,
|
||||||
max_output_vertices);
|
max_output_vertices);
|
||||||
|
|
|
@ -277,13 +277,11 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
|
||||||
{
|
{
|
||||||
const struct tgsi_full_property *fullprop
|
const struct tgsi_full_property *fullprop
|
||||||
= &parse.FullToken.FullProperty;
|
= &parse.FullToken.FullProperty;
|
||||||
|
unsigned name = fullprop->Property.PropertyName;
|
||||||
|
|
||||||
info->properties[info->num_properties].name =
|
assert(name < Elements(info->properties));
|
||||||
fullprop->Property.PropertyName;
|
memcpy(info->properties[name],
|
||||||
memcpy(info->properties[info->num_properties].data,
|
fullprop->u, 8 * sizeof(unsigned));
|
||||||
fullprop->u, 8 * sizeof(unsigned));;
|
|
||||||
|
|
||||||
++info->num_properties;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -296,23 +294,19 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
|
||||||
info->opcode_count[TGSI_OPCODE_KILL]);
|
info->opcode_count[TGSI_OPCODE_KILL]);
|
||||||
|
|
||||||
/* extract simple properties */
|
/* extract simple properties */
|
||||||
for (i = 0; i < info->num_properties; ++i) {
|
info->origin_lower_left =
|
||||||
switch (info->properties[i].name) {
|
info->properties[TGSI_PROPERTY_FS_COORD_ORIGIN][0];
|
||||||
case TGSI_PROPERTY_FS_COORD_ORIGIN:
|
info->pixel_center_integer =
|
||||||
info->origin_lower_left = info->properties[i].data[0];
|
info->properties[TGSI_PROPERTY_FS_COORD_PIXEL_CENTER][0];
|
||||||
break;
|
info->color0_writes_all_cbufs =
|
||||||
case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER:
|
info->properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS][0];
|
||||||
info->pixel_center_integer = info->properties[i].data[0];
|
|
||||||
break;
|
|
||||||
case TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS:
|
|
||||||
info->color0_writes_all_cbufs = info->properties[i].data[0];
|
|
||||||
break;
|
|
||||||
case TGSI_PROPERTY_GS_INPUT_PRIM:
|
|
||||||
/* The dimensions of the IN decleration in geometry shader have
|
/* The dimensions of the IN decleration in geometry shader have
|
||||||
* to be deduced from the type of the input primitive.
|
* to be deduced from the type of the input primitive.
|
||||||
*/
|
*/
|
||||||
if (procType == TGSI_PROCESSOR_GEOMETRY) {
|
if (procType == TGSI_PROCESSOR_GEOMETRY) {
|
||||||
unsigned input_primitive = info->properties[i].data[0];
|
unsigned input_primitive =
|
||||||
|
info->properties[TGSI_PROPERTY_GS_INPUT_PRIM][0];
|
||||||
int num_verts = u_vertices_per_prim(input_primitive);
|
int num_verts = u_vertices_per_prim(input_primitive);
|
||||||
int j;
|
int j;
|
||||||
info->file_count[TGSI_FILE_INPUT] = num_verts;
|
info->file_count[TGSI_FILE_INPUT] = num_verts;
|
||||||
|
@ -322,11 +316,6 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
|
||||||
info->file_mask[TGSI_FILE_INPUT] |= (1 << j);
|
info->file_mask[TGSI_FILE_INPUT] |= (1 << j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tgsi_parse_free (&parse);
|
tgsi_parse_free (&parse);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,11 +91,7 @@ struct tgsi_shader_info
|
||||||
*/
|
*/
|
||||||
unsigned indirect_files;
|
unsigned indirect_files;
|
||||||
|
|
||||||
struct {
|
unsigned properties[TGSI_PROPERTY_COUNT][8]; /* index with TGSI_PROPERTY_ */
|
||||||
unsigned name;
|
|
||||||
unsigned data[8];
|
|
||||||
} properties[TGSI_PROPERTY_COUNT];
|
|
||||||
uint num_properties;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
|
|
|
@ -407,7 +407,6 @@ util_pstipple_create_fragment_shader(struct pipe_context *pipe,
|
||||||
struct pipe_shader_state *new_fs;
|
struct pipe_shader_state *new_fs;
|
||||||
struct pstip_transform_context transform;
|
struct pstip_transform_context transform;
|
||||||
const uint newLen = tgsi_num_tokens(fs->tokens) + NUM_NEW_TOKENS;
|
const uint newLen = tgsi_num_tokens(fs->tokens) + NUM_NEW_TOKENS;
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
new_fs = MALLOC(sizeof(*new_fs));
|
new_fs = MALLOC(sizeof(*new_fs));
|
||||||
if (!new_fs)
|
if (!new_fs)
|
||||||
|
@ -433,11 +432,8 @@ util_pstipple_create_fragment_shader(struct pipe_context *pipe,
|
||||||
|
|
||||||
tgsi_scan_shader(fs->tokens, &transform.info);
|
tgsi_scan_shader(fs->tokens, &transform.info);
|
||||||
|
|
||||||
/* find fragment coordinate origin property */
|
transform.coordOrigin =
|
||||||
for (i = 0; i < transform.info.num_properties; i++) {
|
transform.info.properties[TGSI_PROPERTY_FS_COORD_ORIGIN][0];
|
||||||
if (transform.info.properties[i].name == TGSI_PROPERTY_FS_COORD_ORIGIN)
|
|
||||||
transform.coordOrigin = transform.info.properties[i].data[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
tgsi_transform_shader(fs->tokens,
|
tgsi_transform_shader(fs->tokens,
|
||||||
(struct tgsi_token *) new_fs->tokens,
|
(struct tgsi_token *) new_fs->tokens,
|
||||||
|
|
|
@ -2212,14 +2212,8 @@ generate_fragment(struct llvmpipe_context *lp,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if writes to cbuf[0] are to be copied to all cbufs */
|
/* check if writes to cbuf[0] are to be copied to all cbufs */
|
||||||
cbuf0_write_all = FALSE;
|
cbuf0_write_all =
|
||||||
for (i = 0;i < shader->info.base.num_properties; i++) {
|
shader->info.base.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS][0];
|
||||||
if (shader->info.base.properties[i].name ==
|
|
||||||
TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS) {
|
|
||||||
cbuf0_write_all = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: actually pick these based on the fs and color buffer
|
/* TODO: actually pick these based on the fs and color buffer
|
||||||
* characteristics. */
|
* characteristics. */
|
||||||
|
|
|
@ -1138,24 +1138,12 @@ _nvfx_fragprog_translate(uint16_t oclass, struct nv30_fragprog *fp)
|
||||||
fpc->num_regs = 2;
|
fpc->num_regs = 2;
|
||||||
memset(fp->texcoord, 0xff, sizeof(fp->texcoord));
|
memset(fp->texcoord, 0xff, sizeof(fp->texcoord));
|
||||||
|
|
||||||
for (unsigned i = 0; i < fp->info.num_properties; ++i) {
|
if (fp->info.properties[TGSI_PROPERTY_FS_COORD_ORIGIN][0])
|
||||||
switch (fp->info.properties[i].name) {
|
|
||||||
case TGSI_PROPERTY_FS_COORD_ORIGIN:
|
|
||||||
if (fp->info.properties[i].data[0])
|
|
||||||
fp->coord_conventions |= NV30_3D_COORD_CONVENTIONS_ORIGIN_INVERTED;
|
fp->coord_conventions |= NV30_3D_COORD_CONVENTIONS_ORIGIN_INVERTED;
|
||||||
break;
|
if (fp->info.properties[TGSI_PROPERTY_FS_COORD_PIXEL_CENTER][0])
|
||||||
case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER:
|
|
||||||
if (fp->info.properties[i].data[0])
|
|
||||||
fp->coord_conventions |= NV30_3D_COORD_CONVENTIONS_CENTER_INTEGER;
|
fp->coord_conventions |= NV30_3D_COORD_CONVENTIONS_CENTER_INTEGER;
|
||||||
break;
|
if (fp->info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS][0])
|
||||||
case TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS:
|
|
||||||
if (fp->info.properties[i].data[0])
|
|
||||||
fp->rt_enable |= NV30_3D_RT_ENABLE_MRT;
|
fp->rt_enable |= NV30_3D_RT_ENABLE_MRT;
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!nvfx_fragprog_prepare(fpc))
|
if (!nvfx_fragprog_prepare(fpc))
|
||||||
goto out_err;
|
goto out_err;
|
||||||
|
|
|
@ -468,12 +468,8 @@ static void r300_translate_fragment_shader(
|
||||||
|
|
||||||
find_output_registers(&compiler, shader);
|
find_output_registers(&compiler, shader);
|
||||||
|
|
||||||
shader->write_all = FALSE;
|
shader->write_all =
|
||||||
for (i = 0; i < shader->info.num_properties; i++) {
|
shader->info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS][0];
|
||||||
if (shader->info.properties[i].name == TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS) {
|
|
||||||
shader->write_all = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (compiler.Base.Debug & RC_DBG_LOG) {
|
if (compiler.Base.Debug & RC_DBG_LOG) {
|
||||||
DBG(r300, DBG_FP, "r300: Initial fragment program\n");
|
DBG(r300, DBG_FP, "r300: Initial fragment program\n");
|
||||||
|
|
|
@ -2866,38 +2866,23 @@ int si_shader_create(struct si_screen *sscreen, struct si_shader *shader)
|
||||||
bld_base->emit_epilogue = si_llvm_emit_vs_epilogue;
|
bld_base->emit_epilogue = si_llvm_emit_vs_epilogue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TGSI_PROCESSOR_GEOMETRY: {
|
case TGSI_PROCESSOR_GEOMETRY:
|
||||||
int i;
|
|
||||||
|
|
||||||
si_shader_ctx.radeon_bld.load_input = declare_input_gs;
|
si_shader_ctx.radeon_bld.load_input = declare_input_gs;
|
||||||
bld_base->emit_fetch_funcs[TGSI_FILE_INPUT] = fetch_input_gs;
|
bld_base->emit_fetch_funcs[TGSI_FILE_INPUT] = fetch_input_gs;
|
||||||
bld_base->emit_epilogue = si_llvm_emit_gs_epilogue;
|
bld_base->emit_epilogue = si_llvm_emit_gs_epilogue;
|
||||||
|
|
||||||
for (i = 0; i < sel->info.num_properties; i++) {
|
shader->gs_input_prim =
|
||||||
switch (sel->info.properties[i].name) {
|
sel->info.properties[TGSI_PROPERTY_GS_INPUT_PRIM][0];
|
||||||
case TGSI_PROPERTY_GS_INPUT_PRIM:
|
shader->gs_output_prim =
|
||||||
shader->gs_input_prim = sel->info.properties[i].data[0];
|
sel->info.properties[TGSI_PROPERTY_GS_OUTPUT_PRIM][0];
|
||||||
|
shader->gs_max_out_vertices =
|
||||||
|
sel->info.properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES][0];
|
||||||
break;
|
break;
|
||||||
case TGSI_PROPERTY_GS_OUTPUT_PRIM:
|
case TGSI_PROCESSOR_FRAGMENT:
|
||||||
shader->gs_output_prim = sel->info.properties[i].data[0];
|
|
||||||
break;
|
|
||||||
case TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES:
|
|
||||||
shader->gs_max_out_vertices = sel->info.properties[i].data[0];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TGSI_PROCESSOR_FRAGMENT: {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
si_shader_ctx.radeon_bld.load_input = declare_input_fs;
|
si_shader_ctx.radeon_bld.load_input = declare_input_fs;
|
||||||
bld_base->emit_epilogue = si_llvm_emit_fs_epilogue;
|
bld_base->emit_epilogue = si_llvm_emit_fs_epilogue;
|
||||||
|
|
||||||
for (i = 0; i < sel->info.num_properties; i++) {
|
switch (sel->info.properties[TGSI_PROPERTY_FS_DEPTH_LAYOUT][0]) {
|
||||||
switch (sel->info.properties[i].name) {
|
|
||||||
case TGSI_PROPERTY_FS_DEPTH_LAYOUT:
|
|
||||||
switch (sel->info.properties[i].data[0]) {
|
|
||||||
case TGSI_FS_DEPTH_LAYOUT_GREATER:
|
case TGSI_FS_DEPTH_LAYOUT_GREATER:
|
||||||
shader->db_shader_control |=
|
shader->db_shader_control |=
|
||||||
S_02880C_CONSERVATIVE_Z_EXPORT(V_02880C_EXPORT_GREATER_THAN_Z);
|
S_02880C_CONSERVATIVE_Z_EXPORT(V_02880C_EXPORT_GREATER_THAN_Z);
|
||||||
|
@ -2908,10 +2893,6 @@ int si_shader_create(struct si_screen *sscreen, struct si_shader *shader)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
assert(!"Unsupported shader type");
|
assert(!"Unsupported shader type");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue