diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2018-04-20 14:59:17 -0400 |
|---|---|---|
| committer | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-04-20 11:59:17 -0700 |
| commit | c73ccbc5616dff16ecacb9198f725f498a7e6c84 (patch) | |
| tree | 539d28904ecb6970632a396aa6f914d47b9b1175 /tools/render-test/main.cpp | |
| parent | 4c751df1680c30fac0369171a9b8dd4bb5bb5b9f (diff) | |
Fixes/improvements based on feature/render-binding-resource (#511)
* Dx12 rendering works in test framework.
* Turn on dx12 render tests.
* Split out functions for construction or Renderer types into ShaderRendererUtil. Removed the serialization of buffers code into test-render
* Improvements in documentation and typename in BindingState types.
RegisterSet -> CompactBindIndexSlice
RegisterList -> BindIndexSlice
RegisterDesc -> ShaderBindSet
* Fix debug build break.
Diffstat (limited to 'tools/render-test/main.cpp')
| -rw-r--r-- | tools/render-test/main.cpp | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/tools/render-test/main.cpp b/tools/render-test/main.cpp index 887ba4005..5c15c8037 100644 --- a/tools/render-test/main.cpp +++ b/tools/render-test/main.cpp @@ -9,6 +9,8 @@ #include "slang-support.h" +#include "shader-renderer-util.h" + #include "shader-input-layout.h" #include <stdio.h> #include <stdlib.h> @@ -103,7 +105,7 @@ SlangResult RenderTestApp::initialize(Renderer* renderer, ShaderCompiler* shader { BindingState::Desc bindingStateDesc; - SLANG_RETURN_ON_FAIL(createBindingStateDesc(m_shaderInputLayout, m_renderer, bindingStateDesc)); + SLANG_RETURN_ON_FAIL(ShaderRendererUtil::createBindingStateDesc(m_shaderInputLayout, m_renderer, bindingStateDesc)); m_bindingState = m_renderer->createBindingState(bindingStateDesc); } @@ -246,9 +248,59 @@ void RenderTestApp::finalize() Result RenderTestApp::writeBindingOutput(const char* fileName) { - return serializeBindingOutput(m_shaderInputLayout, m_bindingState, m_renderer, fileName); -} + // Submit the work + m_renderer->submitGpuWork(); + // Wait until everything is complete + m_renderer->waitForGpu(); + + FILE * f = fopen(fileName, "wb"); + if (!f) + { + return SLANG_FAIL; + } + + const BindingState::Desc& bindingStateDesc = m_bindingState->getDesc(); + // Must be the same amount of entries + assert(bindingStateDesc.m_bindings.Count() == m_shaderInputLayout.entries.Count()); + const int numBindings = int(bindingStateDesc.m_bindings.Count()); + + for (int i = 0; i < numBindings; ++i) + { + const auto& layoutBinding = m_shaderInputLayout.entries[i]; + const auto& binding = bindingStateDesc.m_bindings[i]; + + if (layoutBinding.isOutput) + { + if (binding.resource && binding.resource->isBuffer()) + { + BufferResource* bufferResource = static_cast<BufferResource*>(binding.resource.Ptr()); + const size_t bufferSize = bufferResource->getDesc().sizeInBytes; + + unsigned int* ptr = (unsigned int*)m_renderer->map(bufferResource, MapFlavor::HostRead); + if (!ptr) + { + fclose(f); + return SLANG_FAIL; + } + + const int size = int(bufferSize / sizeof(unsigned int)); + for (int i = 0; i < size; ++i) + { + fprintf(f, "%X\n", ptr[i]); + } + m_renderer->unmap(bufferResource); + } + else + { + printf("invalid output type at %d.\n", i); + } + } + } + fclose(f); + + return SLANG_OK; +} // // We use a bare-minimum window procedure to get things up and running. |
