Rename GetAllowedUsage to GetUsage.

Resources used to have both a current and an allowed usage but the
concept of current usage has been removed so we can rename "allowed
usage" to "usage" to make the name match WebGPU's
WebGPUBufferDescriptor::usage and WebGPUTextureDescriptor::usage

Change-Id: I5190950bf7f7f5b86c92247ef0240fead9886268
This commit is contained in:
Corentin Wallez 2018-08-22 15:08:02 +02:00 committed by Corentin Wallez
parent d958b68cb2
commit 62c774391b
13 changed files with 29 additions and 32 deletions

View File

@ -119,7 +119,7 @@ namespace dawn_native {
return;
}
if (!(bufferViews[j]->GetBuffer()->GetAllowedUsage() & requiredBit)) {
if (!(bufferViews[j]->GetBuffer()->GetUsage() & requiredBit)) {
HandleError("Buffer needs to allow the correct usage bit");
return;
}
@ -165,8 +165,7 @@ namespace dawn_native {
return;
}
if (!(textureViews[j]->GetTexture()->GetAllowedUsage() &
dawn::TextureUsageBit::Sampled)) {
if (!(textureViews[j]->GetTexture()->GetUsage() & dawn::TextureUsageBit::Sampled)) {
HandleError("Texture needs to allow the sampled usage bit");
return;
}

View File

@ -25,7 +25,7 @@ namespace dawn_native {
// Buffer
BufferBase::BufferBase(BufferBuilder* builder)
: mDevice(builder->mDevice), mSize(builder->mSize), mAllowedUsage(builder->mAllowedUsage) {
: mDevice(builder->mDevice), mSize(builder->mSize), mUsage(builder->mAllowedUsage) {
}
BufferBase::~BufferBase() {
@ -47,8 +47,8 @@ namespace dawn_native {
return mSize;
}
dawn::BufferUsageBit BufferBase::GetAllowedUsage() const {
return mAllowedUsage;
dawn::BufferUsageBit BufferBase::GetUsage() const {
return mUsage;
}
void BufferBase::CallMapReadCallback(uint32_t serial,
@ -147,7 +147,7 @@ namespace dawn_native {
DAWN_RETURN_ERROR("Buffer subdata out of range");
}
if (!(mAllowedUsage & dawn::BufferUsageBit::TransferDst)) {
if (!(mUsage & dawn::BufferUsageBit::TransferDst)) {
DAWN_RETURN_ERROR("Buffer needs the transfer dst usage bit");
}
@ -166,7 +166,7 @@ namespace dawn_native {
DAWN_RETURN_ERROR("Buffer already mapped");
}
if (!(mAllowedUsage & requiredUsage)) {
if (!(mUsage & requiredUsage)) {
DAWN_RETURN_ERROR("Buffer needs the correct map usage bit");
}

View File

@ -38,7 +38,7 @@ namespace dawn_native {
~BufferBase();
uint32_t GetSize() const;
dawn::BufferUsageBit GetAllowedUsage() const;
dawn::BufferUsageBit GetUsage() const;
DeviceBase* GetDevice() const;
@ -75,7 +75,7 @@ namespace dawn_native {
DeviceBase* mDevice;
uint32_t mSize;
dawn::BufferUsageBit mAllowedUsage = dawn::BufferUsageBit::None;
dawn::BufferUsageBit mUsage = dawn::BufferUsageBit::None;
dawnBufferMapReadCallback mMapReadCallback = nullptr;
dawnBufferMapWriteCallback mMapWriteCallback = nullptr;
@ -91,7 +91,6 @@ namespace dawn_native {
// Dawn API
void SetAllowedUsage(dawn::BufferUsageBit usage);
void SetInitialUsage(dawn::BufferUsageBit usage);
void SetSize(uint32_t size);
private:
@ -101,7 +100,6 @@ namespace dawn_native {
uint32_t mSize;
dawn::BufferUsageBit mAllowedUsage = dawn::BufferUsageBit::None;
dawn::BufferUsageBit mCurrentUsage = dawn::BufferUsageBit::None;
int mPropertiesSet = 0;
};

View File

@ -111,7 +111,7 @@ namespace dawn_native {
MaybeError ValidateCanUseAs(BufferBase* buffer, dawn::BufferUsageBit usage) {
ASSERT(HasZeroOrOneBits(usage));
if (!(buffer->GetAllowedUsage() & usage)) {
if (!(buffer->GetUsage() & usage)) {
DAWN_RETURN_ERROR("buffer doesn't have the required usage.");
}
@ -120,7 +120,7 @@ namespace dawn_native {
MaybeError ValidateCanUseAs(TextureBase* texture, dawn::TextureUsageBit usage) {
ASSERT(HasZeroOrOneBits(usage));
if (!(texture->GetAllowedUsage() & usage)) {
if (!(texture->GetUsage() & usage)) {
DAWN_RETURN_ERROR("texture doesn't have the required usage.");
}
@ -176,7 +176,7 @@ namespace dawn_native {
BufferBase* buffer = it.first;
dawn::BufferUsageBit usage = it.second;
if (usage & ~buffer->GetAllowedUsage()) {
if (usage & ~buffer->GetUsage()) {
DAWN_RETURN_ERROR("Buffer missing usage for the pass");
}
@ -195,7 +195,7 @@ namespace dawn_native {
TextureBase* texture = it.first;
dawn::TextureUsageBit usage = it.second;
if (usage & ~texture->GetAllowedUsage()) {
if (usage & ~texture->GetUsage()) {
DAWN_RETURN_ERROR("Texture missing usage for the pass");
}

View File

@ -75,7 +75,7 @@ namespace dawn_native {
mHeight(builder->mHeight),
mDepth(builder->mDepth),
mNumMipLevels(builder->mNumMipLevels),
mAllowedUsage(builder->mAllowedUsage) {
mUsage(builder->mAllowedUsage) {
}
DeviceBase* TextureBase::GetDevice() const {
@ -100,8 +100,8 @@ namespace dawn_native {
uint32_t TextureBase::GetNumMipLevels() const {
return mNumMipLevels;
}
dawn::TextureUsageBit TextureBase::GetAllowedUsage() const {
return mAllowedUsage;
dawn::TextureUsageBit TextureBase::GetUsage() const {
return mUsage;
}
TextureViewBuilder* TextureBase::CreateTextureViewBuilder() {

View File

@ -46,7 +46,7 @@ namespace dawn_native {
uint32_t GetHeight() const;
uint32_t GetDepth() const;
uint32_t GetNumMipLevels() const;
dawn::TextureUsageBit GetAllowedUsage() const;
dawn::TextureUsageBit GetUsage() const;
DeviceBase* GetDevice() const;
// Dawn API
@ -59,7 +59,7 @@ namespace dawn_native {
dawn::TextureFormat mFormat;
uint32_t mWidth, mHeight, mDepth;
uint32_t mNumMipLevels;
dawn::TextureUsageBit mAllowedUsage = dawn::TextureUsageBit::None;
dawn::TextureUsageBit mUsage = dawn::TextureUsageBit::None;
};
class TextureBuilder : public Builder<TextureBase> {

View File

@ -79,9 +79,9 @@ namespace dawn_native { namespace d3d12 {
resourceDescriptor.SampleDesc.Count = 1;
resourceDescriptor.SampleDesc.Quality = 0;
resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
resourceDescriptor.Flags = D3D12ResourceFlags(GetAllowedUsage());
resourceDescriptor.Flags = D3D12ResourceFlags(GetUsage());
auto heapType = D3D12HeapType(GetAllowedUsage());
auto heapType = D3D12HeapType(GetUsage());
auto bufferUsage = D3D12_RESOURCE_STATE_COMMON;
// D3D12 requires buffers on the READBACK heap to have the D3D12_RESOURCE_STATE_COPY_DEST

View File

@ -120,7 +120,7 @@ namespace dawn_native { namespace d3d12 {
resourceDescriptor.SampleDesc.Count = 1;
resourceDescriptor.SampleDesc.Quality = 0;
resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
resourceDescriptor.Flags = D3D12ResourceFlags(GetAllowedUsage(), GetFormat());
resourceDescriptor.Flags = D3D12ResourceFlags(GetUsage(), GetFormat());
mResource = mDevice->GetResourceAllocator()->Allocate(
D3D12_HEAP_TYPE_DEFAULT, resourceDescriptor, D3D12_RESOURCE_STATE_COMMON);

View File

@ -21,7 +21,7 @@ namespace dawn_native { namespace metal {
Buffer::Buffer(BufferBuilder* builder) : BufferBase(builder) {
MTLResourceOptions storageMode;
if (GetAllowedUsage() & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) {
if (GetUsage() & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) {
storageMode = MTLResourceStorageModeShared;
} else {
storageMode = MTLResourceStorageModePrivate;

View File

@ -70,7 +70,7 @@ namespace dawn_native { namespace metal {
auto desc = [MTLTextureDescriptor new];
[desc autorelease];
desc.textureType = MetalTextureType(GetDimension());
desc.usage = MetalTextureUsage(GetAllowedUsage());
desc.usage = MetalTextureUsage(GetUsage());
desc.pixelFormat = MetalPixelFormat(GetFormat());
desc.width = GetWidth();
desc.height = GetHeight();

View File

@ -121,7 +121,7 @@ namespace dawn_native { namespace null {
};
Buffer::Buffer(BufferBuilder* builder) : BufferBase(builder) {
if (GetAllowedUsage() & (dawn::BufferUsageBit::TransferDst | dawn::BufferUsageBit::MapRead |
if (GetUsage() & (dawn::BufferUsageBit::TransferDst | dawn::BufferUsageBit::MapRead |
dawn::BufferUsageBit::MapWrite)) {
mBackingData = std::unique_ptr<char[]>(new char[GetSize()]);
}

View File

@ -111,7 +111,7 @@ namespace dawn_native { namespace vulkan {
createInfo.pNext = nullptr;
createInfo.flags = 0;
createInfo.size = GetSize();
createInfo.usage = VulkanBufferUsage(GetAllowedUsage());
createInfo.usage = VulkanBufferUsage(GetUsage());
createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
createInfo.queueFamilyIndexCount = 0;
createInfo.pQueueFamilyIndices = 0;
@ -124,8 +124,8 @@ namespace dawn_native { namespace vulkan {
VkMemoryRequirements requirements;
device->fn.GetBufferMemoryRequirements(device->GetVkDevice(), mHandle, &requirements);
bool requestMappable = (GetAllowedUsage() & (dawn::BufferUsageBit::MapRead |
dawn::BufferUsageBit::MapWrite)) != 0;
bool requestMappable =
(GetUsage() & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) != 0;
if (!device->GetMemoryAllocator()->Allocate(requirements, requestMappable,
&mMemoryAllocation)) {
ASSERT(false);

View File

@ -252,7 +252,7 @@ namespace dawn_native { namespace vulkan {
createInfo.arrayLayers = 1;
createInfo.samples = VK_SAMPLE_COUNT_1_BIT;
createInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
createInfo.usage = VulkanImageUsage(GetAllowedUsage(), GetFormat());
createInfo.usage = VulkanImageUsage(GetUsage(), GetFormat());
createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
createInfo.queueFamilyIndexCount = 0;
createInfo.pQueueFamilyIndices = nullptr;