fix samplerType check
This commit is contained in:
committed by
Jeremy Nelson
parent
56b8bf5b4b
commit
5ae7760752
@@ -813,9 +813,9 @@ void WebGPUDriver::beginRenderPass(Handle<HwRenderTarget> rth, RenderPassParams
|
||||
<< "Color attachment " << i << " requests layer "
|
||||
<< colorInfos[i].layer << " but render target has only "
|
||||
<< renderTarget->getLayerCount() << ".";
|
||||
uint8_t mipLevel = colorInfos[i].level;
|
||||
uint32_t arrayLayer = colorInfos[i].layer;
|
||||
customColorViews[customColorViewCount++] = hwTexture->getTextureView(mipLevel, arrayLayer);
|
||||
const uint8_t mipLevel = colorInfos[i].level;
|
||||
const uint32_t arrayLayer = colorInfos[i].layer;
|
||||
customColorViews[customColorViewCount++] = hwTexture->getOrMakeTextureView(mipLevel, arrayLayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -827,9 +827,9 @@ void WebGPUDriver::beginRenderPass(Handle<HwRenderTarget> rth, RenderPassParams
|
||||
<< "but render target has only " << renderTarget->getLayerCount() << ".";
|
||||
auto* hwTexture = handleCast<WGPUTexture>(depthInfo.handle);
|
||||
if (hwTexture) {
|
||||
uint8_t depthMipLevel = depthInfo.level;
|
||||
uint32_t depthArrayLayer = depthInfo.layer;
|
||||
customDepthView = hwTexture->getTextureView(depthMipLevel, depthArrayLayer);
|
||||
const uint8_t depthMipLevel = depthInfo.level;
|
||||
const uint32_t depthArrayLayer = depthInfo.layer;
|
||||
customDepthView = hwTexture->getOrMakeTextureView(depthMipLevel,depthArrayLayer);
|
||||
customDepthFormat = hwTexture->getFormat();
|
||||
}
|
||||
}
|
||||
@@ -843,9 +843,9 @@ void WebGPUDriver::beginRenderPass(Handle<HwRenderTarget> rth, RenderPassParams
|
||||
<< "Stencil attachment requests layer " << stencilInfo.layer
|
||||
<< " but render target has only " << renderTarget->getLayerCount()
|
||||
<< " layers.";
|
||||
uint8_t stencilMipLevel = stencilInfo.level;
|
||||
uint32_t stencilArrayLayer = stencilInfo.layer;
|
||||
customStencilView = hwTexture->getTextureView(stencilMipLevel, stencilArrayLayer);
|
||||
const uint8_t stencilMipLevel = stencilInfo.level;
|
||||
const uint32_t stencilArrayLayer = stencilInfo.layer;
|
||||
customStencilView = hwTexture->getOrMakeTextureView(stencilMipLevel,stencilArrayLayer );
|
||||
customStencilFormat = hwTexture->getFormat();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -600,7 +600,7 @@ WGPUTexture::WGPUTexture(SamplerType samplerType, uint8_t levels, TextureFormat
|
||||
wgpu::TextureDescriptor textureDescriptor{
|
||||
.label = getUserTextureLabel(samplerType),
|
||||
.usage = mUsage,
|
||||
.dimension = target == SamplerType::SAMPLER_3D ? wgpu::TextureDimension::e3D
|
||||
.dimension = samplerType == SamplerType::SAMPLER_3D ? wgpu::TextureDimension::e3D
|
||||
: wgpu::TextureDimension::e2D,
|
||||
.size = { .width = width, .height = height, .depthOrArrayLayers = depth },
|
||||
.format = mFormat,
|
||||
@@ -641,16 +641,15 @@ WGPUTexture::WGPUTexture(SamplerType samplerType, uint8_t levels, TextureFormat
|
||||
mTextureView = makeTextureView(0, levels, 0, mArrayLayerCount, samplerType);
|
||||
}
|
||||
|
||||
WGPUTexture::WGPUTexture(WGPUTexture* src, uint8_t baseLevel, uint8_t levelCount) noexcept {
|
||||
mTexture = src->mTexture;
|
||||
mAspect = src->mAspect;
|
||||
mBlockWidth = src->mBlockWidth;
|
||||
mBlockHeight = src->mBlockHeight;
|
||||
mArrayLayerCount = src->mArrayLayerCount;
|
||||
mSamplerType = src->mSamplerType;
|
||||
|
||||
mTextureView = makeTextureView(baseLevel, levelCount, 0, src->mArrayLayerCount, mSamplerType);
|
||||
}
|
||||
WGPUTexture::WGPUTexture(WGPUTexture* src, uint8_t baseLevel, uint8_t levelCount) noexcept :
|
||||
mTexture(src->mTexture),
|
||||
mAspect(src->mAspect),
|
||||
mArrayLayerCount(src->mArrayLayerCount),
|
||||
mBlockWidth(src->mBlockWidth),
|
||||
mBlockHeight(src->mBlockHeight),
|
||||
mSamplerType(src->mSamplerType),
|
||||
mTextureView(makeTextureView(baseLevel, levelCount, 0, src->mArrayLayerCount, mSamplerType))
|
||||
{}
|
||||
|
||||
wgpu::TextureUsage WGPUTexture::fToWGPUTextureUsage(TextureUsage const& fUsage) {
|
||||
wgpu::TextureUsage retUsage = wgpu::TextureUsage::None;
|
||||
@@ -977,7 +976,9 @@ wgpu::TextureAspect WGPUTexture::fToWGPUTextureViewAspect(TextureUsage const& fU
|
||||
return wgpu::TextureAspect::All;
|
||||
}
|
||||
|
||||
wgpu::TextureView WGPUTexture::getTextureView(uint8_t mipLevel, uint32_t arrayLayer) const {
|
||||
wgpu::TextureView WGPUTexture::getOrMakeTextureView(uint8_t mipLevel, uint32_t arrayLayer) const {
|
||||
// TODO: just return mTextureView if redundant
|
||||
|
||||
return makeTextureView(mipLevel, 1, arrayLayer, 1, mSamplerType);
|
||||
}
|
||||
|
||||
@@ -1027,7 +1028,7 @@ WGPURenderTarget::WGPURenderTarget(uint32_t width, uint32_t height, uint8_t samp
|
||||
const Attachment& depthAttachmentInfo,
|
||||
const Attachment& stencilAttachmentInfo)
|
||||
: HwRenderTarget(width, height),
|
||||
defaultRenderTarget(false),
|
||||
mDefaultRenderTarget(false),
|
||||
mSamples(samples),
|
||||
mLayerCount(layerCount),
|
||||
mColorAttachments(colorAttachmentsMRT),
|
||||
@@ -1066,7 +1067,7 @@ void WGPURenderTarget::setUpRenderPassAttachments(wgpu::RenderPassDescriptor& de
|
||||
mColorAttachmentDescriptors.clear();
|
||||
mHasDepthStencilAttachment = false;
|
||||
|
||||
if (defaultRenderTarget) {
|
||||
if (mDefaultRenderTarget) {
|
||||
assert_invariant(defaultColorTextureView);
|
||||
mColorAttachmentDescriptors.push_back({ .view = defaultColorTextureView,
|
||||
.resolveTarget = nullptr,
|
||||
|
||||
@@ -181,16 +181,13 @@ public:
|
||||
size_t getBlockWidth() const { return mBlockWidth; }
|
||||
size_t getBlockHeight() const { return mBlockHeight; }
|
||||
|
||||
|
||||
[[nodiscard]] const wgpu::Texture& getTexture() const { return mTexture; }
|
||||
|
||||
[[nodiscard]] wgpu::TextureView getTextureView() const {return mTextureView;}
|
||||
[[nodiscard]] wgpu::TextureView getTextureView(uint8_t mipLevel, uint32_t arrayLayer) const;
|
||||
[[nodiscard]] wgpu::TextureView getOrMakeTextureView(uint8_t mipLevel, uint32_t arrayLayer) const;
|
||||
|
||||
[[nodiscard]] wgpu::TextureFormat getFormat() const { return mFormat; }
|
||||
[[nodiscard]] uint32_t getArrayLayerCount() const { return mArrayLayerCount; }
|
||||
[[nodiscard]] filament::backend::SamplerType getSamplerType() const { return mSamplerType; }
|
||||
|
||||
|
||||
static wgpu::TextureFormat fToWGPUTextureFormat(
|
||||
filament::backend::TextureFormat const& fFormat);
|
||||
@@ -203,7 +200,6 @@ private:
|
||||
// along with a sampler Current plan: Inherit the sampler and Texture to always exist (It is a
|
||||
// ref counted pointer) when making views. View is optional
|
||||
wgpu::Texture mTexture = nullptr;
|
||||
wgpu::TextureView mTextureView = nullptr;
|
||||
wgpu::TextureFormat mFormat = wgpu::TextureFormat::Undefined;
|
||||
wgpu::TextureAspect mAspect = wgpu::TextureAspect::Undefined;
|
||||
wgpu::TextureUsage mUsage = wgpu::TextureUsage::None;
|
||||
@@ -211,12 +207,14 @@ private:
|
||||
size_t mBlockWidth;
|
||||
size_t mBlockHeight;
|
||||
SamplerType mSamplerType;
|
||||
wgpu::TextureView mTextureView = nullptr;
|
||||
|
||||
wgpu::TextureUsage fToWGPUTextureUsage(filament::backend::TextureUsage const& fUsage);
|
||||
|
||||
[[nodiscard]] wgpu::TextureView makeTextureView(const uint8_t& baseLevel, const uint8_t& levelCount,
|
||||
const uint32_t& baseArrayLayer, const uint32_t& arrayLayerCount,
|
||||
SamplerType samplerType) const noexcept;
|
||||
[[nodiscard]] wgpu::TextureUsage fToWGPUTextureUsage(filament::backend::TextureUsage const& fUsage);
|
||||
|
||||
[[nodiscard]] wgpu::TextureView makeTextureView(const uint8_t& baseLevel,
|
||||
const uint8_t& levelCount, const uint32_t& baseArrayLayer,
|
||||
const uint32_t& arrayLayerCount, SamplerType samplerType) const noexcept;
|
||||
};
|
||||
|
||||
struct WGPURenderPrimitive : public HwRenderPrimitive {
|
||||
@@ -237,7 +235,7 @@ public:
|
||||
// Default constructor for the default render target
|
||||
WGPURenderTarget()
|
||||
: HwRenderTarget(0, 0),
|
||||
defaultRenderTarget(true),
|
||||
mDefaultRenderTarget(true),
|
||||
mSamples(1) {}
|
||||
|
||||
// Updated signature: takes resolved views for custom RTs, and default views for default RT
|
||||
@@ -255,9 +253,9 @@ public:
|
||||
wgpu::TextureFormat customDepthFormat,
|
||||
wgpu::TextureFormat customStencilFormat);
|
||||
|
||||
bool isDefaultRenderTarget() const { return defaultRenderTarget; }
|
||||
uint8_t getSamples() const { return mSamples; }
|
||||
uint8_t getLayerCount() const { return mLayerCount; }
|
||||
bool isDefaultRenderTarget() const { return mDefaultRenderTarget; }
|
||||
[[nodiscard]] uint8_t getSamples() const { return mSamples; }
|
||||
[[nodiscard]] uint8_t getLayerCount() const { return mLayerCount; }
|
||||
|
||||
// Accessors for the driver to get stored attachment info
|
||||
const MRT& getColorAttachmentInfos() const { return mColorAttachments; }
|
||||
@@ -269,7 +267,7 @@ public:
|
||||
static wgpu::StoreOp getStoreOperation(const RenderPassParams& params, TargetBufferFlags buffer);
|
||||
|
||||
private:
|
||||
bool defaultRenderTarget = false;
|
||||
bool mDefaultRenderTarget = false;
|
||||
uint8_t mSamples = 1;
|
||||
uint8_t mLayerCount = 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user