Multithreadded Shadergen: Minor fixups.
This commit is contained in:
parent
95469ec225
commit
ebe5fd0b36
|
@ -228,7 +228,7 @@ bool GeometryShaderCache::SetShader(u32 primitive_type)
|
|||
}
|
||||
|
||||
// Need to compile a new shader
|
||||
ShaderCode code = GenerateGeometryShaderCode(primitive_type, API_D3D, uid.GetUidData());
|
||||
ShaderCode code = GenerateGeometryShaderCode(API_D3D, uid.GetUidData());
|
||||
|
||||
D3DBlob* pbytecode;
|
||||
if (!D3D::CompileGeometryShader(code.GetBuffer(), &pbytecode))
|
||||
|
|
|
@ -222,8 +222,7 @@ void ShaderCache::HandleGSUIDChange(GeometryShaderUid gs_uid, u32 gs_primitive_t
|
|||
}
|
||||
else
|
||||
{
|
||||
ShaderCode gs_code =
|
||||
GenerateGeometryShaderCode(gs_primitive_type, API_D3D, gs_uid.GetUidData());
|
||||
ShaderCode gs_code = GenerateGeometryShaderCode(API_D3D, gs_uid.GetUidData());
|
||||
ID3DBlob* gs_bytecode = nullptr;
|
||||
|
||||
if (!D3D::CompileGeometryShader(gs_code.GetBuffer(), &gs_bytecode))
|
||||
|
|
|
@ -59,7 +59,7 @@ bool ShaderCache<Uid>::SetShader(DSTALPHA_MODE dst_alpha_mode, u32 primitive_typ
|
|||
}
|
||||
|
||||
// Need to compile a new shader
|
||||
ShaderCode code = GenerateCode(dst_alpha_mode, primitive_type, API_OPENGL, uid);
|
||||
ShaderCode code = GenerateCode(dst_alpha_mode, API_OPENGL, uid);
|
||||
m_shaders.emplace(uid, code.GetBuffer());
|
||||
|
||||
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true);
|
||||
|
|
|
@ -26,8 +26,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual Uid GetUid(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type, API_TYPE api_type) = 0;
|
||||
virtual ShaderCode GenerateCode(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type,
|
||||
API_TYPE api_type, Uid uid) = 0;
|
||||
virtual ShaderCode GenerateCode(DSTALPHA_MODE dst_alpha_mode, API_TYPE api_type, Uid uid) = 0;
|
||||
|
||||
private:
|
||||
std::map<Uid, std::string> m_shaders;
|
||||
|
@ -46,7 +45,7 @@ protected:
|
|||
{
|
||||
return GetVertexShaderUid();
|
||||
}
|
||||
ShaderCode GenerateCode(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type, API_TYPE api_type,
|
||||
ShaderCode GenerateCode(DSTALPHA_MODE dst_alpha_mode, API_TYPE api_type,
|
||||
VertexShaderUid uid) override
|
||||
{
|
||||
return GenerateVertexShaderCode(api_type, uid.GetUidData());
|
||||
|
@ -64,10 +63,10 @@ protected:
|
|||
{
|
||||
return GetGeometryShaderUid(primitive_type);
|
||||
}
|
||||
ShaderCode GenerateCode(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type, API_TYPE api_type,
|
||||
ShaderCode GenerateCode(DSTALPHA_MODE dst_alpha_mode, API_TYPE api_type,
|
||||
GeometryShaderUid uid) override
|
||||
{
|
||||
return GenerateGeometryShaderCode(primitive_type, api_type, uid.GetUidData());
|
||||
return GenerateGeometryShaderCode(api_type, uid.GetUidData());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -82,7 +81,7 @@ protected:
|
|||
{
|
||||
return GetPixelShaderUid(dst_alpha_mode);
|
||||
}
|
||||
ShaderCode GenerateCode(DSTALPHA_MODE dst_alpha_mode, u32 primitive_type, API_TYPE api_type,
|
||||
ShaderCode GenerateCode(DSTALPHA_MODE dst_alpha_mode, API_TYPE api_type,
|
||||
PixelShaderUid uid) override
|
||||
{
|
||||
return GeneratePixelShaderCode(dst_alpha_mode, api_type, uid.GetUidData());
|
||||
|
|
|
@ -211,7 +211,7 @@ SHADER* ProgramShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 primitive_
|
|||
ShaderCode gcode;
|
||||
if (g_ActiveConfig.backend_info.bSupportsGeometryShaders &&
|
||||
!uid.guid.GetUidData()->IsPassthrough())
|
||||
gcode = GenerateGeometryShaderCode(primitive_type, API_OPENGL, uid.guid.GetUidData());
|
||||
gcode = GenerateGeometryShaderCode(API_OPENGL, uid.guid.GetUidData());
|
||||
|
||||
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||
{
|
||||
|
|
|
@ -42,14 +42,13 @@ static void EmitVertex(ShaderCode& out, const geometry_shader_uid_data* uid_data
|
|||
static void EndPrimitive(ShaderCode& out, const geometry_shader_uid_data* uid_data,
|
||||
API_TYPE ApiType);
|
||||
|
||||
ShaderCode GenerateGeometryShaderCode(u32 primitive_type, API_TYPE ApiType,
|
||||
const geometry_shader_uid_data* uid_data)
|
||||
ShaderCode GenerateGeometryShaderCode(API_TYPE ApiType, const geometry_shader_uid_data* uid_data)
|
||||
{
|
||||
ShaderCode out;
|
||||
// Non-uid template parameters will write to the dummy data (=> gets optimized out)
|
||||
|
||||
const unsigned int vertex_in = primitive_type + 1;
|
||||
unsigned int vertex_out = primitive_type == PRIMITIVE_TRIANGLES ? 3 : 4;
|
||||
const unsigned int vertex_in = uid_data->primitive_type + 1;
|
||||
unsigned int vertex_out = uid_data->primitive_type == PRIMITIVE_TRIANGLES ? 3 : 4;
|
||||
|
||||
if (uid_data->wireframe)
|
||||
vertex_out++;
|
||||
|
@ -59,14 +58,14 @@ ShaderCode GenerateGeometryShaderCode(u32 primitive_type, API_TYPE ApiType,
|
|||
// Insert layout parameters
|
||||
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
||||
{
|
||||
out.Write("layout(%s, invocations = %d) in;\n", primitives_ogl[primitive_type],
|
||||
out.Write("layout(%s, invocations = %d) in;\n", primitives_ogl[uid_data->primitive_type],
|
||||
uid_data->stereo ? 2 : 1);
|
||||
out.Write("layout(%s_strip, max_vertices = %d) out;\n",
|
||||
uid_data->wireframe ? "line" : "triangle", vertex_out);
|
||||
}
|
||||
else
|
||||
{
|
||||
out.Write("layout(%s) in;\n", primitives_ogl[primitive_type]);
|
||||
out.Write("layout(%s) in;\n", primitives_ogl[uid_data->primitive_type]);
|
||||
out.Write("layout(%s_strip, max_vertices = %d) out;\n",
|
||||
uid_data->wireframe ? "line" : "triangle",
|
||||
uid_data->stereo ? vertex_out * 2 : vertex_out);
|
||||
|
@ -130,21 +129,21 @@ ShaderCode GenerateGeometryShaderCode(u32 primitive_type, API_TYPE ApiType,
|
|||
out.Write("[maxvertexcount(%d)]\n[instance(%d)]\n", vertex_out, uid_data->stereo ? 2 : 1);
|
||||
out.Write("void main(%s VS_OUTPUT o[%d], inout %sStream<VertexData> output, in uint "
|
||||
"InstanceID : SV_GSInstanceID)\n{\n",
|
||||
primitives_d3d[primitive_type], vertex_in,
|
||||
primitives_d3d[uid_data->primitive_type], vertex_in,
|
||||
uid_data->wireframe ? "Line" : "Triangle");
|
||||
}
|
||||
else
|
||||
{
|
||||
out.Write("[maxvertexcount(%d)]\n", uid_data->stereo ? vertex_out * 2 : vertex_out);
|
||||
out.Write("void main(%s VS_OUTPUT o[%d], inout %sStream<VertexData> output)\n{\n",
|
||||
primitives_d3d[primitive_type], vertex_in,
|
||||
primitives_d3d[uid_data->primitive_type], vertex_in,
|
||||
uid_data->wireframe ? "Line" : "Triangle");
|
||||
}
|
||||
|
||||
out.Write("\tVertexData ps;\n");
|
||||
}
|
||||
|
||||
if (primitive_type == PRIMITIVE_LINES)
|
||||
if (uid_data->primitive_type == PRIMITIVE_LINES)
|
||||
{
|
||||
if (ApiType == API_OPENGL)
|
||||
{
|
||||
|
@ -175,7 +174,7 @@ ShaderCode GenerateGeometryShaderCode(u32 primitive_type, API_TYPE ApiType,
|
|||
"\t\toffset = float2(0, -" I_LINEPTPARAMS ".z / " I_LINEPTPARAMS ".y);\n"
|
||||
"\t}\n");
|
||||
}
|
||||
else if (primitive_type == PRIMITIVE_POINTS)
|
||||
else if (uid_data->primitive_type == PRIMITIVE_POINTS)
|
||||
{
|
||||
if (ApiType == API_OPENGL)
|
||||
{
|
||||
|
@ -235,7 +234,7 @@ ShaderCode GenerateGeometryShaderCode(u32 primitive_type, API_TYPE ApiType,
|
|||
out.Write("\tf.pos.x += " I_STEREOPARAMS "[eye] * (f.pos.w - " I_STEREOPARAMS "[2]);\n");
|
||||
}
|
||||
|
||||
if (primitive_type == PRIMITIVE_LINES)
|
||||
if (uid_data->primitive_type == PRIMITIVE_LINES)
|
||||
{
|
||||
out.Write("\tVS_OUTPUT l = f;\n"
|
||||
"\tVS_OUTPUT r = f;\n");
|
||||
|
@ -256,7 +255,7 @@ ShaderCode GenerateGeometryShaderCode(u32 primitive_type, API_TYPE ApiType,
|
|||
EmitVertex(out, uid_data, "l", ApiType, true);
|
||||
EmitVertex(out, uid_data, "r", ApiType);
|
||||
}
|
||||
else if (primitive_type == PRIMITIVE_POINTS)
|
||||
else if (uid_data->primitive_type == PRIMITIVE_POINTS)
|
||||
{
|
||||
out.Write("\tVS_OUTPUT ll = f;\n"
|
||||
"\tVS_OUTPUT lr = f;\n"
|
||||
|
|
|
@ -31,6 +31,5 @@ struct geometry_shader_uid_data
|
|||
|
||||
typedef ShaderUid<geometry_shader_uid_data> GeometryShaderUid;
|
||||
|
||||
ShaderCode GenerateGeometryShaderCode(u32 primitive_type, API_TYPE ApiType,
|
||||
const geometry_shader_uid_data* uid_data);
|
||||
ShaderCode GenerateGeometryShaderCode(API_TYPE ApiType, const geometry_shader_uid_data* uid_data);
|
||||
GeometryShaderUid GetGeometryShaderUid(u32 primitive_type);
|
||||
|
|
|
@ -63,7 +63,7 @@ struct pixel_shader_uid_data
|
|||
u32 tevindref_bi4 : 3;
|
||||
u32 tevindref_bc4 : 3;
|
||||
|
||||
inline void SetTevindrefValues(int index, u32 texcoord, u32 texmap)
|
||||
void SetTevindrefValues(int index, u32 texcoord, u32 texmap)
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ struct pixel_shader_uid_data
|
|||
}
|
||||
}
|
||||
|
||||
inline u32 GetTevindirefCoord(int index) const
|
||||
u32 GetTevindirefCoord(int index) const
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ struct pixel_shader_uid_data
|
|||
return 0;
|
||||
}
|
||||
|
||||
inline u32 GetTevindirefMap(int index) const
|
||||
u32 GetTevindirefMap(int index) const
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
|
|
|
@ -39,9 +39,9 @@ struct vertex_shader_uid_data
|
|||
u32 pixel_lighting : 1;
|
||||
u32 msaa : 1;
|
||||
|
||||
u32 ssaa : 1;
|
||||
u32 texMtxInfo_n_projection : 16; // Stored separately to guarantee that the texMtxInfo struct is
|
||||
// 8 bits wide
|
||||
u32 ssaa : 1;
|
||||
u32 pad : 15;
|
||||
|
||||
struct
|
||||
|
|
Loading…
Reference in New Issue