summaryrefslogtreecommitdiffstats
path: root/tools/render-test/shader-input-layout.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-03-05 14:53:44 -0500
committerGitHub <noreply@github.com>2019-03-05 14:53:44 -0500
commit3d5546600fb4c585b6f6f6dcdb5e122698d1225e (patch)
treea11fc783760fd6e4b03c05b40fd4ff2f11c582da /tools/render-test/shader-input-layout.cpp
parent890403f576a85a7dca90d9d20360cd73c9ec9604 (diff)
Hotfix/texture2d gather (#876)
* First pass test to see if GatherRed works. * Add support for generating R_Float32 textures. * Set default texture format. * * Alter the texture2d-gather to work with a R_Float32 texture * Add support for scalar Texture2d types with GatherXXX in stdlib * Remove some left over commented out test code from texture2d-gather.hlsl
Diffstat (limited to 'tools/render-test/shader-input-layout.cpp')
-rw-r--r--tools/render-test/shader-input-layout.cpp70
1 files changed, 67 insertions, 3 deletions
diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp
index 5a2021b01..6d51a1980 100644
--- a/tools/render-test/shader-input-layout.cpp
+++ b/tools/render-test/shader-input-layout.cpp
@@ -208,10 +208,25 @@ namespace renderer_test
}
else if(word == "format")
{
+ Format format = Format::Unknown;
+
parser.Read("=");
auto formatWord = parser.ReadWord();
if(formatWord == "R_UInt32")
- entry.bufferDesc.format = Format::R_UInt32;
+ {
+ format = Format::R_UInt32;
+ }
+ else if (formatWord == "R_Float32")
+ {
+ format = Format::R_Float32;
+ }
+ else if (formatWord == "RGBA_Unorm_UInt8")
+ {
+ format = Format::RGBA_Unorm_UInt8;
+ }
+
+ entry.textureDesc.format = format;
+ entry.bufferDesc.format = format;
}
if (parser.LookAhead(","))
parser.Read(",");
@@ -265,15 +280,64 @@ namespace renderer_test
}
}
}
+ }
+
+ void generateTextureData(TextureData& output, const InputTextureDesc& desc)
+ {
+ switch (desc.format)
+ {
+ case Format::RGBA_Unorm_UInt8:
+ {
+ generateTextureDataRGB8(output, desc);
+ break;
+ }
+ case Format::R_Float32:
+ {
+ TextureData work;
+ generateTextureDataRGB8(work, desc);
+ output.textureSize = work.textureSize;
+ output.mipLevels = work.mipLevels;
+ output.arraySize = work.arraySize;
+ List<List<unsigned int>>& dstBuffer = output.dataBuffer;
+
+ int numMips = int(work.dataBuffer.Count());
+ dstBuffer.SetSize(numMips);
+
+ for (int i = 0; i < numMips; ++i)
+ {
+ const int numPixels = int(work.dataBuffer[i].Count());
+ const unsigned int* srcPixels = work.dataBuffer[i].Buffer();
+
+ dstBuffer[i].SetSize(numPixels);
+
+ float* dstPixels = (float*)dstBuffer[i].Buffer();
+
+ for (int j = 0; j < numPixels; ++j)
+ {
+ // Copy out red
+ const unsigned int srcPixel = srcPixels[j];
+ const float value = (srcPixel & 0xff) * 1.0f / 255;
+ dstPixels[j] = value;
+ }
+ }
+ break;
+ }
+ default:
+ {
+ SLANG_ASSERT(!"Unhandled format");
+ break;
+ }
+ }
}
- void generateTextureData(TextureData & output, const InputTextureDesc & inputDesc)
+
+ void generateTextureDataRGB8(TextureData& output, const InputTextureDesc& inputDesc)
{
int arrLen = inputDesc.arrayLength;
if (arrLen == 0)
arrLen = 1;
- List<List<unsigned int>> & dataBuffer = output.dataBuffer;
+ List<List<unsigned int>>& dataBuffer = output.dataBuffer;
int arraySize = arrLen;
if (inputDesc.isCube)
arraySize *= 6;