summaryrefslogtreecommitdiffstats
path: root/tools/render-test/render-d3d11.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-06-12 10:48:36 -0700
committerTim Foley <tfoley@nvidia.com>2017-06-12 12:12:20 -0700
commit5fe2cf3279c279750d4821a9fa97bdbbe876e568 (patch)
treeb929d3d7f77da2ba538846f598e7eeb0a302b0cc /tools/render-test/render-d3d11.cpp
parent4d63b6fe73018ae253bbef0075478f5989ad279a (diff)
GLSL: get GLSL limping in `render-test`
The test case that is there right now is nominally a cross-compilation test, but for right now it uses the preprocessor to present completely different code for HLSL and GLSL compilation. This change is really just fleshing out the OpenGL side of `render-test` enough that it can produce images using OpenGL to enable further testing.
Diffstat (limited to 'tools/render-test/render-d3d11.cpp')
-rw-r--r--tools/render-test/render-d3d11.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/tools/render-test/render-d3d11.cpp b/tools/render-test/render-d3d11.cpp
index ab981bd45..4f1071905 100644
--- a/tools/render-test/render-d3d11.cpp
+++ b/tools/render-test/render-d3d11.cpp
@@ -362,6 +362,13 @@ ID3DBlob* compileHLSLShader(
flags |= D3DCOMPILE_DEBUG;
flags |= D3DCOMPILE_OPTIMIZATION_LEVEL0 | D3DCOMPILE_SKIP_OPTIMIZATION;
+ // We will always define `__HLSL__` when compiling here, so that
+ // input code can react differently to being compiled as pure HLSL.
+ D3D_SHADER_MACRO defines[] = {
+ { "__HLSL__", "1" },
+ { nullptr, nullptr },
+ };
+
// The `D3DCompile` entry point takes a bunch of parameters, but we
// don't really need most of them for Slang-generated code.
ID3DBlob* dxShaderBlob = nullptr;
@@ -370,7 +377,7 @@ ID3DBlob* compileHLSLShader(
source,
strlen(source),
sourcePath,
- nullptr,
+ &defines[0],
nullptr,
entryPointName,
dxProfileName,
@@ -383,8 +390,14 @@ ID3DBlob* compileHLSLShader(
// then we will print them out (whether or not the compilation failed).
if( dxErrorBlob )
{
+ fputs(
+ (char const*)dxErrorBlob->GetBufferPointer(),
+ stderr);
+ fflush(stderr);
+
OutputDebugStringA(
(char const*)dxErrorBlob->GetBufferPointer());
+
dxErrorBlob->Release();
}
@@ -523,7 +536,13 @@ public:
DXGI_SWAP_CHAIN_DESC dxSwapChainDesc = { 0 };
dxSwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
- dxSwapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
+
+ // Note(tfoley): Disabling sRGB for DX back buffer for now, so that we
+ // can get consistent output with OpenGL, where setting up sRGB will
+ // probably be more involved.
+// dxSwapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
+ dxSwapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+
dxSwapChainDesc.SampleDesc.Count = 1;
dxSwapChainDesc.SampleDesc.Quality = 0;
dxSwapChainDesc.BufferCount = 2;
@@ -601,12 +620,17 @@ public:
dxImmediateContext->RSSetViewports(1, &dxViewport);
}
+ float clearColor[4] = { 0, 0, 0, 0 };
+ virtual void setClearColor(float const* color) override
+ {
+ memcpy(clearColor, color, sizeof(clearColor));
+ }
+
virtual void clearFrame() override
{
- static const float kClearColor[] = { 0.25, 0.25, 0.25, 1.0 };
dxImmediateContext->ClearRenderTargetView(
dxBackBufferRTV,
- kClearColor);
+ clearColor);
}
virtual void presentFrame() override