remove initialUsage from SwapChain::Configure

This commit is contained in:
Kai Ninomiya
2017-08-30 16:53:27 -07:00
committed by Kai Ninomiya
parent 8e587e8b42
commit 921fb5e1ce
21 changed files with 22 additions and 50 deletions

View File

@@ -156,7 +156,7 @@ namespace utils {
commandQueue = backend::d3d12::GetCommandQueue(backendDevice);
}
nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit allowedUsage, nxtTextureUsageBit initialUsage,
nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit allowedUsage,
uint32_t width, uint32_t height) {
if (format != NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM) {
return "unsupported format";
@@ -199,25 +199,6 @@ namespace utils {
lastSerialRenderTargetWasUsed[n] = initialSerial;
}
renderTargetResourceState = D3D12ResourceState(initialUsage);
// Transition the first frame. Resources are initially created in PRESENT state
if (renderTargetResourceState != D3D12_RESOURCE_STATE_PRESENT) {
ComPtr<ID3D12GraphicsCommandList> commandList = {};
backend::d3d12::OpenCommandList(backendDevice, &commandList);
D3D12_RESOURCE_BARRIER resourceBarrier;
resourceBarrier.Transition.pResource = renderTargetResources[renderTargetIndex].Get();
resourceBarrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
resourceBarrier.Transition.StateAfter = renderTargetResourceState;
resourceBarrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
resourceBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
resourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
commandList->ResourceBarrier(1, &resourceBarrier);
ASSERT_SUCCESS(commandList->Close());
backend::d3d12::ExecuteCommandLists(backendDevice, { commandList.Get() });
}
return NXT_SWAP_CHAIN_NO_ERROR;
}

View File

@@ -68,7 +68,7 @@ namespace utils {
commandQueue = [mtlDevice newCommandQueue];
}
nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit, nxtTextureUsageBit,
nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit,
uint32_t width, uint32_t height) {
if (format != NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM) {
return "unsupported format";

View File

@@ -69,7 +69,7 @@ namespace utils {
GL_TEXTURE_2D, backTexture, 0);
}
nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit, nxtTextureUsageBit,
nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit,
uint32_t width, uint32_t height) {
if (format != NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM) {
return "unsupported format";

View File

@@ -28,9 +28,8 @@ namespace utils {
impl.Destroy = [](void* userData) {
delete reinterpret_cast<TImpl*>(userData);
};
impl.Configure = [](void* userData, nxtTextureFormat format, nxtTextureUsageBit allowedUsage, nxtTextureUsageBit initialUsage, uint32_t width, uint32_t height) {
return reinterpret_cast<TImpl*>(userData)->Configure(
format, allowedUsage, initialUsage, width, height);
impl.Configure = [](void* userData, nxtTextureFormat format, nxtTextureUsageBit allowedUsage, uint32_t width, uint32_t height) {
return reinterpret_cast<TImpl*>(userData)->Configure(format, allowedUsage, width, height);
};
impl.GetNextTexture = [](void* userData, nxtSwapChainNextTexture* nextTexture) {
return reinterpret_cast<TImpl*>(userData)->GetNextTexture(