summaryrefslogtreecommitdiffstats
path: root/tools/render-test/shader-input-layout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/render-test/shader-input-layout.cpp')
-rw-r--r--tools/render-test/shader-input-layout.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp
index 5ae35b90d..ee4f5fc2c 100644
--- a/tools/render-test/shader-input-layout.cpp
+++ b/tools/render-test/shader-input-layout.cpp
@@ -1,3 +1,6 @@
+// Stop warnings from Visual Studio
+#define _CRT_SECURE_NO_WARNINGS 1
+
#include "shader-input-layout.h"
#include "core/slang-token-reader.h"
@@ -676,6 +679,61 @@ namespace renderer_test
return SLANG_OK;
}
+ /* static */void ShaderInputLayout::getValueBuffers(const Slang::List<ShaderInputLayoutEntry>& entries, const BindSet& bindSet, List<BindSet::Value*>& outBuffers)
+ {
+ outBuffers.setCount(entries.getCount());
+
+ for (Index i = 0; i< outBuffers.getCount(); ++i)
+ {
+ outBuffers[i] = nullptr;
+ }
+
+ const auto& values = bindSet.getValues();
+ for (BindSet::Value* value : values)
+ {
+ if (value->m_userIndex >= 0)
+ {
+ outBuffers[value->m_userIndex] = value;
+ }
+ }
+ }
+
+
+ /* static */SlangResult ShaderInputLayout::writeBindings(const ShaderInputLayout& layout, const List<BindSet::Value*>& buffers, const String& fileName)
+ {
+ FILE * f = fopen(fileName.getBuffer(), "wb");
+ if (!f)
+ {
+ return SLANG_FAIL;
+ }
+
+ const auto& entries = layout.entries;
+
+ for (int i = 0; i < entries.getCount(); ++i)
+ {
+ const auto& entry = entries[i];
+ if (entry.isOutput)
+ {
+ BindSet::Value* buffer = buffers[i];
+
+ unsigned int* ptr = (unsigned int*)buffer->m_data;
+
+ const int size = int(entry.bufferData.getCount());
+ // Must be the same size or less than allocated buffer
+ SLANG_ASSERT(size * sizeof(unsigned int) <= buffer->m_sizeInBytes);
+
+ for (int i = 0; i < size; ++i)
+ {
+ unsigned int v = ptr[i];
+
+ fprintf(f, "%X\n", v);
+ }
+ }
+ }
+ fclose(f);
+ return SLANG_OK;
+ }
+
void generateTextureData(TextureData& output, const InputTextureDesc& desc)
{
switch (desc.format)