Use IsSubset in more places.
This helper function makes the code easier to read because the name encodes the semantic of the operation compared to the bit-twiddling that it replaces. Bug: None Change-Id: Iab587e04a91cf60acf8920de1f20bb55f3ea3816 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31668 Reviewed-by: Stephen White <senorblanco@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
a701961ad3
commit
3317374395
|
@ -144,7 +144,7 @@ namespace dawn_native {
|
|||
return DAWN_VALIDATION_ERROR("Binding type cannot be dynamic.");
|
||||
}
|
||||
|
||||
if ((entry.visibility & allowedStages) != entry.visibility) {
|
||||
if (!IsSubset(entry.visibility, allowedStages)) {
|
||||
return DAWN_VALIDATION_ERROR("Binding type cannot be used with this visibility.");
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ namespace dawn_native {
|
|||
|
||||
const ityp::bitset<VertexBufferSlot, kMaxVertexBuffers>& requiredVertexBuffers =
|
||||
mLastRenderPipeline->GetVertexBufferSlotsUsed();
|
||||
if ((mVertexBufferSlotsUsed & requiredVertexBuffers) == requiredVertexBuffers) {
|
||||
if (IsSubset(requiredVertexBuffers, mVertexBufferSlotsUsed)) {
|
||||
mAspects.set(VALIDATION_ASPECT_VERTEX_BUFFERS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@ namespace dawn_native {
|
|||
return DAWN_VALIDATION_ERROR("Buffer missing usage for the pass");
|
||||
}
|
||||
|
||||
bool readOnly = (usage & kReadOnlyBufferUsages) == usage;
|
||||
bool readOnly = IsSubset(usage, kReadOnlyBufferUsages);
|
||||
bool singleUse = wgpu::HasZeroOrOneBits(usage);
|
||||
|
||||
if (pass.passType == PassType::Render && !readOnly && !singleUse) {
|
||||
|
@ -332,7 +332,7 @@ namespace dawn_native {
|
|||
// The usage variable for the whole texture is a fast path for texture usage tracking.
|
||||
// Because in most cases a texture (with or without subresources) is used as
|
||||
// single-write or multiple read, then we can skip iterating the subresources' usages.
|
||||
bool readOnly = (usage & kReadOnlyTextureUsages) == usage;
|
||||
bool readOnly = IsSubset(usage, kReadOnlyTextureUsages);
|
||||
bool singleUse = wgpu::HasZeroOrOneBits(usage);
|
||||
if (pass.passType != PassType::Render || readOnly || singleUse) {
|
||||
continue;
|
||||
|
@ -340,7 +340,7 @@ namespace dawn_native {
|
|||
// Inspect the subresources if the usage of the whole texture violates usage validation.
|
||||
// Every single subresource can only be used as single-write or multiple read.
|
||||
for (wgpu::TextureUsage subresourceUsage : textureUsage.subresourceUsages) {
|
||||
bool readOnly = (subresourceUsage & kReadOnlyTextureUsages) == subresourceUsage;
|
||||
bool readOnly = IsSubset(subresourceUsage, kReadOnlyTextureUsages);
|
||||
bool singleUse = wgpu::HasZeroOrOneBits(subresourceUsage);
|
||||
if (!readOnly && !singleUse) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
|
|
|
@ -332,7 +332,7 @@ namespace dawn_native {
|
|||
|
||||
const EntryPointMetadata& vertexMetadata =
|
||||
descriptor->vertexStage.module->GetEntryPoint(descriptor->vertexStage.entryPoint);
|
||||
if ((vertexMetadata.usedVertexAttributes & ~attributesSetMask).any()) {
|
||||
if (!IsSubset(vertexMetadata.usedVertexAttributes, attributesSetMask)) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"Pipeline vertex stage uses vertex buffers not in the vertex state");
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ namespace dawn_native {
|
|||
|
||||
// Check that the return texture view matches exactly what was given for this descriptor.
|
||||
ASSERT(view->GetTexture()->GetFormat().format == mFormat);
|
||||
ASSERT((view->GetTexture()->GetUsage() & mUsage) == mUsage);
|
||||
ASSERT(IsSubset(mUsage, view->GetTexture()->GetUsage()));
|
||||
ASSERT(view->GetLevelCount() == 1);
|
||||
ASSERT(view->GetLayerCount() == 1);
|
||||
ASSERT(view->GetDimension() == wgpu::TextureViewDimension::e2D);
|
||||
|
|
|
@ -192,7 +192,7 @@ namespace dawn_native {
|
|||
constexpr wgpu::TextureUsage kValidCompressedUsages = wgpu::TextureUsage::Sampled |
|
||||
wgpu::TextureUsage::CopySrc |
|
||||
wgpu::TextureUsage::CopyDst;
|
||||
if (format->isCompressed && (descriptor->usage & (~kValidCompressedUsages))) {
|
||||
if (format->isCompressed && !IsSubset(descriptor->usage, kValidCompressedUsages)) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"Compressed texture format is incompatible with the texture usage");
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
}
|
||||
|
||||
// We can skip transitions to already current usages.
|
||||
if ((mLastUsage & newUsage) == newUsage) {
|
||||
if (IsSubset(newUsage, mLastUsage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -650,7 +650,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;
|
||||
|
||||
if (lastState == D3D12_RESOURCE_STATE_COMMON) {
|
||||
if (newState == (newState & kD3D12PromotableReadOnlyStates)) {
|
||||
if (IsSubset(newState, kD3D12PromotableReadOnlyStates)) {
|
||||
// Implicit texture state decays can only occur when the texture was implicitly
|
||||
// transitioned to a read-only state. isValidToDecay is needed to differentiate
|
||||
// between resources that were implictly or explicitly transitioned to a
|
||||
|
|
|
@ -169,8 +169,7 @@ namespace dawn_native { namespace metal {
|
|||
ASSERT(HasOneBit(aspect));
|
||||
ASSERT(format.aspects & aspect);
|
||||
|
||||
constexpr Aspect kDepthStencil = Aspect::Depth | Aspect::Stencil;
|
||||
if ((format.aspects & kDepthStencil) == kDepthStencil) {
|
||||
if (IsSubset(Aspect::Depth | Aspect::Stencil, format.aspects)) {
|
||||
// We only provide a blit option if the format has both depth and stencil.
|
||||
// It is invalid to provide a blit option otherwise.
|
||||
switch (aspect) {
|
||||
|
|
|
@ -214,8 +214,8 @@ namespace dawn_native { namespace vulkan {
|
|||
VkBufferMemoryBarrier* barrier,
|
||||
VkPipelineStageFlags* srcStages,
|
||||
VkPipelineStageFlags* dstStages) {
|
||||
bool lastIncludesTarget = (mLastUsage & usage) == usage;
|
||||
bool lastReadOnly = (mLastUsage & kReadOnlyBufferUsages) == mLastUsage;
|
||||
bool lastIncludesTarget = IsSubset(usage, mLastUsage);
|
||||
bool lastReadOnly = IsSubset(mLastUsage, kReadOnlyBufferUsages);
|
||||
|
||||
// We can skip transitions to already current read-only usages.
|
||||
if (lastIncludesTarget && lastReadOnly) {
|
||||
|
|
|
@ -340,7 +340,7 @@ namespace dawn_native { namespace vulkan {
|
|||
VkImageUsageFlags targetUsages =
|
||||
VulkanImageUsage(GetUsage(), GetDevice()->GetValidInternalFormat(GetFormat()));
|
||||
VkImageUsageFlags supportedUsages = surfaceInfo.capabilities.supportedUsageFlags;
|
||||
if ((supportedUsages & targetUsages) != targetUsages) {
|
||||
if (!IsSubset(targetUsages, supportedUsages)) {
|
||||
config.needsBlit = true;
|
||||
} else {
|
||||
config.usage = targetUsages;
|
||||
|
|
|
@ -802,7 +802,7 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
bool Texture::CanReuseWithoutBarrier(wgpu::TextureUsage lastUsage, wgpu::TextureUsage usage) {
|
||||
// Reuse the texture directly and avoid encoding barriers when it isn't needed.
|
||||
bool lastReadOnly = (lastUsage & kReadOnlyTextureUsages) == lastUsage;
|
||||
bool lastReadOnly = IsSubset(lastUsage, kReadOnlyTextureUsages);
|
||||
if (lastReadOnly && lastUsage == usage && mLastExternalState == mExternalState) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -44,8 +44,7 @@ namespace dawn_native { namespace vulkan { namespace external_semaphore {
|
|||
VkFlags requiredFlags = VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT_KHR |
|
||||
VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT_KHR;
|
||||
mSupported =
|
||||
mSupported &&
|
||||
((semaphoreProperties.externalSemaphoreFeatures & requiredFlags) == requiredFlags);
|
||||
mSupported && IsSubset(requiredFlags, semaphoreProperties.externalSemaphoreFeatures);
|
||||
}
|
||||
|
||||
Service::~Service() = default;
|
||||
|
|
|
@ -44,8 +44,7 @@ namespace dawn_native { namespace vulkan { namespace external_semaphore {
|
|||
VkFlags requiredFlags = VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT_KHR |
|
||||
VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT_KHR;
|
||||
mSupported =
|
||||
mSupported &&
|
||||
((semaphoreProperties.externalSemaphoreFeatures & requiredFlags) == requiredFlags);
|
||||
mSupported && IsSubset(requiredFlags, semaphoreProperties.externalSemaphoreFeatures);
|
||||
}
|
||||
|
||||
Service::~Service() = default;
|
||||
|
|
Loading…
Reference in New Issue