mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Hack to hide debug cubes in Super Mario Sunshine
... while not breaking other games.
This commit is contained in:
@ -61,7 +61,8 @@ struct VertexShaderConstants
|
||||
u32 components; // .x
|
||||
u32 xfmem_dualTexInfo; // .y
|
||||
u32 xfmem_numColorChans; // .z
|
||||
u32 color_chan_alpha; // .w
|
||||
u32 missing_color_hex; // .w, used for change detection but not directly by shaders
|
||||
float4 missing_color_value;
|
||||
|
||||
std::array<float4, 6> posnormalmatrix;
|
||||
std::array<float4, 4> projection;
|
||||
|
@ -229,7 +229,8 @@ const char* GetInterpolationQualifier(bool msaa, bool ssaa, bool in_glsl_interfa
|
||||
static const char s_shader_uniforms[] = "\tuint components;\n"
|
||||
"\tuint xfmem_dualTexInfo;\n"
|
||||
"\tuint xfmem_numColorChans;\n"
|
||||
"\tuint color_chan_alpha;\n"
|
||||
"\tuint missing_color_hex;\n"
|
||||
"\tfloat4 missing_color_value;\n"
|
||||
"\tfloat4 " I_POSNORMALMATRIX "[6];\n"
|
||||
"\tfloat4 " I_PROJECTION "[4];\n"
|
||||
"\tint4 " I_MATERIALS "[4];\n"
|
||||
|
@ -189,8 +189,7 @@ ShaderCode GenVertexShader(APIType api_type, const ShaderHostConfig& host_config
|
||||
out.Write("for (uint color = 0u; color < {}u; color++) {{\n", NUM_XF_COLOR_CHANNELS);
|
||||
out.Write(" if ((color == 0u || use_color_1) && (components & ({}u << color)) != 0u) {{\n",
|
||||
VB_HAS_COL0);
|
||||
out.Write(" float4 color_value;\n"
|
||||
" // Use color0 for channel 0, and color1 for channel 1 if both colors 0 and 1 are "
|
||||
out.Write(" // Use color0 for channel 0, and color1 for channel 1 if both colors 0 and 1 are "
|
||||
"present.\n"
|
||||
" if (color == 0u)\n"
|
||||
" vertex_color_0 = rawcolor0;\n"
|
||||
@ -201,12 +200,10 @@ ShaderCode GenVertexShader(APIType api_type, const ShaderHostConfig& host_config
|
||||
out.Write(" // Use color1 for channel 0 if color0 is not present.\n"
|
||||
" vertex_color_0 = rawcolor1;\n"
|
||||
" }} else {{\n"
|
||||
" // The default alpha channel depends on the number of components in the vertex.\n"
|
||||
" float alpha = float((color_chan_alpha >> color) & 1u);\n"
|
||||
" if (color == 0u)\n"
|
||||
" vertex_color_0 = float4(1.0, 1.0, 1.0, alpha);\n"
|
||||
" vertex_color_0 = missing_color_value;\n"
|
||||
" else\n"
|
||||
" vertex_color_1 = float4(1.0, 1.0, 1.0, alpha);\n"
|
||||
" vertex_color_1 = missing_color_value;\n"
|
||||
" }}\n"
|
||||
"}}\n"
|
||||
"\n");
|
||||
|
@ -214,10 +214,7 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& ho
|
||||
}
|
||||
else
|
||||
{
|
||||
// The default alpha channel depends on the number of components in the vertex format.
|
||||
out.Write(
|
||||
"vertex_color_{0} = float4(1.0, 1.0, 1.0, float((color_chan_alpha >> {0}) & 1u));\n",
|
||||
color);
|
||||
out.Write("vertex_color_{0} = missing_color_value;\n", color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,6 +136,18 @@ void VertexShaderManager::Dirty()
|
||||
// TODO: A cleaner way to control the matrices without making a mess in the parameters field
|
||||
void VertexShaderManager::SetConstants()
|
||||
{
|
||||
if (constants.missing_color_hex != g_ActiveConfig.iMissingColorValue)
|
||||
{
|
||||
const float a = (g_ActiveConfig.iMissingColorValue) & 0xFF;
|
||||
const float b = (g_ActiveConfig.iMissingColorValue >> 8) & 0xFF;
|
||||
const float g = (g_ActiveConfig.iMissingColorValue >> 16) & 0xFF;
|
||||
const float r = (g_ActiveConfig.iMissingColorValue >> 24) & 0xFF;
|
||||
constants.missing_color_hex = g_ActiveConfig.iMissingColorValue;
|
||||
constants.missing_color_value = {r / 255, g / 255, b / 255, a / 255};
|
||||
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
if (nTransformMatricesChanged[0] >= 0)
|
||||
{
|
||||
int startn = nTransformMatricesChanged[0] / 4;
|
||||
@ -615,17 +627,6 @@ void VertexShaderManager::SetVertexFormat(u32 components)
|
||||
constants.components = components;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
// The default alpha channel seems to depend on the number of components in the vertex format.
|
||||
// If the vertex attribute has an alpha channel, zero is used, otherwise one.
|
||||
const auto g0 = g_main_cp_state.vtx_attr[g_main_cp_state.last_id].g0;
|
||||
const u32 color_chan_alpha = (g0.Color0Elements == ColorComponentCount::RGB ? 1 : 0) |
|
||||
(g0.Color1Elements == ColorComponentCount::RGB ? 2 : 0);
|
||||
if (color_chan_alpha != constants.color_chan_alpha)
|
||||
{
|
||||
constants.color_chan_alpha = color_chan_alpha;
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void VertexShaderManager::SetTexMatrixInfoChanged(int index)
|
||||
|
@ -158,6 +158,7 @@ void VideoConfig::Refresh()
|
||||
bEFBEmulateFormatChanges = Config::Get(Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES);
|
||||
bVertexRounding = Config::Get(Config::GFX_HACK_VERTEX_ROUDING);
|
||||
iEFBAccessTileSize = Config::Get(Config::GFX_HACK_EFB_ACCESS_TILE_SIZE);
|
||||
iMissingColorValue = Config::Get(Config::GFX_HACK_MISSING_COLOR_VALUE);
|
||||
|
||||
bPerfQueriesEnable = Config::Get(Config::GFX_PERF_QUERIES_ENABLE);
|
||||
|
||||
|
@ -135,6 +135,7 @@ struct VideoConfig final
|
||||
int iEFBAccessTileSize;
|
||||
int iLog; // CONF_ bits
|
||||
int iSaveTargetId; // TODO: Should be dropped
|
||||
u32 iMissingColorValue;
|
||||
|
||||
// Stereoscopy
|
||||
StereoMode stereo_mode;
|
||||
|
Reference in New Issue
Block a user