(WIIU) shaders: use bitfields for GPU register values.

This commit is contained in:
aliaspider 2017-12-30 16:39:23 +01:00
parent ec4b0f9089
commit f6fdd421c6
2 changed files with 248 additions and 69 deletions

View File

@ -71,18 +71,91 @@ typedef struct GX2VertexShader
{
struct
{
uint32_t sq_pgm_resources_vs;
uint32_t vgt_primitiveid_en;
uint32_t spi_vs_out_config;
struct
{
unsigned :2;
bool prime_cache_on_const :1;
bool prime_cache_enable :1;
bool uncached_first_inst :1;
unsigned fetch_cache_lines :3;
bool prime_cache_on_draw :1;
bool prime_cache_pgm_en :1;
bool dx10_clamp :1;
unsigned :5;
unsigned stack_size :8;
unsigned num_gprs :8;
}sq_pgm_resources_vs;
bool vgt_primitiveid_en;
struct
{
unsigned :18;
unsigned vs_out_fog_vec_addr : 5;
bool vs_exports_fog : 1;
unsigned :2;
unsigned vs_export_count :5;
bool vs_per_component : 1;
}spi_vs_out_config;
uint32_t num_spi_vs_out_id;
uint32_t spi_vs_out_id[10];
uint32_t pa_cl_vs_out_cntl;
struct
{
uint8_t semantic_3;
uint8_t semantic_2;
uint8_t semantic_1;
uint8_t semantic_0;
}spi_vs_out_id[10];
struct
{
bool clip_dist_ena_7 :1;
bool clip_dist_ena_6 :1;
bool clip_dist_ena_5 :1;
bool clip_dist_ena_4 :1;
bool clip_dist_ena_3 :1;
bool clip_dist_ena_2 :1;
bool clip_dist_ena_1 :1;
bool clip_dist_ena_0 :1;
bool cull_dist_ena_7 :1;
bool cull_dist_ena_6 :1;
bool cull_dist_ena_5 :1;
bool cull_dist_ena_0 :1;
bool cull_dist_ena_4 :1;
bool cull_dist_ena_3 :1;
bool cull_dist_ena_2 :1;
bool cull_dist_ena_1 :1;
bool vs_out_misc_side_bus_ena :1;
bool vs_out_ccdist1_vec_ena :1;
bool vs_out_ccdist0_vec_ena :1;
bool vs_out_misc_vec_ena :1;
bool use_vtx_kill_flag :1;
bool use_vtx_viewport_indx :1;
bool use_vtx_render_target_indx :1;
bool use_vtx_edge_flag :1;
unsigned :6;
bool use_vtx_point_size :1;
bool use_vtx_gs_cut_flag :1;
}pa_cl_vs_out_cntl;
uint32_t sq_vtx_semantic_clear;
uint32_t num_sq_vtx_semantic;
uint32_t sq_vtx_semantic[32];
uint32_t vgt_strmout_buffer_en;
uint32_t vgt_vertex_reuse_block_cntl;
uint32_t vgt_hos_reuse_depth;
uint32_t sq_vtx_semantic[32]; /* 8 bit */
struct
{
bool buffer_3_en :1;
bool buffer_2_en :1;
bool buffer_1_en :1;
bool buffer_0_en :1;
}vgt_strmout_buffer_en;
struct
{
unsigned :24;
uint8_t vtx_reuse_depth;
}vgt_vertex_reuse_block_cntl;
struct
{
unsigned :24;
uint8_t reuse_depth;
}vgt_hos_reuse_depth;
} regs;
uint32_t size;
@ -115,20 +188,129 @@ typedef struct GX2VertexShader
GX2RBuffer gx2rBuffer;
} GX2VertexShader;
typedef enum {
spi_baryc_cntl_centroids_only = 0,
spi_baryc_cntl_centers_only = 1,
spi_baryc_cntl_centroids_and_centers = 2,
}spi_baryc_cntl;
typedef enum {
db_z_order_late_z = 0,
db_z_order_early_z_then_late_z = 1,
db_z_order_re_z = 2,
db_z_order_early_z_then_re_z = 3,
}db_z_order;
typedef struct GX2PixelShader
{
struct
{
uint32_t sq_pgm_resources_ps;
uint32_t sq_pgm_exports_ps;
uint32_t spi_ps_in_control_0;
uint32_t spi_ps_in_control_1;
struct
{
unsigned :2;
bool prime_cache_on_const :1;
bool prime_cache_enable :1;
bool uncached_first_inst :1;
unsigned fetch_cache_lines :3;
bool prime_cache_on_draw :1;
bool prime_cache_pgm_en :1;
bool dx10_clamp :1;
unsigned :5;
unsigned stack_size :8;
unsigned num_gprs :8;
}sq_pgm_resources_ps;
struct
{
unsigned :24;
unsigned export_mode :5;
}sq_pgm_exports_ps;
struct
{
bool baryc_at_sample_ena :1;
bool position_sample :1;
bool linear_gradient_ena :1;
bool persp_gradient_ena :1;
spi_baryc_cntl baryc_sample_cntl :2;
unsigned param_gen_addr : 7;
unsigned param_gen :4;
unsigned position_addr :5;
bool position_centroid :1;
bool position_ena :1;
unsigned :2;
unsigned num_interp :6;
}spi_ps_in_control_0;
struct
{
unsigned :1;
bool position_ulc :1;
unsigned fixed_pt_position_addr :5;
bool fixed_pt_position_ena :1;
unsigned fog_addr :7;
unsigned front_face_addr :5;
bool front_face_all_bits :1;
unsigned front_face_chan :2;
bool front_face_ena :1;
unsigned gen_index_pix_addr :7;
bool gen_index_pix :1;
}spi_ps_in_control_1;
uint32_t num_spi_ps_input_cntl;
uint32_t spi_ps_input_cntls[32];
uint32_t cb_shader_mask;
uint32_t cb_shader_control;
uint32_t db_shader_control;
uint32_t spi_input_z;
struct
{
unsigned :13;
bool sel_sample :1;
bool pt_sprite_tex :1;
unsigned cyl_wrap :4;
bool sel_linear :1;
bool sel_centroid :1;
bool flat_shade :1;
unsigned default_val :2;
unsigned semantic :8;
}spi_ps_input_cntls[32];
struct
{
unsigned output7_enable :4;
unsigned output6_enable :4;
unsigned output5_enable :4;
unsigned output4_enable :4;
unsigned output3_enable :4;
unsigned output2_enable :4;
unsigned output1_enable :4;
unsigned output0_enable :4;
}cb_shader_mask;
struct {
unsigned :24;
bool rt7_enable :1;
bool rt6_enable :1;
bool rt5_enable :1;
bool rt4_enable :1;
bool rt3_enable :1;
bool rt2_enable :1;
bool rt1_enable :1;
bool rt0_enable :1;
}cb_shader_control;
struct
{
unsigned :19;
bool alpha_to_mask_disable :1;
bool exec_on_noop :1;
bool exec_on_hier_fail :1;
bool dual_export_enable :1;
bool mask_export_enable :1;
bool coverage_to_mask_enable :1;
bool kill_enable :1;
db_z_order z_order :2;
unsigned :2;
bool z_export_enable :1;
bool stencil_ref_export_enable :1;
} db_shader_control;
bool spi_input_z;
} regs;
uint32_t size;

View File

@ -133,67 +133,64 @@ tex_shader_t tex_shader =
{
{
{
0x00000103, 0x00000000, 0x00000000, 0x00000001, /* sq_pgm_resources_vs, vgt_primitiveid_en, spi_vs_out_config, num_spi_vs_out_id */
{ 0xffffff00, _x9(0xffffffff) }, /* spi_vs_out_id @10 */
0x00000000, 0xfffffffc, 0x00000002, /* pa_cl_vs_out_cntl, sq_vtx_semantic_clear, num_sq_vtx_semantic */
.sq_pgm_resources_vs.num_gprs = 3,
.sq_pgm_resources_vs.stack_size = 1,
.num_spi_vs_out_id = 1,
{
0x00000000, 0x00000001, _x30(0x000000ff) /* sq_vtx_semantic @32 */
{.semantic_0 = 0x00, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
},
0x00000000, 0x0000000e, 0x00000010 /* vgt_strmout_buffer_en, vgt_vertex_reuse_block_cntl, vgt_hos_reuse_depth */
}, /* regs */
sizeof(vs_program), /* size */
(uint8_t*)&vs_program, /* program */
GX2_SHADER_MODE_UNIFORM_REGISTER, /* mode */
0, /* uniformBlockCount */
NULL, /* uniformBlocks */
0, /* uniformVarCount */
NULL, /* uniformVars */
0, /* initialValueCount */
NULL, /* initialValues */
0, /* loopVarCount */
NULL, /* loopVars */
0, /* samplerVarCount */
NULL, /* samplerVars */
sizeof(tex_shader.attributes) / sizeof(GX2AttribVar), /* attribVarCount */
(GX2AttribVar*) &tex_shader.attributes, /* attribVars */
0, /* ringItemsize */
FALSE, /* hasStreamOut */
{0}, /* streamOutStride @4 */
{} /* gx2rBuffer */
.sq_vtx_semantic_clear = ~0x3,
.num_sq_vtx_semantic = 2,
{
0, 1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
},
.vgt_vertex_reuse_block_cntl.vtx_reuse_depth = 0xE,
.vgt_hos_reuse_depth.reuse_depth = 0x10,
}, /* regs */
.size = sizeof(vs_program),
.program = (uint8_t*)&vs_program,
.mode = GX2_SHADER_MODE_UNIFORM_REGISTER,
.attribVarCount = sizeof(tex_shader.attributes) / sizeof(GX2AttribVar), (GX2AttribVar*) &tex_shader.attributes,
},
{
{
0x00000001, 0x00000002, 0x14000001, 0x00000000, /* sq_pgm_resources_ps, sq_pgm_exports_ps, spi_ps_in_control_0, spi_ps_in_control_1 */
0x00000001, /* num_spi_ps_input_cntl */
{ 0x00000100, _x30(0x00000000)}, /* spi_ps_input_cntls @ 32*/
0x0000000f, 0x00000001, 0x00000010, 0x00000000 /* cb_shader_mask, cb_shader_control, db_shader_control, spi_input_z */
}, /* regs */
sizeof(ps_program), /* size */
(uint8_t*)&ps_program, /* program */
GX2_SHADER_MODE_UNIFORM_REGISTER, /* mode */
0, /* uniformBlockCount */
NULL, /* uniformBlocks */
0, /* uniformVarCount */
NULL, /* uniformVars */
0, /* initialValueCount */
NULL, /* initialValues */
0, /* loopVarCount */
NULL, /* loopVars */
1, /* samplerVarCount */
(GX2SamplerVar*) &tex_shader.sampler, /* samplerVars */
{} /* gx2rBuffer */
.sq_pgm_resources_ps.num_gprs = 1,
.sq_pgm_exports_ps.export_mode = 0x2,
.spi_ps_in_control_0.num_interp = 1,
.spi_ps_in_control_0.persp_gradient_ena = 1,
.spi_ps_in_control_0.baryc_sample_cntl = spi_baryc_cntl_centers_only,
.num_spi_ps_input_cntl = 1, {{.default_val = 1},},
.cb_shader_mask.output0_enable = 0xF,
.cb_shader_control.rt0_enable = TRUE,
.db_shader_control.z_order = db_z_order_early_z_then_late_z,
}, /* regs */
.size = sizeof(ps_program),
.program = (uint8_t*)&ps_program,
.mode = GX2_SHADER_MODE_UNIFORM_REGISTER,
.samplerVarCount = 1,
.samplerVars = (GX2SamplerVar*) &tex_shader.sampler,
},
{ "s", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, 0 },
{
{ "position", GX2_SHADER_VAR_TYPE_FLOAT2, 0, 0},
{ "tex_coord_in", GX2_SHADER_VAR_TYPE_FLOAT2, 0, 1}
.sampler = { "s", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, 0 },
.attributes = {
.position = { "position", GX2_SHADER_VAR_TYPE_FLOAT2, 0, 0},
.tex_coord = { "tex_coord_in", GX2_SHADER_VAR_TYPE_FLOAT2, 0, 1}
},
{
{
.attribute_stream = {
.position = {
0, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32,
GX2_ATTRIB_INDEX_PER_VERTEX, 0, GX2_COMP_SEL(_X, _Y, _0, _1), GX2_ENDIAN_SWAP_DEFAULT
},
{
.tex_coord = {
1, 1, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32,
GX2_ATTRIB_INDEX_PER_VERTEX, 0, GX2_COMP_SEL(_X, _Y, _0, _1), GX2_ENDIAN_SWAP_DEFAULT
}