mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 05:27:49 +00:00
Descriptorize Texture
This patch introduces texture descriptor for texture creation instead of texture builders. This patch also adds "arrayLayer" to texture descriptor and removes mDevice in TextureD3D12.
This commit is contained in:
committed by
Corentin Wallez
parent
75559bf1be
commit
425428f97b
@@ -48,13 +48,16 @@ void initBuffers() {
|
||||
}
|
||||
|
||||
void initTextures() {
|
||||
texture = device.CreateTextureBuilder()
|
||||
.SetDimension(dawn::TextureDimension::e2D)
|
||||
.SetExtent(1024, 1024, 1)
|
||||
.SetFormat(dawn::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetMipLevels(1)
|
||||
.SetAllowedUsage(dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Sampled)
|
||||
.GetResult();
|
||||
dawn::TextureDescriptor descriptor;
|
||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||
descriptor.width = 1024;
|
||||
descriptor.height = 1024;
|
||||
descriptor.depth = 1;
|
||||
descriptor.arrayLayer = 1;
|
||||
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||
descriptor.mipLevel = 1;
|
||||
descriptor.usage = dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Sampled;
|
||||
texture = device.CreateTexture(&descriptor);
|
||||
|
||||
dawn::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
|
||||
sampler = device.CreateSampler(&samplerDesc);
|
||||
|
||||
@@ -136,13 +136,16 @@ dawn::SwapChain GetSwapChain(const dawn::Device &device) {
|
||||
}
|
||||
|
||||
dawn::TextureView CreateDefaultDepthStencilView(const dawn::Device& device) {
|
||||
auto depthStencilTexture = device.CreateTextureBuilder()
|
||||
.SetDimension(dawn::TextureDimension::e2D)
|
||||
.SetExtent(640, 480, 1)
|
||||
.SetFormat(dawn::TextureFormat::D32FloatS8Uint)
|
||||
.SetMipLevels(1)
|
||||
.SetAllowedUsage(dawn::TextureUsageBit::OutputAttachment)
|
||||
.GetResult();
|
||||
dawn::TextureDescriptor descriptor;
|
||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||
descriptor.width = 640;
|
||||
descriptor.height = 480;
|
||||
descriptor.depth = 1;
|
||||
descriptor.arrayLayer = 1;
|
||||
descriptor.format = dawn::TextureFormat::D32FloatS8Uint;
|
||||
descriptor.mipLevel = 1;
|
||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment;
|
||||
auto depthStencilTexture = device.CreateTexture(&descriptor);
|
||||
return depthStencilTexture.CreateTextureViewBuilder()
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
@@ -382,13 +382,16 @@ namespace {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto oTexture = device.CreateTextureBuilder()
|
||||
.SetDimension(dawn::TextureDimension::e2D)
|
||||
.SetExtent(iImage.width, iImage.height, 1)
|
||||
.SetFormat(format)
|
||||
.SetMipLevels(1)
|
||||
.SetAllowedUsage(dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Sampled)
|
||||
.GetResult();
|
||||
dawn::TextureDescriptor descriptor;
|
||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||
descriptor.width = iImage.width;
|
||||
descriptor.height = iImage.height;
|
||||
descriptor.depth = 1;
|
||||
descriptor.arrayLayer = 1;
|
||||
descriptor.format = format;
|
||||
descriptor.mipLevel = 1;
|
||||
descriptor.usage = dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Sampled;
|
||||
auto oTexture = device.CreateTexture(&descriptor);
|
||||
// TODO: release this texture
|
||||
|
||||
const uint8_t* origData = iImage.image.data();
|
||||
|
||||
Reference in New Issue
Block a user