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

@@ -37,14 +37,14 @@ void initBuffers() {
static const uint32_t indexData[3] = {
0, 1, 2,
};
indexBuffer = utils::CreateFrozenBufferFromData(device, indexData, sizeof(indexData), nxt::BufferUsageBit::Index);
indexBuffer = utils::CreateBufferFromData(device, indexData, sizeof(indexData), nxt::BufferUsageBit::Index);
static const float vertexData[12] = {
0.0f, 0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, 0.0f, 1.0f,
0.5f, -0.5f, 0.0f, 1.0f,
};
vertexBuffer = utils::CreateFrozenBufferFromData(device, vertexData, sizeof(vertexData), nxt::BufferUsageBit::Vertex);
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData), nxt::BufferUsageBit::Vertex);
}
void initTextures() {
@@ -66,14 +66,12 @@ void initTextures() {
}
nxt::Buffer stagingBuffer = utils::CreateFrozenBufferFromData(device, data.data(), static_cast<uint32_t>(data.size()), nxt::BufferUsageBit::TransferSrc);
nxt::Buffer stagingBuffer = utils::CreateBufferFromData(device, data.data(), static_cast<uint32_t>(data.size()), nxt::BufferUsageBit::TransferSrc);
nxt::CommandBuffer copy = device.CreateCommandBufferBuilder()
.TransitionTextureUsage(texture, nxt::TextureUsageBit::TransferDst)
.CopyBufferToTexture(stagingBuffer, 0, 0, texture, 0, 0, 0, 1024, 1024, 1, 0)
.GetResult();
queue.Submit(1, &copy);
texture.FreezeUsage(nxt::TextureUsageBit::Sampled);
}
void init() {
@@ -162,7 +160,6 @@ void frame() {
.GetResult();
queue.Submit(1, &commands);
backbuffer.TransitionUsage(nxt::TextureUsageBit::Present);
swapchain.Present(backbuffer);
DoFlush();
}