diff options
Diffstat (limited to 'examples/autodiff-texture/main.cpp')
| -rw-r--r-- | examples/autodiff-texture/main.cpp | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/examples/autodiff-texture/main.cpp b/examples/autodiff-texture/main.cpp index 01cad6fe4..8bffadd84 100644 --- a/examples/autodiff-texture/main.cpp +++ b/examples/autodiff-texture/main.cpp @@ -78,6 +78,11 @@ struct AutoDiffTexture : public WindowedAppBase diagnoseIfNeeded(diagnosticsBlob); SLANG_RETURN_ON_FAIL(result); + if (isTestMode()) + { + printEntrypointHashes(componentTypes.getCount() - 1, 1, linkedProgram); + } + gfx::IShaderProgram::Desc programDesc = {}; programDesc.slangGlobalScope = linkedProgram; SLANG_RETURN_ON_FAIL(device->createProgram(programDesc, outProgram)); @@ -114,6 +119,11 @@ struct AutoDiffTexture : public WindowedAppBase diagnoseIfNeeded(diagnosticsBlob); SLANG_RETURN_ON_FAIL(result); + if (isTestMode()) + { + printEntrypointHashes(componentTypes.getCount() - 1, 1, linkedProgram); + } + gfx::IShaderProgram::Desc programDesc = {}; programDesc.slangGlobalScope = linkedProgram; SLANG_RETURN_ON_FAIL(device->createProgram(programDesc, outProgram)); @@ -266,18 +276,31 @@ struct AutoDiffTexture : public WindowedAppBase initializeBase("autodiff-texture", 1024, 768); srand(20421); - gWindow->events.keyPress = [this](platform::KeyEventArgs& e) + if (!isTestMode()) { - if (e.keyChar == 'R' || e.keyChar == 'r') - resetLearntTexture = true; - }; + gWindow->events.keyPress = [this](platform::KeyEventArgs& e) + { + if (e.keyChar == 'R' || e.keyChar == 'r') + resetLearntTexture = true; + }; + } kClearValue.color.floatValues[0] = 0.3f; kClearValue.color.floatValues[1] = 0.5f; kClearValue.color.floatValues[2] = 0.7f; kClearValue.color.floatValues[3] = 1.0f; - auto clientRect = gWindow->getClientRect(); + platform::Rect clientRect{}; + if (isTestMode()) + { + clientRect.width = 1024; + clientRect.height = 768; + } + else + { + clientRect = getWindow()->getClientRect(); + } + windowWidth = clientRect.width; windowHeight = clientRect.height; @@ -321,7 +344,7 @@ struct AutoDiffTexture : public WindowedAppBase } { ComPtr<IShaderProgram> shaderProgram; - SLANG_RETURN_ON_FAIL(loadComputeProgram(gDevice, "convert", shaderProgram.writeRef())); + SLANG_RETURN_ON_FAIL(loadComputeProgram(gDevice, "convert.slang", shaderProgram.writeRef())); gConvertPipelineState = createComputePipelineState(shaderProgram); } { @@ -619,7 +642,7 @@ struct AutoDiffTexture : public WindowedAppBase commandBuffer->close(); gQueue->executeCommandBuffer(commandBuffer); } - + // Draw currently learnt texture. { ComPtr<ICommandBuffer> commandBuffer = @@ -635,7 +658,10 @@ struct AutoDiffTexture : public WindowedAppBase gQueue->executeCommandBuffer(commandBuffer); } - gSwapchain->present(); + if (!isTestMode()) + { + gSwapchain->present(); + } } void drawTexturedQuad(IRenderCommandEncoder* renderEncoder, int x, int y, int w, int h, IResourceView* srv) |
