diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-06-05 21:35:48 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-05 21:35:48 -0700 |
| commit | 1a698128c15bce0c05b0664bb1458842e1e55511 (patch) | |
| tree | de4b65733737b1002168084e0b579843be761c3e /tools/render-test/render.cpp | |
| parent | 8b16bbf64a082d30d496453f948f65605e58a014 (diff) | |
Fix atomic operations on RWBuffer (#593)
* Fix atomic operations on RWBuffer
An earlier change added support for passing true pointers to `__ref` parameters to fix the global `Interlocked*()` functions when applied to `groupshared` variables or `RWStructureBuffer<T>` elements.
That change didn't apply to `RWBuffer<T>` or `RWTexture2D<T>`, etc. because those types had so far only declared `get` and `set` accessors, but not any `ref` accessors (which return a pointer).
The main fixes here are:
* Add `ref` accessors to the subscript oeprations on the `RW*` resource types
* Adjust the logic for emitting calls to subscript accessors so that we don't get quite as eager about invoking a `ref` accessor, and instead try to invoke just a `get` or `set` accessor when these will suffice. This is important for Vulkan cross-compilation, where we don't yet support the semantics of our `ref` accessors.
* Add a test case for atomics on a `RWBuffer`
* Fix up `render-test` so that we can specify a format for a buffer resource, which allows us to use things other than `*StructuredBuffer` and `*ByteAddressBuffer`. The work there is probably not complete; I just did what I could to get the test working.
* A bunch of files got whitespace edits thanks to the fact that I'm using editorconfig and others on the project seemingly arent...
* fixup: remove ifdefed-out code
Diffstat (limited to 'tools/render-test/render.cpp')
| -rw-r--r-- | tools/render-test/render.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/tools/render-test/render.cpp b/tools/render-test/render.cpp index b22a41ca7..bfb7aeb94 100644 --- a/tools/render-test/render.cpp +++ b/tools/render-test/render.cpp @@ -6,7 +6,7 @@ namespace renderer_test { using namespace Slang; -/* static */const Resource::BindFlag::Enum Resource::s_requiredBinding[] = +/* static */const Resource::BindFlag::Enum Resource::s_requiredBinding[] = { BindFlag::VertexBuffer, // VertexBuffer BindFlag::IndexBuffer, // IndexBuffer @@ -19,7 +19,7 @@ using namespace Slang; BindFlag::PixelShaderResource, // PixelShaderResource BindFlag::NonPixelShaderResource, // NonPixelShaderResource BindFlag::Enum(BindFlag::PixelShaderResource | BindFlag::NonPixelShaderResource), // GenericRead -}; +}; /* static */void Resource::compileTimeAsserts() @@ -44,7 +44,7 @@ const Resource::DescBase& Resource::getDescBase() const /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! RendererUtil !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ -/* static */const uint8_t RendererUtil::s_formatSize[] = +/* static */const uint8_t RendererUtil::s_formatSize[] = { 0, // Unknown, @@ -55,6 +55,8 @@ const Resource::DescBase& Resource::getDescBase() const uint8_t(sizeof(uint32_t)), // RGBA_Unorm_UInt8, + uint8_t(sizeof(uint32_t)), // R_UInt32, + uint8_t(sizeof(float)), // D_Float32, uint8_t(sizeof(uint32_t)), // D_Unorm24_S8, }; @@ -151,7 +153,7 @@ int TextureResource::Size::calcMaxDimension(Type type) const case Resource::Type::Texture1D: return this->width; case Resource::Type::Texture3D: return std::max(std::max(this->width, this->height), this->depth); case Resource::Type::TextureCube: // fallthru - case Resource::Type::Texture2D: + case Resource::Type::Texture2D: { return std::max(this->width, this->height); } @@ -193,24 +195,24 @@ int TextureResource::Desc::calcNumSubResources() const switch (type) { - case Resource::Type::Texture1D: - case Resource::Type::Texture2D: + case Resource::Type::Texture1D: + case Resource::Type::Texture2D: { return numMipMaps * arrSize; } - case Resource::Type::Texture3D: + case Resource::Type::Texture3D: { // can't have arrays of 3d textures assert(this->arraySize <= 1); - return numMipMaps * this->size.depth; + return numMipMaps * this->size.depth; } - case Resource::Type::TextureCube: + case Resource::Type::TextureCube: { // There are 6 faces to a cubemap return numMipMaps * arrSize * 6; } default: return 0; - } + } } void TextureResource::Desc::fixSize() @@ -259,7 +261,7 @@ int TextureResource::Desc::calcEffectiveArraySize() const switch (type) { case Resource::Type::Texture1D: // fallthru - case Resource::Type::Texture2D: + case Resource::Type::Texture2D: { return arrSize; } @@ -273,7 +275,7 @@ void TextureResource::Desc::init(Type typeIn) { this->type = typeIn; this->size.init(); - + this->format = Format::Unknown; this->arraySize = 0; this->numMipLevels = 0; @@ -287,14 +289,14 @@ void TextureResource::Desc::init1D(Format formatIn, int widthIn, int numMipMapsI { this->type = Type::Texture1D; this->size.init(widthIn); - + this->format = format; this->arraySize = 0; this->numMipLevels = numMipMapsIn; this->sampleDesc.init(); this->bindFlags = 0; - this->cpuAccessFlags = 0; + this->cpuAccessFlags = 0; } void TextureResource::Desc::init2D(Type typeIn, Format formatIn, int widthIn, int heightIn, int numMipMapsIn) @@ -303,7 +305,7 @@ void TextureResource::Desc::init2D(Type typeIn, Format formatIn, int widthIn, in this->type = type; this->size.init(widthIn, heightIn); - + this->format = format; this->arraySize = 0; this->numMipLevels = numMipMapsIn; @@ -357,7 +359,7 @@ ProjectionStyle RendererUtil::getProjectionStyle(RendererType type) case ProjectionStyle::OpenGl: { static const float kIdentity[] = - { + { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, @@ -378,7 +380,7 @@ ProjectionStyle RendererUtil::getProjectionStyle(RendererType type) ::memcpy(projMatrix, kIdentity, sizeof(kIdentity)); break; } - default: + default: { assert(!"Not handled"); } |
