diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/gfx-unit-test/gfx-test-texture-util.cpp | 4 | ||||
| -rw-r--r-- | tools/gfx/d3d/d3d-util.cpp | 4 | ||||
| -rw-r--r-- | tools/gfx/gfx.slang | 4 | ||||
| -rw-r--r-- | tools/gfx/render.cpp | 4 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-api.h | 4 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-device.cpp | 120 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-util.cpp | 4 | ||||
| -rw-r--r-- | tools/render-test/shader-input-layout.cpp | 436 | ||||
| -rw-r--r-- | tools/render-test/shader-input-layout.h | 11 | ||||
| -rw-r--r-- | tools/render-test/shader-renderer-util.cpp | 1 |
10 files changed, 423 insertions, 169 deletions
diff --git a/tools/gfx-unit-test/gfx-test-texture-util.cpp b/tools/gfx-unit-test/gfx-test-texture-util.cpp index ed651475d..3b3a1a760 100644 --- a/tools/gfx-unit-test/gfx-test-texture-util.cpp +++ b/tools/gfx-unit-test/gfx-test-texture-util.cpp @@ -80,6 +80,8 @@ namespace gfx_test case Format::R16G16_FLOAT: return new ValidationTextureFormat<uint16_t>(2); case Format::R16_FLOAT: return new ValidationTextureFormat<uint16_t>(1); + case Format::R64_UINT: return new ValidationTextureFormat<uint64_t>(1); + case Format::R32G32B32A32_UINT: return new ValidationTextureFormat<uint32_t>(4); case Format::R32G32B32_UINT: return new ValidationTextureFormat<uint32_t>(3); case Format::R32G32_UINT: return new ValidationTextureFormat<uint32_t>(2); @@ -93,6 +95,8 @@ namespace gfx_test case Format::R8G8_UINT: return new ValidationTextureFormat<uint8_t>(2); case Format::R8_UINT: return new ValidationTextureFormat<uint8_t>(1); + case Format::R64_SINT: return new ValidationTextureFormat<int64_t>(1); + case Format::R32G32B32A32_SINT: return new ValidationTextureFormat<int32_t>(4); case Format::R32G32B32_SINT: return new ValidationTextureFormat<int32_t>(3); case Format::R32G32_SINT: return new ValidationTextureFormat<int32_t>(2); diff --git a/tools/gfx/d3d/d3d-util.cpp b/tools/gfx/d3d/d3d-util.cpp index 34d615744..8d76c74b3 100644 --- a/tools/gfx/d3d/d3d-util.cpp +++ b/tools/gfx/d3d/d3d-util.cpp @@ -167,6 +167,8 @@ D3D12_DEPTH_STENCILOP_DESC D3DUtil::translateStencilOpDesc(DepthStencilOpDesc de case Format::R16G16_FLOAT: return DXGI_FORMAT_R16G16_FLOAT; case Format::R16_FLOAT: return DXGI_FORMAT_R16_FLOAT; + case Format::R64_UINT: return DXGI_FORMAT_R32G32_UINT; + case Format::R32G32B32A32_UINT: return DXGI_FORMAT_R32G32B32A32_UINT; case Format::R32G32B32_UINT: return DXGI_FORMAT_R32G32B32_UINT; case Format::R32G32_UINT: return DXGI_FORMAT_R32G32_UINT; @@ -180,6 +182,8 @@ D3D12_DEPTH_STENCILOP_DESC D3DUtil::translateStencilOpDesc(DepthStencilOpDesc de case Format::R8G8_UINT: return DXGI_FORMAT_R8G8_UINT; case Format::R8_UINT: return DXGI_FORMAT_R8_UINT; + case Format::R64_SINT: return DXGI_FORMAT_R32G32_SINT; + case Format::R32G32B32A32_SINT: return DXGI_FORMAT_R32G32B32A32_SINT; case Format::R32G32B32_SINT: return DXGI_FORMAT_R32G32B32_SINT; case Format::R32G32_SINT: return DXGI_FORMAT_R32G32_SINT; diff --git a/tools/gfx/gfx.slang b/tools/gfx/gfx.slang index e9a31445b..37ae5182d 100644 --- a/tools/gfx/gfx.slang +++ b/tools/gfx/gfx.slang @@ -150,6 +150,8 @@ public enum class Format R16G16_FLOAT, R16_FLOAT, + R64_UINT, + R32G32B32A32_UINT, R32G32B32_UINT, R32G32_UINT, @@ -163,6 +165,8 @@ public enum class Format R8G8_UINT, R8_UINT, + R64_SINT, + R32G32B32A32_SINT, R32G32B32_SINT, R32G32_SINT, diff --git a/tools/gfx/render.cpp b/tools/gfx/render.cpp index 6dd0c90dd..68f81fba5 100644 --- a/tools/gfx/render.cpp +++ b/tools/gfx/render.cpp @@ -86,6 +86,8 @@ struct FormatInfoMap set(Format::R16G16_FLOAT, SLANG_SCALAR_TYPE_FLOAT16, 2); set(Format::R16_FLOAT, SLANG_SCALAR_TYPE_FLOAT16, 1); + set(Format::R64_UINT, SLANG_SCALAR_TYPE_UINT64, 1); + set(Format::R32G32B32A32_UINT, SLANG_SCALAR_TYPE_UINT32, 4); set(Format::R32G32B32_UINT, SLANG_SCALAR_TYPE_UINT32, 3); set(Format::R32G32_UINT, SLANG_SCALAR_TYPE_UINT32, 2); @@ -99,6 +101,8 @@ struct FormatInfoMap set(Format::R8G8_UINT, SLANG_SCALAR_TYPE_UINT8, 2); set(Format::R8_UINT, SLANG_SCALAR_TYPE_UINT8, 1); + set(Format::R64_SINT, SLANG_SCALAR_TYPE_INT64, 1); + set(Format::R32G32B32A32_SINT, SLANG_SCALAR_TYPE_INT32, 4); set(Format::R32G32B32_SINT, SLANG_SCALAR_TYPE_INT32, 3); set(Format::R32G32_SINT, SLANG_SCALAR_TYPE_INT32, 2); diff --git a/tools/gfx/vulkan/vk-api.h b/tools/gfx/vulkan/vk-api.h index 27a19acfb..cceac20e1 100644 --- a/tools/gfx/vulkan/vk-api.h +++ b/tools/gfx/vulkan/vk-api.h @@ -250,6 +250,10 @@ struct VulkanExtendedFeatureProperties VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT atomicFloat2Features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_2_FEATURES_EXT }; + // Image int64 atomic features + VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT imageInt64AtomicFeatures = { + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_IMAGE_ATOMIC_INT64_FEATURES_EXT + }; // Extended dynamic state features VkPhysicalDeviceExtendedDynamicStateFeaturesEXT extendedDynamicStateFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT diff --git a/tools/gfx/vulkan/vk-device.cpp b/tools/gfx/vulkan/vk-device.cpp index b2cbb03c1..dd8a674cb 100644 --- a/tools/gfx/vulkan/vk-device.cpp +++ b/tools/gfx/vulkan/vk-device.cpp @@ -487,6 +487,11 @@ Result DeviceImpl::initVulkanInstanceAndDevice( extendedFeatures.atomicFloat2Features.pNext = deviceFeatures2.pNext; deviceFeatures2.pNext = &extendedFeatures.atomicFloat2Features; + // Image Int64 Atomic + // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT.html + extendedFeatures.imageInt64AtomicFeatures.pNext = deviceFeatures2.pNext; + deviceFeatures2.pNext = &extendedFeatures.imageInt64AtomicFeatures; + // mesh shader features extendedFeatures.meshShaderFeatures.pNext = deviceFeatures2.pNext; deviceFeatures2.pNext = &extendedFeatures.meshShaderFeatures; @@ -580,6 +585,13 @@ Result DeviceImpl::initVulkanInstanceAndDevice( ); SIMPLE_EXTENSION_FEATURE( + extendedFeatures.imageInt64AtomicFeatures, + shaderImageInt64Atomics, + VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME, + "image-atomic-int64" + ); + + SIMPLE_EXTENSION_FEATURE( extendedFeatures.extendedDynamicStateFeatures, extendedDynamicState, VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME, @@ -1638,6 +1650,97 @@ Result DeviceImpl::createTextureResource( VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); + if(desc.sampleDesc.numSamples != 1) + { + // Handle senario where texture is sampled. We cannot use + // a simple buffer copy for sampled textures. ClearColorImage + // is not data accurate but it is fine for testing & works. + FormatInfo formatInfo; + gfxGetFormatInfo(desc.format, &formatInfo); + uint32_t data = 0; + VkClearColorValue clearColor; + switch(formatInfo.channelType) + { + case SLANG_SCALAR_TYPE_INT32: + for(int i = 0; i < 4; i++) + clearColor.int32[i] = *reinterpret_cast<int32_t*>(const_cast<void*>(initData->data)); + break; + case SLANG_SCALAR_TYPE_UINT32: + for(int i = 0; i < 4; i++) + clearColor.uint32[i] = *reinterpret_cast<uint32_t*>(const_cast<void*>(initData->data)); break; + break; + case SLANG_SCALAR_TYPE_INT64: + { + for(int i = 0; i < 4; i++) + clearColor.int32[i] = int32_t(*reinterpret_cast<int64_t*>(const_cast<void*>(initData->data))); + break; + } + case SLANG_SCALAR_TYPE_UINT64: + { + for(int i = 0; i < 4; i++) + clearColor.uint32[i] = uint32_t(*reinterpret_cast<uint64_t*>(const_cast<void*>(initData->data))); + break; + } + case SLANG_SCALAR_TYPE_FLOAT16: + { + for(int i = 0; i < 4; i++) + clearColor.float32[i] = HalfToFloat(*reinterpret_cast<uint16_t*>(const_cast<void*>(initData->data))); + break; + } + case SLANG_SCALAR_TYPE_FLOAT32: + { + for(int i = 0; i < 4; i++) + clearColor.float32[i] = (*reinterpret_cast<float*>(const_cast<void*>(initData->data))); + break; + } + case SLANG_SCALAR_TYPE_FLOAT64: + { + for(int i = 0; i < 4; i++) + clearColor.float32[i] = float(*reinterpret_cast<double*>(const_cast<void*>(initData->data))); + break; + } + case SLANG_SCALAR_TYPE_INT8: + { + for(int i = 0; i < 4; i++) + clearColor.int32[i] = int32_t(*reinterpret_cast<int8_t*>(const_cast<void*>(initData->data))); + break; + } + case SLANG_SCALAR_TYPE_UINT8: + { + for(int i = 0; i < 4; i++) + clearColor.uint32[i] = uint32_t(*reinterpret_cast<uint8_t*>(const_cast<void*>(initData->data))); + break; + } + case SLANG_SCALAR_TYPE_INT16: + { + for(int i = 0; i < 4; i++) + clearColor.int32[i] = int32_t(*reinterpret_cast<int16_t*>(const_cast<void*>(initData->data))); + break; + } + case SLANG_SCALAR_TYPE_UINT16: + { + for(int i = 0; i < 4; i++) + clearColor.uint32[i] = uint32_t(*reinterpret_cast<uint16_t*>(const_cast<void*>(initData->data))); + break; + } + }; + + VkImageSubresourceRange range{}; + range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + range.baseMipLevel = 0; + range.levelCount = VK_REMAINING_MIP_LEVELS; + range.baseArrayLayer = 0; + range.layerCount = VK_REMAINING_ARRAY_LAYERS; + + m_api.vkCmdClearColorImage( + commandBuffer, + texture->m_image, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + &clearColor, + 1, + &range); + } + else { Offset srcOffset = 0; for (int i = 0; i < arraySize; ++i) @@ -2154,6 +2257,23 @@ Result DeviceImpl::createBufferView( info.buffer = resourceImpl->m_buffer.m_buffer; info.offset = offset; info.range = size; + VkBufferUsageFlags2CreateInfoKHR bufferViewUsage{}; + bufferViewUsage.sType = VK_STRUCTURE_TYPE_BUFFER_USAGE_FLAGS_2_CREATE_INFO_KHR; + + if (desc.type == IResourceView::Type::UnorderedAccess) + { + info.pNext = &bufferViewUsage; + bufferViewUsage.usage = VK_BUFFER_USAGE_2_STORAGE_TEXEL_BUFFER_BIT_KHR; + } + else if (desc.type == IResourceView::Type::ShaderResource) + { + info.pNext = &bufferViewUsage; + bufferViewUsage.usage = VK_BUFFER_USAGE_2_UNIFORM_TEXEL_BUFFER_BIT_KHR; + } + else + { + assert(!"unhandled"); + } SLANG_VK_RETURN_ON_FAIL(m_api.vkCreateBufferView(m_device, &info, nullptr, &view)); } diff --git a/tools/gfx/vulkan/vk-util.cpp b/tools/gfx/vulkan/vk-util.cpp index e8007805a..1a571c812 100644 --- a/tools/gfx/vulkan/vk-util.cpp +++ b/tools/gfx/vulkan/vk-util.cpp @@ -25,6 +25,8 @@ namespace gfx { case Format::R8_TYPELESS: return VK_FORMAT_R8_UNORM; case Format::B8G8R8A8_TYPELESS: return VK_FORMAT_B8G8R8A8_UNORM; + case Format::R64_UINT: return VK_FORMAT_R64_UINT; + case Format::R32G32B32A32_FLOAT: return VK_FORMAT_R32G32B32A32_SFLOAT; case Format::R32G32B32_FLOAT: return VK_FORMAT_R32G32B32_SFLOAT; case Format::R32G32_FLOAT: return VK_FORMAT_R32G32_SFLOAT; @@ -47,6 +49,8 @@ namespace gfx { case Format::R8G8_UINT: return VK_FORMAT_R8G8_UINT; case Format::R8_UINT: return VK_FORMAT_R8_UINT; + case Format::R64_SINT: return VK_FORMAT_R64_SINT; + case Format::R32G32B32A32_SINT: return VK_FORMAT_R32G32B32A32_SINT; case Format::R32G32B32_SINT: return VK_FORMAT_R32G32B32_SINT; case Format::R32G32_SINT: return VK_FORMAT_R32G32_SINT; diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp index 6b30315fb..96f5db6e0 100644 --- a/tools/render-test/shader-input-layout.cpp +++ b/tools/render-test/shader-input-layout.cpp @@ -112,6 +112,25 @@ namespace renderer_test else val->textureDesc.content = InputTextureContent::Gradient; } + else if (word == "sampleCount") + { + parser.Read("="); + auto contentWord = parser.ReadWord(); + if(contentWord == "one") + val->textureDesc.sampleCount = InputTextureSampleCount::One; + else if(contentWord == "two") + val->textureDesc.sampleCount = InputTextureSampleCount::Two; + else if(contentWord == "four") + val->textureDesc.sampleCount = InputTextureSampleCount::Four; + else if(contentWord == "eight") + val->textureDesc.sampleCount = InputTextureSampleCount::Eight; + else if(contentWord == "sixteen") + val->textureDesc.sampleCount = InputTextureSampleCount::Sixteen; + else if(contentWord == "thirtyTwo") + val->textureDesc.sampleCount = InputTextureSampleCount::ThirtyTwo; + else if(contentWord == "sixtyFour") + val->textureDesc.sampleCount = InputTextureSampleCount::SixtyFour; + } else if(word == "mipMaps") { parser.Read("="); @@ -633,6 +652,13 @@ namespace renderer_test maybeParseOptions(parser, val.Ptr()); return val; } + else if (parser.AdvanceIf("RWTextureBuffer")) + { + RefPtr<ShaderInputLayout::BufferVal> val = new ShaderInputLayout::BufferVal; + val->bufferDesc.type = InputBufferType::StorageBuffer; + maybeParseOptions(parser, val.Ptr()); + return val; + } else if (parser.AdvanceIf("Texture2D")) { RefPtr<ShaderInputLayout::TextureVal> val = new ShaderInputLayout::TextureVal; @@ -1100,7 +1126,99 @@ namespace renderer_test return SLANG_OK; } + void loadDataIntoHalf(uint16_t& out, const uint8_t& in) + { + out = FloatToHalf((float(in) / 255.0f)); + } + void loadDataIntoFloat(float& out, const uint8_t& in) + { + out = (float(in)/255.0f); + } + template<typename T> + void loadDataIntoUint(T& out, const uint8_t& in) + { + out = T(in); + } + template<typename T> + void loadDataIntoInt(T& out, const uint8_t& in) + { + out = T(in); + } + + // T for type to return, F for function pointer to operate on uint8->T + template<typename T, typename F> + void generateTextureDataWithTargetTStorage(TextureData& output, const InputTextureDesc& desc, gfx::FormatInfo& formatInfo, F loadUint8ToT) + { + // the following function assumes input of 0 or 1 since our testing framework only tests with 0 or 1 + TextureData work; + generateTextureDataRGB8(work, desc); + + output.init(desc.format); + + output.m_textureSize = work.m_textureSize; + output.m_mipLevels = work.m_mipLevels; + output.m_arraySize = work.m_arraySize; + List<TextureData::Slice>& dstSlices = output.m_slices; + + Index numSlices = work.m_slices.getCount(); + dstSlices.setCount(numSlices); + + for (int i = 0; i < numSlices; ++i) + { + const TextureData::Slice& srcSlice = work.m_slices[i]; + + const Index pixelCount = srcSlice.valuesCount; + const uint8_t* srcPixels = (const uint8_t*)srcSlice.values; + + T* dstPixels = (T*)output.setSliceCount(i, pixelCount); + switch (formatInfo.channelCount) + { + case 1: + { + for (Index j = 0; j < pixelCount; ++j, srcPixels += 4, dstPixels += 1) + { + // Copy out r + loadUint8ToT(dstPixels[0], srcPixels[0]); + } + break; + } + case 2: + { + for (Index j = 0; j < pixelCount; ++j, srcPixels += 4, dstPixels += 2) + { + // Copy out rg + loadUint8ToT(dstPixels[0], srcPixels[0]); + loadUint8ToT(dstPixels[1], srcPixels[1]); + } + break; + } + case 3: + { + for (Index j = 0; j < pixelCount; ++j, srcPixels += 4, dstPixels += 3) + { + // Copy out rgb + loadUint8ToT(dstPixels[0], srcPixels[0]); + loadUint8ToT(dstPixels[1], srcPixels[1]); + loadUint8ToT(dstPixels[2], srcPixels[2]); + } + break; + } + case 4: + { + for (Index j = 0; j < pixelCount; ++j, srcPixels += 4, dstPixels += 4) + { + // Copy out rgba + loadUint8ToT(dstPixels[0], srcPixels[0]); + loadUint8ToT(dstPixels[1], srcPixels[1]); + loadUint8ToT(dstPixels[2], srcPixels[2]); + loadUint8ToT(dstPixels[3], srcPixels[3]); + } + break; + } + } + } + } void generateTextureData(TextureData& output, const InputTextureDesc& desc) { gfx::FormatInfo formatInfo; @@ -1117,75 +1235,12 @@ namespace renderer_test case Format::R16G16_FLOAT: case Format::R16G16B16A16_FLOAT: { - TextureData work; - generateTextureDataRGB8(work, desc); - - output.init(desc.format); - - output.m_textureSize = work.m_textureSize; - output.m_mipLevels = work.m_mipLevels; - output.m_arraySize = work.m_arraySize; - - List<TextureData::Slice>& dstSlices = output.m_slices; - - Index numSlices = work.m_slices.getCount(); - dstSlices.setCount(numSlices); - - for (int i = 0; i < numSlices; ++i) - { - const TextureData::Slice& srcSlice = work.m_slices[i]; - - const Index pixelCount = srcSlice.valuesCount; - const uint8_t* srcPixels = (const uint8_t*)srcSlice.values; - - int16_t* dstPixels = (int16_t*)output.setSliceCount(i, pixelCount); - - switch (formatInfo.channelCount) - { - case 1: - { - for (Index j = 0; j < pixelCount; ++j, srcPixels += 4, dstPixels += 1) - { - // Copy out r - dstPixels[0] = FloatToHalf(srcPixels[0] * (1.0f / 255)); - } - break; - } - case 2: - { - for (Index j = 0; j < pixelCount; ++j, srcPixels += 4, dstPixels += 2) - { - // Copy out rg - dstPixels[0] = FloatToHalf(srcPixels[0] * (1.0f / 255)); - dstPixels[1] = FloatToHalf(srcPixels[1] * (1.0f / 255)); - } - break; - } - case 3: - { - for (Index j = 0; j < pixelCount; ++j, srcPixels += 4, dstPixels += 3) - { - // Copy out rgb - dstPixels[0] = FloatToHalf(srcPixels[0] * (1.0f / 255)); - dstPixels[1] = FloatToHalf(srcPixels[1] * (1.0f / 255)); - dstPixels[2] = FloatToHalf(srcPixels[2] * (1.0f / 255)); - } - break; - } - case 4: - { - for (Index j = 0; j < pixelCount; ++j, srcPixels += 4, dstPixels += 4) - { - // Copy out rgba - dstPixels[0] = FloatToHalf(srcPixels[0] * (1.0f / 255)); - dstPixels[1] = FloatToHalf(srcPixels[1] * (1.0f / 255)); - dstPixels[2] = FloatToHalf(srcPixels[2] * (1.0f / 255)); - dstPixels[3] = FloatToHalf(srcPixels[3] * (1.0f / 255)); - } - break; - } - } - } + generateTextureDataWithTargetTStorage<uint16_t>(output, desc, formatInfo, loadDataIntoHalf); + break; + } + case Format::R64_UINT: + { + generateTextureDataWithTargetTStorage<uint64_t>(output, desc, formatInfo, loadDataIntoUint<uint64_t>); break; } case Format::R32_FLOAT: @@ -1194,76 +1249,56 @@ namespace renderer_test case Format::R32G32B32A32_FLOAT: case Format::D32_FLOAT: { - TextureData work; - generateTextureDataRGB8(work, desc); - - output.init(desc.format); - - output.m_textureSize = work.m_textureSize; - output.m_mipLevels = work.m_mipLevels; - output.m_arraySize = work.m_arraySize; - - List<TextureData::Slice>& dstSlices = output.m_slices; - - Index numSlices = work.m_slices.getCount(); - dstSlices.setCount(numSlices); - - for (int i = 0; i < numSlices; ++i) - { - const TextureData::Slice& srcSlice = work.m_slices[i]; - - const Index pixelCount = srcSlice.valuesCount; - const uint8_t* srcPixels = (const uint8_t*)srcSlice.values; - - float* dstPixels = (float*)output.setSliceCount(i, pixelCount); - - switch (formatInfo.channelCount) - { - case 1: - { - for (Index j = 0; j < pixelCount; ++j, srcPixels += 4, dstPixels++) - { - // Copy out r - dstPixels[0] = srcPixels[0] * (1.0f / 255); - } - break; - } - case 2: - { - for (Index j = 0; j < pixelCount; ++j, srcPixels += 4, dstPixels += 2) - { - // Copy out rg - dstPixels[0] = srcPixels[0] * (1.0f / 255); - dstPixels[1] = srcPixels[1] * (1.0f / 255); - } - break; - } - case 3: - { - for (Index j = 0; j < pixelCount; ++j, srcPixels += 4, dstPixels += 3) - { - // Copy out rgb - dstPixels[0] = srcPixels[0] * (1.0f / 255); - dstPixels[1] = srcPixels[1] * (1.0f / 255); - dstPixels[2] = srcPixels[2] * (1.0f / 255); - } - break; - } - case 4: - { - - for (Index j = 0; j < pixelCount; ++j, srcPixels += 4, dstPixels += 4) - { - // Copy out rgba - dstPixels[0] = srcPixels[0] * (1.0f / 255); - dstPixels[1] = srcPixels[1] * (1.0f / 255); - dstPixels[2] = srcPixels[2] * (1.0f / 255); - dstPixels[3] = srcPixels[3] * (1.0f / 255); - } - break; - } - } - } + generateTextureDataWithTargetTStorage<float>(output, desc, formatInfo, loadDataIntoFloat); + break; + } + case Format::R32_UINT: + case Format::R32G32_UINT: + case Format::R32G32B32_UINT: + case Format::R32G32B32A32_UINT: + { + generateTextureDataWithTargetTStorage<uint32_t>(output, desc, formatInfo, loadDataIntoUint<uint32_t>); + break; + } + case Format::R16_UINT: + case Format::R16G16_UINT: + case Format::R16G16B16A16_UINT: + { + generateTextureDataWithTargetTStorage<uint16_t>(output, desc, formatInfo, loadDataIntoUint<uint16_t>); + break; + } + case Format::R8_UINT: + case Format::R8G8_UINT: + case Format::R8G8B8A8_UINT: + { + generateTextureDataWithTargetTStorage<uint8_t>(output, desc, formatInfo, loadDataIntoUint<uint8_t>); + break; + } + case Format::R64_SINT: + { + generateTextureDataWithTargetTStorage<int64_t>(output, desc, formatInfo, loadDataIntoInt<int64_t>); + break; + } + case Format::R32_SINT: + case Format::R32G32_SINT: + case Format::R32G32B32_SINT: + case Format::R32G32B32A32_SINT: + { + generateTextureDataWithTargetTStorage<int32_t>(output, desc, formatInfo, loadDataIntoInt<int32_t>); + break; + } + case Format::R16_SINT: + case Format::R16G16_SINT: + case Format::R16G16B16A16_SINT: + { + generateTextureDataWithTargetTStorage<int16_t>(output, desc, formatInfo, loadDataIntoInt<int16_t>); + break; + } + case Format::R8_SINT: + case Format::R8G8_SINT: + case Format::R8G8B8A8_SINT: + { + generateTextureDataWithTargetTStorage<int8_t>(output, desc, formatInfo, loadDataIntoInt<int8_t>); break; } default: @@ -1299,6 +1334,37 @@ namespace renderer_test output.init(Format::R8G8B8A8_UNORM); + enum class SimpleScalarType { + kUint, + kInt, + kFloat, + }; + SimpleScalarType type; + gfx::FormatInfo formatInfo; + gfxGetFormatInfo(inputDesc.format, &formatInfo); + switch (formatInfo.channelType) + { + case SLANG_SCALAR_TYPE_UINT64: + case SLANG_SCALAR_TYPE_UINT32: + case SLANG_SCALAR_TYPE_UINT16: + case SLANG_SCALAR_TYPE_UINT8: + type = SimpleScalarType::kUint; + break; + case SLANG_SCALAR_TYPE_INT64: + case SLANG_SCALAR_TYPE_INT32: + case SLANG_SCALAR_TYPE_INT16: + case SLANG_SCALAR_TYPE_INT8: + type = SimpleScalarType::kInt; + break; + case SLANG_SCALAR_TYPE_FLOAT64: + case SLANG_SCALAR_TYPE_FLOAT32: + case SLANG_SCALAR_TYPE_FLOAT16: + type = SimpleScalarType::kFloat; + break; + default: + type = SimpleScalarType::kUint; + break; + } //List<List<unsigned int>>& dataBuffer = output.dataBuffer; int arraySize = arrLen; if (inputDesc.isCube) @@ -1327,36 +1393,68 @@ namespace renderer_test uint32_t* dst = (uint32_t*)output.setSliceCount(slice, bufferLen); - _iteratePixels(inputDesc.dimension, size, dst, [&](int x, int y, int z) -> unsigned int - { - if (inputDesc.content == InputTextureContent::Zero) - { - return 0x0; - } - else if (inputDesc.content == InputTextureContent::One) - { - return 0xFFFFFFFF; - } - else if (inputDesc.content == InputTextureContent::Gradient) - { - unsigned char r = (unsigned char)(x / (float)(size - 1) * 255.0f); - unsigned char g = (unsigned char)(y / (float)(size - 1) * 255.0f); - unsigned char b = (unsigned char)(z / (float)(size - 1) * 255.0f); - return 0xFF000000 + r + (g << 8) + (b << 16); - } - else if (inputDesc.content == InputTextureContent::ChessBoard) - { - unsigned int xSig = x < (size >> 1) ? 1 : 0; - unsigned int ySig = y < (size >> 1) ? 1 : 0; - unsigned int zSig = z < (size >> 1) ? 1 : 0; - auto sig = xSig ^ ySig ^ zSig; - if (sig) - return 0xFFFFFFFF; - else - return 0xFF808080; - } - return 0x0; - }); + if (type == SimpleScalarType::kFloat) + _iteratePixels(inputDesc.dimension, size, dst, [&](int x, int y, int z) -> unsigned int + { + if (inputDesc.content == InputTextureContent::Zero) + { + return 0x0; + } + else if (inputDesc.content == InputTextureContent::One) + { + return 0xFFFFFFFF; + } + else if (inputDesc.content == InputTextureContent::Gradient) + { + unsigned char r = (unsigned char)(x / (float)(size - 1) * 255.0f); + unsigned char g = (unsigned char)(y / (float)(size - 1) * 255.0f); + unsigned char b = (unsigned char)(z / (float)(size - 1) * 255.0f); + return 0xFF000000 + r + (g << 8) + (b << 16); + } + else if (inputDesc.content == InputTextureContent::ChessBoard) + { + unsigned int xSig = x < (size >> 1) ? 1 : 0; + unsigned int ySig = y < (size >> 1) ? 1 : 0; + unsigned int zSig = z < (size >> 1) ? 1 : 0; + auto sig = xSig ^ ySig ^ zSig; + if (sig) + return 0xFFFFFFFF; + else + return 0xFF808080; + } + return 0x0; + }); + else if (type == SimpleScalarType::kUint || type == SimpleScalarType::kInt) + _iteratePixels(inputDesc.dimension, size, dst, [&](int x, int y, int z) -> unsigned int + { + if (inputDesc.content == InputTextureContent::Zero) + { + return 0x0; + } + else if (inputDesc.content == InputTextureContent::One) + { + return 0x01010101; + } + else if (inputDesc.content == InputTextureContent::Gradient) + { + unsigned char r = (unsigned char)(x / (float)(size - 1)); + unsigned char g = (unsigned char)(y / (float)(size - 1)); + unsigned char b = (unsigned char)(z / (float)(size - 1)); + return 0x01000000 + r + (g << 8) + (b << 16); + } + else if (inputDesc.content == InputTextureContent::ChessBoard) + { + unsigned int xSig = x < (size >> 1) ? 1 : 0; + unsigned int ySig = y < (size >> 1) ? 1 : 0; + unsigned int zSig = z < (size >> 1) ? 1 : 0; + auto sig = xSig ^ ySig ^ zSig; + if (sig) + return 0x01010101; + else + return 0x0; + } + return 0x0; + }); slice++; } } diff --git a/tools/render-test/shader-input-layout.h b/tools/render-test/shader-input-layout.h index 2803d1915..de1da3da9 100644 --- a/tools/render-test/shader-input-layout.h +++ b/tools/render-test/shader-input-layout.h @@ -31,6 +31,16 @@ enum class InputTextureContent Zero, One, ChessBoard, Gradient }; +enum InputTextureSampleCount +{ + One = 1, + Two = 2, + Four = 4, + Eight = 8, + Sixteen = 16, + ThirtyTwo = 32, + SixtyFour = 64, +}; struct InputTextureDesc { int dimension = 2; @@ -41,6 +51,7 @@ struct InputTextureDesc int size = 4; int mipMapCount = 0; ///< 0 means the maximum number of mips will be bound + InputTextureSampleCount sampleCount = InputTextureSampleCount::One; Format format = Format::R8G8B8A8_UNORM; InputTextureContent content = InputTextureContent::One; diff --git a/tools/render-test/shader-renderer-util.cpp b/tools/render-test/shader-renderer-util.cpp index bbc000594..fe726012e 100644 --- a/tools/render-test/shader-renderer-util.cpp +++ b/tools/render-test/shader-renderer-util.cpp @@ -32,6 +32,7 @@ using Slang::Result; // Default to R8G8B8A8_UNORM const Format format = (inputDesc.format == Format::Unknown) ? Format::R8G8B8A8_UNORM : inputDesc.format; + textureResourceDesc.sampleDesc = ITextureResource::SampleDesc{inputDesc.sampleCount, 0}; textureResourceDesc.format = format; textureResourceDesc.numMipLevels = texData.m_mipLevels; textureResourceDesc.arraySize = inputDesc.arrayLength; |
