diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-02-18 12:40:14 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-18 12:40:14 -0500 |
| commit | e109985375712b449d365450b3d3e39416a171ce (patch) | |
| tree | 56a2c805368d5afbfa568e514af0704b8ed7346c /tools/render-test/cpu-compute-util.cpp | |
| parent | 2c097545eaa324a91a035327abad2e8b4fa60469 (diff) | |
CUDA/CPU resource coverage (#1224)
* Add cubemap support.
* Add CUDA fence instrinsics.
* Added Gather for CUDA.
* Use the CUDA driver API as much as possible.
* * Support 1D texture on CPU
* WIP on 1D texture on CUDA
* Added simplified texture test
* Fix test.
* Improve texture-simple tests.
* * Add CPU support for 3d textures
* Add support for mip maps to CUDA
* Disable warnings in nvrtc
* Update CUDA docs
* WIP on 3d texture support.
* Add support for 3d textures for CPU and CUDA.
Diffstat (limited to 'tools/render-test/cpu-compute-util.cpp')
| -rw-r--r-- | tools/render-test/cpu-compute-util.cpp | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/tools/render-test/cpu-compute-util.cpp b/tools/render-test/cpu-compute-util.cpp index d0907482c..d69521e66 100644 --- a/tools/render-test/cpu-compute-util.cpp +++ b/tools/render-test/cpu-compute-util.cpp @@ -16,6 +16,40 @@ namespace renderer_test { using namespace Slang; template <int COUNT> +struct ValueTexture3D : public CPUComputeUtil::Resource, public CPPPrelude::ITexture3D +{ + void set(void* out) + { + float* dst = (float*)out; + for (int i = 0; i < COUNT; ++i) + { + dst[i] = m_value; + } + } + + virtual void Load(const CPPPrelude::int4& v, void* out) SLANG_OVERRIDE + { + set(out); + } + virtual void Sample(CPPPrelude::SamplerState samplerState, const CPPPrelude::float3& loc, void* out) SLANG_OVERRIDE + { + set(out); + } + virtual void SampleLevel(CPPPrelude::SamplerState samplerState, const CPPPrelude::float3& loc, float level, void* out) SLANG_OVERRIDE + { + set(out); + } + + ValueTexture3D(float value) : + m_value(value) + { + m_interface = static_cast<CPPPrelude::ITexture3D*>(this); + } + + float m_value; +}; + +template <int COUNT> struct ValueTexture2D : public CPUComputeUtil::Resource, public CPPPrelude::ITexture2D { void set(void* out) @@ -83,6 +117,8 @@ struct ValueTexture1D : public CPUComputeUtil::Resource, public CPPPrelude::ITex float m_value; }; + + static CPUComputeUtil::Resource* _newValueTexture(SlangResourceShape baseShape, int elemCount, float value) { switch (baseShape) @@ -110,12 +146,22 @@ static CPUComputeUtil::Resource* _newValueTexture(SlangResourceShape baseShape, default: break; } } + case SLANG_TEXTURE_3D: + { + switch (elemCount) + { + case 1: return new ValueTexture3D<1>(value); + case 2: return new ValueTexture3D<2>(value); + case 3: return new ValueTexture3D<3>(value); + case 4: return new ValueTexture3D<4>(value); + default: break; + } + } default: break; } return nullptr; } - /* static */SlangResult CPUComputeUtil::calcBindings(const ShaderCompilerUtil::OutputAndLayout& compilationAndLayout, Context& outContext) { auto request = compilationAndLayout.output.request; @@ -172,6 +218,8 @@ static CPUComputeUtil::Resource* _newValueTexture(SlangResourceShape baseShape, { case SLANG_TEXTURE_1D: case SLANG_TEXTURE_2D: + case SLANG_TEXTURE_3D: + case SLANG_TEXTURE_CUBE: { SLANG_ASSERT(value->m_userIndex >= 0); auto& srcEntry = layout.entries[value->m_userIndex]; @@ -203,11 +251,15 @@ static CPUComputeUtil::Resource* _newValueTexture(SlangResourceShape baseShape, } default: break; } + + if (value->m_target == nullptr) + { + SLANG_ASSERT(!"Couldn't construct resource type"); + return SLANG_FAIL; + } + break; } - - case SLANG_TEXTURE_3D: - case SLANG_TEXTURE_CUBE: case SLANG_TEXTURE_BUFFER: { // Need a CPU impl for these... |
