From e510a287deb25f2542a68bf21382f2557740d70c Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 6 May 2021 12:45:00 -0400 Subject: Half texture support (#1836) * #include an absolute path didn't work - because paths were taken to always be relative. * Split out StringEscapeUtil. * Added StringEscapeUtil. * Fix typo in unix quoting type. * Small comment improvements. * Try to fix linux linking issue. * Fix typo. * Attempt to fix linux link issue. * Update VS proj even though nothing really changed. * Fix another typo issue. * Fix for windows issue. Fixed bug. * Make separate Utils for escaping. * Fix typo. * Split out into StringEscapeHandler. * Windows shell does handle removing quotes (so remove code to remove them). * Handle unescaping if not initiating using the shell. * Slight improvement around shell like decoding. * Simplify command extraction. * Add shared-library category type. * Fix bug in command extraction. * Typo in transcendental category. * Enable unit-test on in smoke test category. * Make parsing failing output as a failing test. * Fixes for transcendental tests. Disable tests that do not work. * Changed category parsing. * Removed the TestResult parameter from _gatherTestsForFile. Made testsList only output. * Remove testing if all tests were disabled. * Make args of CommandLine always unescaped. * Add category. * Don't need escaping on unix/linux. * Remove some no longer used functions. * Add requireSMVersion to CUDAExtensionTracker. * half-calc.slang now works for CUDA. * bit-cast-16-bit works on CUDA. * WIP handling of CUDA vector types. * Half swizzle CUDA. * Half vector test. * Fix swizzle half bug. * Fix compilation issue with narrowing to Index. * Add unary ops. * Add some vector scalar maths ops. * Add half vector conversions for CUDA. * Fix erroneous comment. * Support for half comparisons. * First pass test for half compare. * Fix bug in CUDA specialized emit control. Updated tests to have pre and post inc/dec. * Removed unneeded parts of the cuda prelude. * Half structured buffer works on CUDA. * Added name lookup for Gfx::Format * Support half texture type in test system. * Test for half reading on CUDA. * Add half formats to Vk and D3D utils. * Fix getAt for CUDA - where there might not be a .x member in a vector. --- tools/render-test/shader-input-layout.h | 73 +++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 4 deletions(-) (limited to 'tools/render-test/shader-input-layout.h') diff --git a/tools/render-test/shader-input-layout.h b/tools/render-test/shader-input-layout.h index 60582aed8..adb30c7ec 100644 --- a/tools/render-test/shader-input-layout.h +++ b/tools/render-test/shader-input-layout.h @@ -65,10 +65,75 @@ struct InputSamplerDesc struct TextureData { - Slang::List> dataBuffer; - int textureSize; - int mipLevels; - int arraySize; + struct Slice + { + static Slice make(void* values, size_t size) + { + Slice slice; + slice.values = values; + slice.valuesCount = size; + return slice; + } + + void* values = nullptr; ///< Values of the type format + size_t valuesCount = 0; + }; + + void addSlice(const void* data, size_t elemCount) + { + const size_t totalSize = m_formatSize * elemCount; + void* dst = ::malloc(totalSize); + ::memcpy(dst, data, totalSize); + m_slices.add(Slice::make(dst, elemCount)); + } + void* addSlice(size_t elemCount) + { + void* dst = ::malloc(m_formatSize * elemCount); + m_slices.add(Slice::make(dst, elemCount)); + return dst; + } + + /// Set the size of the slice in count of format sized elements + void* setSliceCount(Slang::Index sliceIndex, size_t count) + { + auto& slice = m_slices[sliceIndex]; + if (count != slice.valuesCount) + { + slice.values = ::realloc(slice.values, count * m_formatSize); + slice.valuesCount = count; + } + return slice.values; + } + + void init(Format format) + { + clearSlices(); + + m_formatSize = uint8_t(gfxGetFormatSize(format)); + m_format = format; + } + + ~TextureData() { clearSlices(); } + + void clearSlices() + { + for (auto& slice : m_slices) + { + if (slice.values) + { + ::free(slice.values); + } + } + m_slices.clear(); + } + + gfx::Format m_format = gfx::Format::Unknown; + uint8_t m_formatSize = 0; + + Slang::List m_slices; + int m_textureSize; + int m_mipLevels; + int m_arraySize; }; class ShaderInputLayout -- cgit v1.2.3