Remove explicit usage transition from the API and validation

This removes the following for both Buffer and Texture:
 - The builder's SetInitialUsage
 - The object's FreezeUsage and TransitionUsage methods
 - The CommandBuffer Transition<Object>Usage methods

All samples and tests are simplified as a result. This also obsoletes
the UsageValidationTest which is removed.

Some validation was dependent on "current usage" and hasn't been
reintroduced for implicit transitions yet:
 - Buffers can be used while mapped
 - Swapchain textures can be used after they have been presented.

Validation for these will involve collecting all the resources used by a
command buffer and will be done in a follow-up patch.
This commit is contained in:
Corentin Wallez
2018-07-09 15:15:07 +02:00
committed by Corentin Wallez
parent d2312e8138
commit d8c068fb4f
67 changed files with 143 additions and 1012 deletions

View File

@@ -97,17 +97,15 @@ namespace utils {
return builder.GetResult();
}
nxt::Buffer CreateFrozenBufferFromData(const nxt::Device& device,
const void* data,
uint32_t size,
nxt::BufferUsageBit usage) {
nxt::Buffer CreateBufferFromData(const nxt::Device& device,
const void* data,
uint32_t size,
nxt::BufferUsageBit usage) {
nxt::Buffer buffer = device.CreateBufferBuilder()
.SetAllowedUsage(nxt::BufferUsageBit::TransferDst | usage)
.SetInitialUsage(nxt::BufferUsageBit::TransferDst)
.SetSize(size)
.GetResult();
buffer.SetSubData(0, size, reinterpret_cast<const uint8_t*>(data));
buffer.FreezeUsage(usage);
return buffer;
}
@@ -126,7 +124,6 @@ namespace utils {
.SetMipLevels(1)
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment |
nxt::TextureUsageBit::TransferSrc)
.SetInitialUsage(nxt::TextureUsageBit::OutputAttachment)
.GetResult();
nxt::TextureView colorView = result.color.CreateTextureViewBuilder().GetResult();

View File

@@ -24,17 +24,16 @@ namespace utils {
nxt::ShaderModule CreateShaderModule(const nxt::Device& device,
nxt::ShaderStage stage,
const char* source);
nxt::Buffer CreateFrozenBufferFromData(const nxt::Device& device,
const void* data,
uint32_t size,
nxt::BufferUsageBit usage);
nxt::Buffer CreateBufferFromData(const nxt::Device& device,
const void* data,
uint32_t size,
nxt::BufferUsageBit usage);
template <typename T>
nxt::Buffer CreateFrozenBufferFromData(const nxt::Device& device,
nxt::BufferUsageBit usage,
std::initializer_list<T> data) {
return CreateFrozenBufferFromData(device, data.begin(), uint32_t(sizeof(T) * data.size()),
usage);
nxt::Buffer CreateBufferFromData(const nxt::Device& device,
nxt::BufferUsageBit usage,
std::initializer_list<T> data) {
return CreateBufferFromData(device, data.begin(), uint32_t(sizeof(T) * data.size()), usage);
}
struct BasicRenderPass {