add Default miplevel and array layer

This commit is contained in:
Jeremy Nelson
2025-06-05 22:18:34 -07:00
committed by Jeremy Nelson
parent 2a04cee97f
commit bd61ab691c
3 changed files with 8 additions and 15 deletions
@@ -431,18 +431,6 @@ void WebGPUDriver::createDefaultRenderTargetR(Handle<HwRenderTarget> rth, int) {
void WebGPUDriver::createRenderTargetR(Handle<HwRenderTarget> rth, TargetBufferFlags targets,
uint32_t width, uint32_t height, uint8_t samples, uint8_t layerCount, MRT color,
TargetBufferInfo depth, TargetBufferInfo stencil) {
// The `targets` flags indicate which of the `color`, `depth`, `stencil` TargetBufferInfo
// are actually active for this render target.
// We'll pass all TargetBufferInfo to WGPURenderTarget; it will use them if their handles are valid.
// Ensure that textures intended for use as attachments were created with
// wgpu::TextureUsage::RenderAttachment. This check should ideally be in createTextureR
// or validated here if possible.
// The `layerCount` parameter might be for creating array textures that this RT targets.
// Individual attachments (color[i].layer, depth.layer, stencil.layer) specify which layer
// of an array texture to bind. For now, we assume textures are pre-configured.
constructHandle<WGPURenderTarget>(rth, width, height, samples, layerCount, color, depth, stencil);
}
@@ -638,7 +638,8 @@ WGPUTexture::WGPUTexture(SamplerType samplerType, uint8_t levels, TextureFormat
FILAMENT_CHECK_POSTCONDITION(mTexture)
<< "Failed to create texture for " << textureDescriptor.label;
mDefaultTextureView = makeTextureView(0, levels, 0, mArrayLayerCount, samplerType);
mDefaultTextureView = makeTextureView(mDefaultMipLevel, levels, mDefaultBaseArrayLayer,
mArrayLayerCount, samplerType);
}
WGPUTexture::WGPUTexture(WGPUTexture* src, uint8_t baseLevel, uint8_t levelCount) noexcept
@@ -977,7 +978,10 @@ wgpu::TextureAspect WGPUTexture::fToWGPUTextureViewAspect(TextureUsage const& fU
}
wgpu::TextureView WGPUTexture::getOrMakeTextureView(uint8_t mipLevel, uint32_t arrayLayer) const {
// TODO: just return mTextureView if redundant
//TODO: there's an optimization to be made here to return mDefaultTextureView.
// Problem: mDefaultTextureView is a view of the entire texture,
// but this function (and its callers) expects a single-slice view.
// Returning the whole texture view for a single-slice request seems wrong.
return makeTextureView(mipLevel, 1, arrayLayer, 1, mSamplerType);
}
+2 -1
View File
@@ -208,7 +208,8 @@ private:
size_t mBlockHeight;
SamplerType mSamplerType;
wgpu::TextureView mDefaultTextureView = nullptr;
uint32_t mDefaultMipLevel = 0;
uint32_t mDefaultBaseArrayLayer = 0;
[[nodiscard]] wgpu::TextureUsage fToWGPUTextureUsage(
filament::backend::TextureUsage const& fUsage);