New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VideoCommon: Better shader names #10752
VideoCommon: Better shader names #10752
Conversation
TellowKrinkle
commented
Jun 14, 2022
- Adds names to ubershaders
- Removes palette from names of texture decoding shaders that don't require a palette
- Also prevents separate versions from being made for each palette type, since they don't use palettes
0c5a0fd
to
ecb7945
Compare
|
About the ubershader naming, I think the change is great ( @Pokechu22 and I talked about this a while back ) but it'd be nice to do the same for the specialized shaders too. Feels like that could be its own PR. Then a separate PR for this palette work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For more context on that, see #10269.
Doing ubershaders seems a lot easier than doing the specialized shaders, though. Here's the current UIDs for the ubershaders:
dolphin/Source/Core/VideoCommon/UberShaderVertex.h
Lines 12 to 17 in 431d757
| struct vertex_ubershader_uid_data | |
| { | |
| u32 num_texgens : 4; | |
| u32 NumValues() const { return sizeof(vertex_ubershader_uid_data); } | |
| }; |
dolphin/Source/Core/VideoCommon/UberShaderPixel.h
Lines 15 to 23 in 431d757
| struct pixel_ubershader_uid_data | |
| { | |
| u32 num_texgens : 4; | |
| u32 early_depth : 1; | |
| u32 per_pixel_depth : 1; | |
| u32 uint_output : 1; | |
| u32 NumValues() const { return sizeof(pixel_ubershader_uid_data); } | |
| }; |
... and here's the specialized ones:
dolphin/Source/Core/VideoCommon/VertexShaderGen.h
Lines 38 to 67 in 431d757
| struct vertex_shader_uid_data | |
| { | |
| u32 NumValues() const { return sizeof(vertex_shader_uid_data); } | |
| u32 components : 23; | |
| u32 numTexGens : 4; | |
| u32 numColorChans : 2; | |
| u32 dualTexTrans_enabled : 1; | |
| u32 texMtxInfo_n_projection : 16; // Stored separately to guarantee that the texMtxInfo struct is | |
| // 8 bits wide | |
| u32 pad : 18; | |
| struct | |
| { | |
| TexInputForm inputform : 2; | |
| TexGenType texgentype : 3; | |
| SourceRow sourcerow : 5; | |
| u32 embosssourceshift : 3; | |
| u32 embosslightshift : 3; | |
| } texMtxInfo[8]; | |
| struct | |
| { | |
| u32 index : 6; | |
| u32 normalize : 1; | |
| u32 pad : 1; | |
| } postMtxInfo[8]; | |
| LightingUidData lighting; | |
| }; |
dolphin/Source/Core/VideoCommon/PixelShaderGen.h
Lines 23 to 155 in 431d757
| struct pixel_shader_uid_data | |
| { | |
| // TODO: Optimize field order for easy access! | |
| u32 num_values; // TODO: Shouldn't be a u32 | |
| u32 NumValues() const { return num_values; } | |
| u32 pad0 : 4; | |
| u32 useDstAlpha : 1; | |
| AlphaTestResult Pretest : 2; | |
| u32 nIndirectStagesUsed : 4; | |
| u32 genMode_numtexgens : 4; | |
| u32 genMode_numtevstages : 4; | |
| u32 genMode_numindstages : 3; | |
| CompareMode alpha_test_comp0 : 3; | |
| CompareMode alpha_test_comp1 : 3; | |
| AlphaTestOp alpha_test_logic : 2; | |
| u32 alpha_test_use_zcomploc_hack : 1; | |
| FogProjection fog_proj : 1; | |
| FogType fog_fsel : 3; | |
| u32 fog_RangeBaseEnabled : 1; | |
| ZTexOp ztex_op : 2; | |
| u32 per_pixel_depth : 1; | |
| u32 forced_early_z : 1; | |
| u32 early_ztest : 1; | |
| u32 late_ztest : 1; | |
| u32 bounding_box : 1; | |
| u32 zfreeze : 1; | |
| u32 numColorChans : 2; | |
| u32 rgba6_format : 1; | |
| u32 dither : 1; | |
| u32 uint_output : 1; | |
| u32 blend_enable : 1; // Only used with shader_framebuffer_fetch blend | |
| SrcBlendFactor blend_src_factor : 3; // Only used with shader_framebuffer_fetch blend | |
| SrcBlendFactor blend_src_factor_alpha : 3; // Only used with shader_framebuffer_fetch blend | |
| DstBlendFactor blend_dst_factor : 3; // Only used with shader_framebuffer_fetch blend | |
| DstBlendFactor blend_dst_factor_alpha : 3; // Only used with shader_framebuffer_fetch blend | |
| u32 blend_subtract : 1; // Only used with shader_framebuffer_fetch blend | |
| u32 blend_subtract_alpha : 1; // Only used with shader_framebuffer_fetch blend | |
| u32 logic_op_enable : 1; // Only used with shader_framebuffer_fetch logic ops | |
| u32 logic_op_mode : 4; // Only used with shader_framebuffer_fetch logic ops | |
| u32 texMtxInfo_n_projection : 8; // 8x1 bit | |
| u32 tevindref_bi0 : 3; | |
| u32 tevindref_bc0 : 3; | |
| u32 tevindref_bi1 : 3; | |
| u32 tevindref_bc1 : 3; | |
| u32 tevindref_bi2 : 3; | |
| u32 tevindref_bc2 : 3; | |
| u32 tevindref_bi3 : 3; | |
| u32 tevindref_bc3 : 3; | |
| void SetTevindrefValues(int index, u32 texcoord, u32 texmap) | |
| { | |
| if (index == 0) | |
| { | |
| tevindref_bc0 = texcoord; | |
| tevindref_bi0 = texmap; | |
| } | |
| else if (index == 1) | |
| { | |
| tevindref_bc1 = texcoord; | |
| tevindref_bi1 = texmap; | |
| } | |
| else if (index == 2) | |
| { | |
| tevindref_bc2 = texcoord; | |
| tevindref_bi2 = texmap; | |
| } | |
| else if (index == 3) | |
| { | |
| tevindref_bc3 = texcoord; | |
| tevindref_bi3 = texmap; | |
| } | |
| } | |
| u32 GetTevindirefCoord(int index) const | |
| { | |
| if (index == 0) | |
| return tevindref_bc0; | |
| else if (index == 1) | |
| return tevindref_bc1; | |
| else if (index == 2) | |
| return tevindref_bc2; | |
| else if (index == 3) | |
| return tevindref_bc3; | |
| return 0; | |
| } | |
| u32 GetTevindirefMap(int index) const | |
| { | |
| if (index == 0) | |
| return tevindref_bi0; | |
| else if (index == 1) | |
| return tevindref_bi1; | |
| else if (index == 2) | |
| return tevindref_bi2; | |
| else if (index == 3) | |
| return tevindref_bi3; | |
| return 0; | |
| } | |
| struct | |
| { | |
| // TODO: Can save a lot space by removing the padding bits | |
| u32 cc : 24; | |
| u32 ac : 24; // tswap and rswap are left blank (encoded into the tevksel fields below) | |
| u32 tevorders_texmap : 3; | |
| u32 tevorders_texcoord : 3; | |
| u32 tevorders_enable : 1; | |
| RasColorChan tevorders_colorchan : 3; | |
| u32 pad1 : 7; | |
| // TODO: Clean up the swapXY mess | |
| u32 tevind : 21; | |
| u32 tevksel_swap1a : 2; | |
| u32 tevksel_swap2a : 2; | |
| u32 tevksel_swap1b : 2; | |
| u32 tevksel_swap2b : 2; | |
| u32 pad2 : 2; | |
| u32 tevksel_swap1c : 2; | |
| u32 tevksel_swap2c : 2; | |
| u32 tevksel_swap1d : 2; | |
| u32 tevksel_swap2d : 2; | |
| KonstSel tevksel_kc : 5; | |
| KonstSel tevksel_ka : 5; | |
| u32 pad3 : 14; | |
| } stagehash[16]; | |
| LightingUidData lighting; | |
| }; |
I think it's fairly obvious that giving names for ubershaders is a lot easier than giving names for specialized shaders.
| @@ -950,6 +950,7 @@ uint GetTiledTexelOffset(uint2 block_size, uint2 coords) | |||
| return buffer_pos; | |||
| } | |||
|
|
|||
| #if defined(HAS_PALETTE) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems a bit odd to use defines here, but conditionally write/don't write stuff in the shader source elsewhere. (This isn't new; #if defined(PALETTE_FORMAT_IA8) and similar were already in use a few lines below. I just find it a bit odd).
|
@Pokechu22 - true, however, it would be nice to at least have the names (and maybe number of texgens for consistency). We can worry about details later. |
07b5545
to
3e5124e
Compare
3e5124e
to
c7892d7
Compare
98329bc
to
f79ac76
Compare