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:
parent
d958b68cb2
commit
62c774391b
|
@ -119,7 +119,7 @@ namespace dawn_native {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(bufferViews[j]->GetBuffer()->GetAllowedUsage() & requiredBit)) {
|
if (!(bufferViews[j]->GetBuffer()->GetUsage() & requiredBit)) {
|
||||||
HandleError("Buffer needs to allow the correct usage bit");
|
HandleError("Buffer needs to allow the correct usage bit");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -165,8 +165,7 @@ namespace dawn_native {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(textureViews[j]->GetTexture()->GetAllowedUsage() &
|
if (!(textureViews[j]->GetTexture()->GetUsage() & dawn::TextureUsageBit::Sampled)) {
|
||||||
dawn::TextureUsageBit::Sampled)) {
|
|
||||||
HandleError("Texture needs to allow the sampled usage bit");
|
HandleError("Texture needs to allow the sampled usage bit");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace dawn_native {
|
||||||
// Buffer
|
// Buffer
|
||||||
|
|
||||||
BufferBase::BufferBase(BufferBuilder* builder)
|
BufferBase::BufferBase(BufferBuilder* builder)
|
||||||
: mDevice(builder->mDevice), mSize(builder->mSize), mAllowedUsage(builder->mAllowedUsage) {
|
: mDevice(builder->mDevice), mSize(builder->mSize), mUsage(builder->mAllowedUsage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferBase::~BufferBase() {
|
BufferBase::~BufferBase() {
|
||||||
|
@ -47,8 +47,8 @@ namespace dawn_native {
|
||||||
return mSize;
|
return mSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::BufferUsageBit BufferBase::GetAllowedUsage() const {
|
dawn::BufferUsageBit BufferBase::GetUsage() const {
|
||||||
return mAllowedUsage;
|
return mUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBase::CallMapReadCallback(uint32_t serial,
|
void BufferBase::CallMapReadCallback(uint32_t serial,
|
||||||
|
@ -147,7 +147,7 @@ namespace dawn_native {
|
||||||
DAWN_RETURN_ERROR("Buffer subdata out of range");
|
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");
|
DAWN_RETURN_ERROR("Buffer needs the transfer dst usage bit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ namespace dawn_native {
|
||||||
DAWN_RETURN_ERROR("Buffer already mapped");
|
DAWN_RETURN_ERROR("Buffer already mapped");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(mAllowedUsage & requiredUsage)) {
|
if (!(mUsage & requiredUsage)) {
|
||||||
DAWN_RETURN_ERROR("Buffer needs the correct map usage bit");
|
DAWN_RETURN_ERROR("Buffer needs the correct map usage bit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace dawn_native {
|
||||||
~BufferBase();
|
~BufferBase();
|
||||||
|
|
||||||
uint32_t GetSize() const;
|
uint32_t GetSize() const;
|
||||||
dawn::BufferUsageBit GetAllowedUsage() const;
|
dawn::BufferUsageBit GetUsage() const;
|
||||||
|
|
||||||
DeviceBase* GetDevice() const;
|
DeviceBase* GetDevice() const;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
DeviceBase* mDevice;
|
DeviceBase* mDevice;
|
||||||
uint32_t mSize;
|
uint32_t mSize;
|
||||||
dawn::BufferUsageBit mAllowedUsage = dawn::BufferUsageBit::None;
|
dawn::BufferUsageBit mUsage = dawn::BufferUsageBit::None;
|
||||||
|
|
||||||
dawnBufferMapReadCallback mMapReadCallback = nullptr;
|
dawnBufferMapReadCallback mMapReadCallback = nullptr;
|
||||||
dawnBufferMapWriteCallback mMapWriteCallback = nullptr;
|
dawnBufferMapWriteCallback mMapWriteCallback = nullptr;
|
||||||
|
@ -91,7 +91,6 @@ namespace dawn_native {
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void SetAllowedUsage(dawn::BufferUsageBit usage);
|
void SetAllowedUsage(dawn::BufferUsageBit usage);
|
||||||
void SetInitialUsage(dawn::BufferUsageBit usage);
|
|
||||||
void SetSize(uint32_t size);
|
void SetSize(uint32_t size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -101,7 +100,6 @@ namespace dawn_native {
|
||||||
|
|
||||||
uint32_t mSize;
|
uint32_t mSize;
|
||||||
dawn::BufferUsageBit mAllowedUsage = dawn::BufferUsageBit::None;
|
dawn::BufferUsageBit mAllowedUsage = dawn::BufferUsageBit::None;
|
||||||
dawn::BufferUsageBit mCurrentUsage = dawn::BufferUsageBit::None;
|
|
||||||
int mPropertiesSet = 0;
|
int mPropertiesSet = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
MaybeError ValidateCanUseAs(BufferBase* buffer, dawn::BufferUsageBit usage) {
|
MaybeError ValidateCanUseAs(BufferBase* buffer, dawn::BufferUsageBit usage) {
|
||||||
ASSERT(HasZeroOrOneBits(usage));
|
ASSERT(HasZeroOrOneBits(usage));
|
||||||
if (!(buffer->GetAllowedUsage() & usage)) {
|
if (!(buffer->GetUsage() & usage)) {
|
||||||
DAWN_RETURN_ERROR("buffer doesn't have the required 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) {
|
MaybeError ValidateCanUseAs(TextureBase* texture, dawn::TextureUsageBit usage) {
|
||||||
ASSERT(HasZeroOrOneBits(usage));
|
ASSERT(HasZeroOrOneBits(usage));
|
||||||
if (!(texture->GetAllowedUsage() & usage)) {
|
if (!(texture->GetUsage() & usage)) {
|
||||||
DAWN_RETURN_ERROR("texture doesn't have the required usage.");
|
DAWN_RETURN_ERROR("texture doesn't have the required usage.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ namespace dawn_native {
|
||||||
BufferBase* buffer = it.first;
|
BufferBase* buffer = it.first;
|
||||||
dawn::BufferUsageBit usage = it.second;
|
dawn::BufferUsageBit usage = it.second;
|
||||||
|
|
||||||
if (usage & ~buffer->GetAllowedUsage()) {
|
if (usage & ~buffer->GetUsage()) {
|
||||||
DAWN_RETURN_ERROR("Buffer missing usage for the pass");
|
DAWN_RETURN_ERROR("Buffer missing usage for the pass");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ namespace dawn_native {
|
||||||
TextureBase* texture = it.first;
|
TextureBase* texture = it.first;
|
||||||
dawn::TextureUsageBit usage = it.second;
|
dawn::TextureUsageBit usage = it.second;
|
||||||
|
|
||||||
if (usage & ~texture->GetAllowedUsage()) {
|
if (usage & ~texture->GetUsage()) {
|
||||||
DAWN_RETURN_ERROR("Texture missing usage for the pass");
|
DAWN_RETURN_ERROR("Texture missing usage for the pass");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ namespace dawn_native {
|
||||||
mHeight(builder->mHeight),
|
mHeight(builder->mHeight),
|
||||||
mDepth(builder->mDepth),
|
mDepth(builder->mDepth),
|
||||||
mNumMipLevels(builder->mNumMipLevels),
|
mNumMipLevels(builder->mNumMipLevels),
|
||||||
mAllowedUsage(builder->mAllowedUsage) {
|
mUsage(builder->mAllowedUsage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceBase* TextureBase::GetDevice() const {
|
DeviceBase* TextureBase::GetDevice() const {
|
||||||
|
@ -100,8 +100,8 @@ namespace dawn_native {
|
||||||
uint32_t TextureBase::GetNumMipLevels() const {
|
uint32_t TextureBase::GetNumMipLevels() const {
|
||||||
return mNumMipLevels;
|
return mNumMipLevels;
|
||||||
}
|
}
|
||||||
dawn::TextureUsageBit TextureBase::GetAllowedUsage() const {
|
dawn::TextureUsageBit TextureBase::GetUsage() const {
|
||||||
return mAllowedUsage;
|
return mUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureViewBuilder* TextureBase::CreateTextureViewBuilder() {
|
TextureViewBuilder* TextureBase::CreateTextureViewBuilder() {
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace dawn_native {
|
||||||
uint32_t GetHeight() const;
|
uint32_t GetHeight() const;
|
||||||
uint32_t GetDepth() const;
|
uint32_t GetDepth() const;
|
||||||
uint32_t GetNumMipLevels() const;
|
uint32_t GetNumMipLevels() const;
|
||||||
dawn::TextureUsageBit GetAllowedUsage() const;
|
dawn::TextureUsageBit GetUsage() const;
|
||||||
DeviceBase* GetDevice() const;
|
DeviceBase* GetDevice() const;
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
|
@ -59,7 +59,7 @@ namespace dawn_native {
|
||||||
dawn::TextureFormat mFormat;
|
dawn::TextureFormat mFormat;
|
||||||
uint32_t mWidth, mHeight, mDepth;
|
uint32_t mWidth, mHeight, mDepth;
|
||||||
uint32_t mNumMipLevels;
|
uint32_t mNumMipLevels;
|
||||||
dawn::TextureUsageBit mAllowedUsage = dawn::TextureUsageBit::None;
|
dawn::TextureUsageBit mUsage = dawn::TextureUsageBit::None;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextureBuilder : public Builder<TextureBase> {
|
class TextureBuilder : public Builder<TextureBase> {
|
||||||
|
|
|
@ -79,9 +79,9 @@ namespace dawn_native { namespace d3d12 {
|
||||||
resourceDescriptor.SampleDesc.Count = 1;
|
resourceDescriptor.SampleDesc.Count = 1;
|
||||||
resourceDescriptor.SampleDesc.Quality = 0;
|
resourceDescriptor.SampleDesc.Quality = 0;
|
||||||
resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
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;
|
auto bufferUsage = D3D12_RESOURCE_STATE_COMMON;
|
||||||
|
|
||||||
// D3D12 requires buffers on the READBACK heap to have the D3D12_RESOURCE_STATE_COPY_DEST
|
// D3D12 requires buffers on the READBACK heap to have the D3D12_RESOURCE_STATE_COPY_DEST
|
||||||
|
|
|
@ -120,7 +120,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
resourceDescriptor.SampleDesc.Count = 1;
|
resourceDescriptor.SampleDesc.Count = 1;
|
||||||
resourceDescriptor.SampleDesc.Quality = 0;
|
resourceDescriptor.SampleDesc.Quality = 0;
|
||||||
resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
|
resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
|
||||||
resourceDescriptor.Flags = D3D12ResourceFlags(GetAllowedUsage(), GetFormat());
|
resourceDescriptor.Flags = D3D12ResourceFlags(GetUsage(), GetFormat());
|
||||||
|
|
||||||
mResource = mDevice->GetResourceAllocator()->Allocate(
|
mResource = mDevice->GetResourceAllocator()->Allocate(
|
||||||
D3D12_HEAP_TYPE_DEFAULT, resourceDescriptor, D3D12_RESOURCE_STATE_COMMON);
|
D3D12_HEAP_TYPE_DEFAULT, resourceDescriptor, D3D12_RESOURCE_STATE_COMMON);
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
Buffer::Buffer(BufferBuilder* builder) : BufferBase(builder) {
|
Buffer::Buffer(BufferBuilder* builder) : BufferBase(builder) {
|
||||||
MTLResourceOptions storageMode;
|
MTLResourceOptions storageMode;
|
||||||
if (GetAllowedUsage() & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) {
|
if (GetUsage() & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) {
|
||||||
storageMode = MTLResourceStorageModeShared;
|
storageMode = MTLResourceStorageModeShared;
|
||||||
} else {
|
} else {
|
||||||
storageMode = MTLResourceStorageModePrivate;
|
storageMode = MTLResourceStorageModePrivate;
|
||||||
|
|
|
@ -70,7 +70,7 @@ namespace dawn_native { namespace metal {
|
||||||
auto desc = [MTLTextureDescriptor new];
|
auto desc = [MTLTextureDescriptor new];
|
||||||
[desc autorelease];
|
[desc autorelease];
|
||||||
desc.textureType = MetalTextureType(GetDimension());
|
desc.textureType = MetalTextureType(GetDimension());
|
||||||
desc.usage = MetalTextureUsage(GetAllowedUsage());
|
desc.usage = MetalTextureUsage(GetUsage());
|
||||||
desc.pixelFormat = MetalPixelFormat(GetFormat());
|
desc.pixelFormat = MetalPixelFormat(GetFormat());
|
||||||
desc.width = GetWidth();
|
desc.width = GetWidth();
|
||||||
desc.height = GetHeight();
|
desc.height = GetHeight();
|
||||||
|
|
|
@ -121,7 +121,7 @@ namespace dawn_native { namespace null {
|
||||||
};
|
};
|
||||||
|
|
||||||
Buffer::Buffer(BufferBuilder* builder) : BufferBase(builder) {
|
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)) {
|
dawn::BufferUsageBit::MapWrite)) {
|
||||||
mBackingData = std::unique_ptr<char[]>(new char[GetSize()]);
|
mBackingData = std::unique_ptr<char[]>(new char[GetSize()]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
createInfo.pNext = nullptr;
|
createInfo.pNext = nullptr;
|
||||||
createInfo.flags = 0;
|
createInfo.flags = 0;
|
||||||
createInfo.size = GetSize();
|
createInfo.size = GetSize();
|
||||||
createInfo.usage = VulkanBufferUsage(GetAllowedUsage());
|
createInfo.usage = VulkanBufferUsage(GetUsage());
|
||||||
createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
createInfo.queueFamilyIndexCount = 0;
|
createInfo.queueFamilyIndexCount = 0;
|
||||||
createInfo.pQueueFamilyIndices = 0;
|
createInfo.pQueueFamilyIndices = 0;
|
||||||
|
@ -124,8 +124,8 @@ namespace dawn_native { namespace vulkan {
|
||||||
VkMemoryRequirements requirements;
|
VkMemoryRequirements requirements;
|
||||||
device->fn.GetBufferMemoryRequirements(device->GetVkDevice(), mHandle, &requirements);
|
device->fn.GetBufferMemoryRequirements(device->GetVkDevice(), mHandle, &requirements);
|
||||||
|
|
||||||
bool requestMappable = (GetAllowedUsage() & (dawn::BufferUsageBit::MapRead |
|
bool requestMappable =
|
||||||
dawn::BufferUsageBit::MapWrite)) != 0;
|
(GetUsage() & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) != 0;
|
||||||
if (!device->GetMemoryAllocator()->Allocate(requirements, requestMappable,
|
if (!device->GetMemoryAllocator()->Allocate(requirements, requestMappable,
|
||||||
&mMemoryAllocation)) {
|
&mMemoryAllocation)) {
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
|
|
|
@ -252,7 +252,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
createInfo.arrayLayers = 1;
|
createInfo.arrayLayers = 1;
|
||||||
createInfo.samples = VK_SAMPLE_COUNT_1_BIT;
|
createInfo.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
createInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
createInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||||
createInfo.usage = VulkanImageUsage(GetAllowedUsage(), GetFormat());
|
createInfo.usage = VulkanImageUsage(GetUsage(), GetFormat());
|
||||||
createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
createInfo.queueFamilyIndexCount = 0;
|
createInfo.queueFamilyIndexCount = 0;
|
||||||
createInfo.pQueueFamilyIndices = nullptr;
|
createInfo.pQueueFamilyIndices = nullptr;
|
||||||
|
|
Loading…
Reference in New Issue