summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorYONGH\yongh <yonghe@outlook.com>2017-10-25 17:59:45 -0400
committerYONGH\yongh <yonghe@outlook.com>2017-10-25 17:59:45 -0400
commit52ceff4beee7cdc7d47eb9292a35e9f610a80bdc (patch)
tree27178492317206dc1281b2d3caa31ab60bd35002 /tools
parent922c17be4c6d33243cb4876bea9a44e3c855f4bc (diff)
add new test mode: COMPARE_RENDER_COMPUTE, which runs a input vertex/fragment shader pair, but instead of comparing the resulting framebuffer, it expects the test shader to write results into a UAV, and compares the pixel shader UAV output to the reference output.
Diffstat (limited to 'tools')
-rw-r--r--tools/render-test/main.cpp20
-rw-r--r--tools/render-test/options.cpp4
-rw-r--r--tools/render-test/options.h3
-rw-r--r--tools/render-test/render-d3d11.cpp18
-rw-r--r--tools/render-test/render-gl.cpp10
-rw-r--r--tools/render-test/render.h1
-rw-r--r--tools/render-test/shader-input-layout.cpp14
-rw-r--r--tools/render-test/shader-input-layout.h4
-rw-r--r--tools/slang-test/main.cpp7
9 files changed, 53 insertions, 28 deletions
diff --git a/tools/render-test/main.cpp b/tools/render-test/main.cpp
index d3247e55f..cb0eb927d 100644
--- a/tools/render-test/main.cpp
+++ b/tools/render-test/main.cpp
@@ -37,13 +37,14 @@ struct Vertex
{
float position[3];
float color[3];
+ float uv[2];
};
static const int kVertexCount = 3;
static const Vertex kVertexData[kVertexCount] = {
- { { 0, 0, 0.5 }, {1, 0, 0} },
- { { 0, 1, 0.5 }, {0, 0, 1} },
- { { 1, 0, 0.5 }, {0, 1, 0} },
+ { { 0, 0, 0.5 }, {1, 0, 0} , {0, 0} },
+ { { 0, 1, 0.5 }, {0, 0, 1} , {1, 0} },
+ { { 1, 0, 0.5 }, {0, 1, 0} , {1, 1} },
};
@@ -65,9 +66,9 @@ static char const* computeEntryPointName = "computeMain";
// "Profile" to use when compiling for HLSL targets
// TODO: does this belong here?
-static char const* vertexProfileName = "vs_4_0";
-static char const* fragmentProfileName = "ps_4_0";
-static char const* computeProfileName = "cs_4_0";
+static char const* vertexProfileName = "vs_5_0";
+static char const* fragmentProfileName = "ps_5_0";
+static char const* computeProfileName = "cs_5_0";
Error initializeShaders(
ShaderCompiler* shaderCompiler)
@@ -101,7 +102,7 @@ Error initializeShaders(
ShaderCompileRequest compileRequest;
compileRequest.source = sourceInfo;
- if (gOptions.shaderType == ShaderProgramType::Graphics)
+ if (gOptions.shaderType == ShaderProgramType::Graphics || gOptions.shaderType == ShaderProgramType::GraphicsCompute)
{
compileRequest.vertexShader.source = sourceInfo;
compileRequest.vertexShader.name = vertexEntryPointName;
@@ -157,9 +158,10 @@ Error initializeInner(
InputElementDesc inputElements[] = {
{ "A", 0, Format::RGB_Float32, offsetof(Vertex, position) },
{ "A", 1, Format::RGB_Float32, offsetof(Vertex, color) },
+ { "A", 2, Format::RG_Float32, offsetof(Vertex, uv) },
};
- gInputLayout = renderer->createInputLayout(&inputElements[0], 2);
+ gInputLayout = renderer->createInputLayout(&inputElements[0], sizeof(inputElements)/sizeof(inputElements[0]));
if(!gInputLayout)
return Error::Unexpected;
@@ -409,7 +411,7 @@ int main(
// If we are in a mode where output is requested, we need to snapshot the back buffer here
if (gOptions.outputPath)
{
- if (gOptions.shaderType == ShaderProgramType::Compute)
+ if (gOptions.shaderType == ShaderProgramType::Compute || gOptions.shaderType == ShaderProgramType::GraphicsCompute)
renderer->serializeOutput(gBindingState, gOptions.outputPath);
else
renderer->captureScreenShot(gOptions.outputPath);
diff --git a/tools/render-test/options.cpp b/tools/render-test/options.cpp
index 89a68b27f..629016155 100644
--- a/tools/render-test/options.cpp
+++ b/tools/render-test/options.cpp
@@ -100,6 +100,10 @@ void parseOptions(int* argc, char** argv)
{
gOptions.shaderType = ShaderProgramType::Graphics;
}
+ else if (strcmp(arg, "-gcompute") == 0)
+ {
+ gOptions.shaderType = ShaderProgramType::GraphicsCompute;
+ }
else
{
fprintf(stderr, "unknown option '%s'\n", arg);
diff --git a/tools/render-test/options.h b/tools/render-test/options.h
index a36e0a809..2c48c4ceb 100644
--- a/tools/render-test/options.h
+++ b/tools/render-test/options.h
@@ -34,7 +34,8 @@ enum
enum class ShaderProgramType
{
Graphics,
- Compute
+ Compute,
+ GraphicsCompute
};
struct Options
diff --git a/tools/render-test/render-d3d11.cpp b/tools/render-test/render-d3d11.cpp
index f90d3fbbe..cdb9f20bd 100644
--- a/tools/render-test/render-d3d11.cpp
+++ b/tools/render-test/render-d3d11.cpp
@@ -339,7 +339,7 @@ public:
hr = D3D11CreateDeviceAndSwapChain_(
NULL, // adapter (use default)
D3D_DRIVER_TYPE_WARP,
-// D3D_DRIVER_TYPE_HARDWARE,
+ //D3D_DRIVER_TYPE_HARDWARE,
NULL, // software
deviceFlags,
&featureLevels[ii],
@@ -520,7 +520,8 @@ public:
{
case Format::RGB_Float32:
return DXGI_FORMAT_R32G32B32_FLOAT;
-
+ case Format::RG_Float32:
+ return DXGI_FORMAT_R32G32_FLOAT;
default:
return DXGI_FORMAT_UNKNOWN;
}
@@ -556,7 +557,9 @@ public:
case Format::RGB_Float32:
typeName = "float3";
break;
-
+ case Format::RG_Float32:
+ typeName = "float2";
+ break;
default:
return nullptr;
}
@@ -570,7 +573,7 @@ public:
hlslCursor += sprintf(hlslCursor, "\n) : SV_Position { return 0; }");
- auto dxVertexShaderBlob = compileHLSLShader("inputLayout", hlslBuffer, "main", "vs_4_0");
+ auto dxVertexShaderBlob = compileHLSLShader("inputLayout", hlslBuffer, "main", "vs_5_0");
if(!dxVertexShaderBlob)
return nullptr;
@@ -894,6 +897,7 @@ public:
viewDesc.Texture1DArray.FirstArraySlice = 0;
viewDesc.Texture1DArray.MipLevels = texData.mipLevels;
viewDesc.Texture1DArray.MostDetailedMip = 0;
+ viewDesc.Format = desc.Format;
dxDevice->CreateShaderResourceView(texture, &viewDesc, &viewOut);
}
else if (inputDesc.dimension == 2)
@@ -934,6 +938,7 @@ public:
desc.Usage = D3D11_USAGE_DEFAULT;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
+ viewDesc.Format = desc.Format;
ID3D11Texture2D * texture;
dxDevice->CreateTexture2D(&desc, subRes.Buffer(), &texture);
dxDevice->CreateShaderResourceView(texture, &viewDesc, &viewOut);
@@ -946,7 +951,7 @@ public:
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;
- desc.MipLevels = texData.mipLevels;
+ desc.MipLevels = 1;
viewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
desc.Width = texData.textureSize;
desc.Height = texData.textureSize;
@@ -956,8 +961,9 @@ public:
dxDevice->CreateTexture3D(&desc, subRes.Buffer(), &texture);
if (inputDesc.arrayLength != 0)
viewDesc.ViewDimension = (D3D11_SRV_DIMENSION)(int)(viewDesc.ViewDimension + 1);
- viewDesc.Texture3D.MipLevels = texData.mipLevels;
+ viewDesc.Texture3D.MipLevels = 1;
viewDesc.Texture3D.MostDetailedMip = 0;
+ viewDesc.Format = desc.Format;
dxDevice->CreateShaderResourceView(texture, &viewDesc, &viewOut);
}
}
diff --git a/tools/render-test/render-gl.cpp b/tools/render-test/render-gl.cpp
index e983dad70..d19e71743 100644
--- a/tools/render-test/render-gl.cpp
+++ b/tools/render-test/render-gl.cpp
@@ -287,6 +287,7 @@ public:
case Format::NAME: do { VertexAttributeFormat result = {COUNT, TYPE, NORMALIZED}; return result; } while (0)
CASE(RGB_Float32, 3, GL_FLOAT, GL_FALSE);
+ CASE(RG_Float32, 2, GL_FLOAT, GL_FALSE);
#undef CASE
@@ -625,7 +626,7 @@ public:
{
ShaderInputType type;
GLuint handle;
- int binding;
+ List<int> binding;
int bindTarget;
int bufferSize;
bool isOutput = false;
@@ -789,14 +790,15 @@ public:
switch (entry.type)
{
case ShaderInputType::Buffer:
- glBindBufferBase(entry.bindTarget, entry.binding, entry.handle);
+ glBindBufferBase(entry.bindTarget, entry.binding[0], entry.handle);
break;
case ShaderInputType::Sampler:
- glBindSampler(entry.binding, entry.handle);
+ for (auto b : entry.binding)
+ glBindSampler(b, entry.handle);
break;
case ShaderInputType::Texture:
case ShaderInputType::CombinedTextureSampler:
- glActiveTexture(GL_TEXTURE0 + entry.binding);
+ glActiveTexture(GL_TEXTURE0 + entry.binding[0]);
glBindTexture(entry.bindTarget, entry.handle);
break;
}
diff --git a/tools/render-test/render.h b/tools/render-test/render.h
index 706868e9a..24610eb4d 100644
--- a/tools/render-test/render.h
+++ b/tools/render-test/render.h
@@ -43,6 +43,7 @@ enum class Format
{
Unknown,
RGB_Float32,
+ RG_Float32,
};
enum class BufferFlavor
diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp
index 47ba767ae..ef78fe3d5 100644
--- a/tools/render-test/shader-input-layout.cpp
+++ b/tools/render-test/shader-input-layout.cpp
@@ -171,8 +171,8 @@ namespace renderer_test
else
break;
}
+ parser.Read(")");
}
- parser.Read(")");
// parse bindings
if (parser.LookAhead(":"))
{
@@ -190,11 +190,13 @@ namespace renderer_test
{
parser.ReadToken();
parser.Read("(");
- entry.glslBinding = entry.glslLocation = parser.ReadInt();
- if (parser.LookAhead(","))
+ while (!parser.IsEnd() && !parser.LookAhead(")"))
{
- parser.Read(",");
- entry.glslLocation = parser.ReadInt();
+ entry.glslBinding.Add(parser.ReadInt());
+ if (parser.LookAhead(","))
+ parser.Read(",");
+ else
+ break;
}
parser.Read(")");
}
@@ -223,7 +225,7 @@ namespace renderer_test
int arrLen = inputDesc.arrayLength;
if (arrLen == 0)
arrLen = 1;
- List<List<unsigned int>> dataBuffer;
+ List<List<unsigned int>> & dataBuffer = output.dataBuffer;
int arraySize = arrLen;
if (inputDesc.isCube)
arraySize *= 6;
diff --git a/tools/render-test/shader-input-layout.h b/tools/render-test/shader-input-layout.h
index 9dae75270..9602e4fe8 100644
--- a/tools/render-test/shader-input-layout.h
+++ b/tools/render-test/shader-input-layout.h
@@ -46,8 +46,8 @@ namespace renderer_test
InputSamplerDesc samplerDesc;
bool isOutput = false;
int hlslBinding = -1;
- int glslBinding = -1;
- int glslLocation = -1;
+ Slang::List<int> glslBinding;
+
};
struct TextureData
diff --git a/tools/slang-test/main.cpp b/tools/slang-test/main.cpp
index cdea6b4dc..de75fa68c 100644
--- a/tools/slang-test/main.cpp
+++ b/tools/slang-test/main.cpp
@@ -1187,6 +1187,11 @@ TestResult doSlangComputeComparisonTest(TestInput& input)
return doComputeComparisonTestRunImpl(input, "-slang -compute", input.outputStem + ".expected.txt");
}
+TestResult doSlangRenderComputeComparisonTest(TestInput& input)
+{
+ return doComputeComparisonTestRunImpl(input, "-slang -gcompute", input.outputStem + ".expected.txt");
+}
+
TestResult doRenderComparisonTestRun(TestInput& input, char const* langOption, char const* outputKind, String* outOutput)
{
// TODO: delete any existing files at the output path(s) to avoid stale outputs leading to a false pass
@@ -1386,6 +1391,8 @@ TestResult runTest(
{ "COMPARE_HLSL_CROSS_COMPILE_RENDER", &runHLSLCrossCompileRenderComparisonTest},
{ "COMPARE_HLSL_GLSL_RENDER", &runHLSLAndGLSLComparisonTest },
{ "COMPARE_COMPUTE", &doSlangComputeComparisonTest},
+ { "COMPARE_RENDER_COMPUTE", &doSlangRenderComputeComparisonTest },
+
#else
{ "COMPARE_HLSL", &skipTest },
{ "COMPARE_HLSL_RENDER", &skipTest },