D3D: Add geometry shader instancing support.
This commit is contained in:
parent
ca766747a8
commit
4f6ce0f236
|
@ -81,7 +81,6 @@ void InitBackendInfo()
|
||||||
g_Config.backend_info.bSupportsOversizedViewports = false;
|
g_Config.backend_info.bSupportsOversizedViewports = false;
|
||||||
g_Config.backend_info.bSupportsStereoscopy = true;
|
g_Config.backend_info.bSupportsStereoscopy = true;
|
||||||
g_Config.backend_info.bSupports3DVision = true;
|
g_Config.backend_info.bSupports3DVision = true;
|
||||||
g_Config.backend_info.bSupportsGSInstancing = false;
|
|
||||||
|
|
||||||
IDXGIFactory* factory;
|
IDXGIFactory* factory;
|
||||||
IDXGIAdapter* ad;
|
IDXGIAdapter* ad;
|
||||||
|
@ -115,11 +114,17 @@ void InitBackendInfo()
|
||||||
|
|
||||||
g_Config.backend_info.AAModes.push_back(samples);
|
g_Config.backend_info.AAModes.push_back(samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shader_model_5_supported = (DX11::D3D::GetFeatureLevel(ad) >= D3D_FEATURE_LEVEL_11_0);
|
bool shader_model_5_supported = (DX11::D3D::GetFeatureLevel(ad) >= D3D_FEATURE_LEVEL_11_0);
|
||||||
|
|
||||||
// Requires the earlydepthstencil attribute (only available in shader model 5)
|
// Requires the earlydepthstencil attribute (only available in shader model 5)
|
||||||
g_Config.backend_info.bSupportsEarlyZ = shader_model_5_supported;
|
g_Config.backend_info.bSupportsEarlyZ = shader_model_5_supported;
|
||||||
|
|
||||||
// Requires full UAV functionality (only available in shader model 5)
|
// Requires full UAV functionality (only available in shader model 5)
|
||||||
g_Config.backend_info.bSupportsBBox = shader_model_5_supported;
|
g_Config.backend_info.bSupportsBBox = shader_model_5_supported;
|
||||||
|
|
||||||
|
// Requires the instance attribute (only available in shader model 5)
|
||||||
|
g_Config.backend_info.bSupportsGSInstancing = shader_model_5_supported;
|
||||||
}
|
}
|
||||||
g_Config.backend_info.Adapters.push_back(UTF16ToUTF8(desc.Description));
|
g_Config.backend_info.Adapters.push_back(UTF16ToUTF8(desc.Description));
|
||||||
ad->Release();
|
ad->Release();
|
||||||
|
|
|
@ -64,8 +64,16 @@ static inline void GenerateGeometryShader(T& out, u32 components, API_TYPE ApiTy
|
||||||
}
|
}
|
||||||
else // D3D
|
else // D3D
|
||||||
{
|
{
|
||||||
out.Write("[maxvertexcount(6)]\n");
|
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
||||||
out.Write("void main(triangle VS_OUTPUT o[3], inout TriangleStream<GS_OUTPUT> Output)\n{\n");
|
{
|
||||||
|
out.Write("[maxvertexcount(3)]\n[instance(%d)]\n", g_ActiveConfig.iStereoMode > 0 ? 2 : 1);
|
||||||
|
out.Write("void main(triangle VS_OUTPUT o[3], inout TriangleStream<GS_OUTPUT> Output, in uint InstanceID : SV_GSInstanceID)\n{\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out.Write("[maxvertexcount(6)]\n");
|
||||||
|
out.Write("void main(triangle VS_OUTPUT o[3], inout TriangleStream<GS_OUTPUT> Output)\n{\n");
|
||||||
|
}
|
||||||
|
|
||||||
out.Write("\tGS_OUTPUT gs;\n");
|
out.Write("\tGS_OUTPUT gs;\n");
|
||||||
}
|
}
|
||||||
|
@ -75,13 +83,19 @@ static inline void GenerateGeometryShader(T& out, u32 components, API_TYPE ApiTy
|
||||||
// If the GPU supports invocation we don't need a for loop and can simply use the
|
// If the GPU supports invocation we don't need a for loop and can simply use the
|
||||||
// invocation identifier to determine which layer we're rendering.
|
// invocation identifier to determine which layer we're rendering.
|
||||||
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
||||||
out.Write("\tint l = gl_InvocationID;\n");
|
{
|
||||||
|
if (ApiType == API_OPENGL)
|
||||||
|
out.Write("\tint l = gl_InvocationID;\n");
|
||||||
|
else
|
||||||
|
out.Write("\tint l = InstanceID;\n");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
out.Write("\tfor (int l = 0; l < %d; ++l) {\n", g_ActiveConfig.iStereoMode > 0 ? 2 : 1);
|
out.Write("\tfor (int l = 0; l < %d; ++l) {\n", g_ActiveConfig.iStereoMode > 0 ? 2 : 1);
|
||||||
|
|
||||||
out.Write("\tfor (int i = 0; i < 3; ++i) {\n");
|
out.Write("\tfor (int i = 0; i < 3; ++i) {\n");
|
||||||
out.Write("\t\tgs.layer = l;\n");
|
|
||||||
|
|
||||||
|
// Select the output layer
|
||||||
|
out.Write("\t\tgs.layer = l;\n");
|
||||||
if (ApiType == API_OPENGL)
|
if (ApiType == API_OPENGL)
|
||||||
out.Write("\t\tgl_Layer = l;\n");
|
out.Write("\t\tgl_Layer = l;\n");
|
||||||
|
|
||||||
|
@ -118,7 +132,7 @@ static inline void GenerateGeometryShader(T& out, u32 components, API_TYPE ApiTy
|
||||||
if (ApiType == API_OPENGL)
|
if (ApiType == API_OPENGL)
|
||||||
out.Write("\tEndPrimitive();\n");
|
out.Write("\tEndPrimitive();\n");
|
||||||
else
|
else
|
||||||
out.Write("\t\tOutput.RestartStrip();\n");
|
out.Write("\tOutput.RestartStrip();\n");
|
||||||
|
|
||||||
if (!g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
if (!g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
||||||
out.Write("\t}\n");
|
out.Write("\t}\n");
|
||||||
|
|
Loading…
Reference in New Issue