mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-03 03:35:59 +00:00
Remove BufferView and inline offset/size in BindGroup
BUG=dawn:2 Change-Id: I811024c4ac3a6167dd0caff05eca3fbb2640e862 Reviewed-on: https://dawn-review.googlesource.com/c/2941 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Jiawei Shao <jiawei.shao@intel.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
0f50114b3c
commit
6f0e1f9d82
27
dawn.json
27
dawn.json
@ -30,7 +30,9 @@
|
|||||||
"extensible": false,
|
"extensible": false,
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "binding", "type": "uint32_t"},
|
{"name": "binding", "type": "uint32_t"},
|
||||||
{"name": "buffer view", "type": "buffer view", "optional": true},
|
{"name": "buffer", "type": "buffer", "optional": true},
|
||||||
|
{"name": "offset", "type": "uint32_t"},
|
||||||
|
{"name": "size", "type": "uint32_t"},
|
||||||
{"name": "sampler", "type": "sampler", "optional": true},
|
{"name": "sampler", "type": "sampler", "optional": true},
|
||||||
{"name": "texture view", "type": "texture view", "optional": true}
|
{"name": "texture view", "type": "texture view", "optional": true}
|
||||||
]
|
]
|
||||||
@ -164,10 +166,6 @@
|
|||||||
"buffer": {
|
"buffer": {
|
||||||
"category": "object",
|
"category": "object",
|
||||||
"methods": [
|
"methods": [
|
||||||
{
|
|
||||||
"name": "create buffer view builder",
|
|
||||||
"returns": "buffer view builder"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "set sub data",
|
"name": "set sub data",
|
||||||
"args": [
|
"args": [
|
||||||
@ -264,25 +262,6 @@
|
|||||||
{"value": 128, "name": "storage"}
|
{"value": 128, "name": "storage"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"buffer view": {
|
|
||||||
"category": "object"
|
|
||||||
},
|
|
||||||
"buffer view builder": {
|
|
||||||
"category": "object",
|
|
||||||
"methods": [
|
|
||||||
{
|
|
||||||
"name": "get result",
|
|
||||||
"returns": "buffer view"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "set extent",
|
|
||||||
"args": [
|
|
||||||
{"name": "offset", "type": "uint32_t"},
|
|
||||||
{"name": "size", "type": "uint32_t"}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"callback userdata": {
|
"callback userdata": {
|
||||||
"category": "natively defined"
|
"category": "natively defined"
|
||||||
},
|
},
|
||||||
|
@ -237,22 +237,11 @@ void initSim() {
|
|||||||
csDesc.layout = pl;
|
csDesc.layout = pl;
|
||||||
updatePipeline = device.CreateComputePipeline(&csDesc);
|
updatePipeline = device.CreateComputePipeline(&csDesc);
|
||||||
|
|
||||||
dawn::BufferView updateParamsView = updateParams.CreateBufferViewBuilder()
|
|
||||||
.SetExtent(0, sizeof(SimParams))
|
|
||||||
.GetResult();
|
|
||||||
|
|
||||||
std::array<dawn::BufferView, 2> views;
|
|
||||||
for (uint32_t i = 0; i < 2; ++i) {
|
|
||||||
views[i] = particleBuffers[i].CreateBufferViewBuilder()
|
|
||||||
.SetExtent(0, kNumParticles * sizeof(Particle))
|
|
||||||
.GetResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < 2; ++i) {
|
for (uint32_t i = 0; i < 2; ++i) {
|
||||||
updateBGs[i] = utils::MakeBindGroup(device, bgl, {
|
updateBGs[i] = utils::MakeBindGroup(device, bgl, {
|
||||||
{0, updateParamsView},
|
{0, updateParams, 0, sizeof(SimParams)},
|
||||||
{1, views[i]},
|
{1, particleBuffers[i], 0, kNumParticles * sizeof(Particle)},
|
||||||
{2, views[(i + 1) % 2]}
|
{2, particleBuffers[(i + 1) % 2], 0, kNumParticles * sizeof(Particle)},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,27 +180,14 @@ void init() {
|
|||||||
transform = glm::translate(transform, glm::vec3(0.f, -2.f, 0.f));
|
transform = glm::translate(transform, glm::vec3(0.f, -2.f, 0.f));
|
||||||
transformBuffer[1] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4), dawn::BufferUsageBit::Uniform);
|
transformBuffer[1] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4), dawn::BufferUsageBit::Uniform);
|
||||||
|
|
||||||
dawn::BufferView cameraBufferView = cameraBuffer.CreateBufferViewBuilder()
|
|
||||||
.SetExtent(0, sizeof(CameraData))
|
|
||||||
.GetResult();
|
|
||||||
|
|
||||||
dawn::BufferView transformBufferView[2] = {
|
|
||||||
transformBuffer[0].CreateBufferViewBuilder()
|
|
||||||
.SetExtent(0, sizeof(glm::mat4))
|
|
||||||
.GetResult(),
|
|
||||||
transformBuffer[1].CreateBufferViewBuilder()
|
|
||||||
.SetExtent(0, sizeof(glm::mat4))
|
|
||||||
.GetResult(),
|
|
||||||
};
|
|
||||||
|
|
||||||
bindGroup[0] = utils::MakeBindGroup(device, bgl, {
|
bindGroup[0] = utils::MakeBindGroup(device, bgl, {
|
||||||
{0, cameraBufferView},
|
{0, cameraBuffer, 0, sizeof(CameraData)},
|
||||||
{1, transformBufferView[0]}
|
{1, transformBuffer[0], 0, sizeof(glm::mat4)}
|
||||||
});
|
});
|
||||||
|
|
||||||
bindGroup[1] = utils::MakeBindGroup(device, bgl, {
|
bindGroup[1] = utils::MakeBindGroup(device, bgl, {
|
||||||
{0, cameraBufferView},
|
{0, cameraBuffer, 0, sizeof(CameraData)},
|
||||||
{1, transformBufferView[1]}
|
{1, transformBuffer[1], 0, sizeof(glm::mat4)}
|
||||||
});
|
});
|
||||||
|
|
||||||
depthStencilView = CreateDefaultDepthStencilView(device);
|
depthStencilView = CreateDefaultDepthStencilView(device);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "dawn_native/ValidationUtils_autogen.h"
|
#include "dawn_native/ValidationUtils_autogen.h"
|
||||||
|
|
||||||
{% for type in by_category["object"] %}
|
{% for type in by_category["object"] %}
|
||||||
{% if not type.is_builder and type.name.canonical_case() not in ["buffer view", "texture view"] %}
|
{% if not type.is_builder and type.name.canonical_case() not in ["texture view"] %}
|
||||||
#include "dawn_native/{{type.name.CamelCase()}}.h"
|
#include "dawn_native/{{type.name.CamelCase()}}.h"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -30,17 +30,28 @@ namespace dawn_native {
|
|||||||
|
|
||||||
MaybeError ValidateBufferBinding(const BindGroupBinding& binding,
|
MaybeError ValidateBufferBinding(const BindGroupBinding& binding,
|
||||||
dawn::BufferUsageBit requiredUsage) {
|
dawn::BufferUsageBit requiredUsage) {
|
||||||
if (binding.bufferView == nullptr || binding.sampler != nullptr ||
|
if (binding.buffer == nullptr || binding.sampler != nullptr ||
|
||||||
binding.textureView != nullptr) {
|
binding.textureView != nullptr) {
|
||||||
return DAWN_VALIDATION_ERROR("expected buffer binding");
|
return DAWN_VALIDATION_ERROR("expected buffer binding");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsAligned(binding.bufferView->GetOffset(), 256)) {
|
uint32_t bufferSize = binding.buffer->GetSize();
|
||||||
return DAWN_VALIDATION_ERROR(
|
if (binding.size > bufferSize) {
|
||||||
"Buffer view offset for bind group needs to be 256-byte aligned");
|
return DAWN_VALIDATION_ERROR("Buffer binding size larger than the buffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(binding.bufferView->GetBuffer()->GetUsage() & requiredUsage)) {
|
// Note that no overflow can happen because we already checked that
|
||||||
|
// bufferSize >= binding.size
|
||||||
|
if (binding.offset > bufferSize - binding.size) {
|
||||||
|
return DAWN_VALIDATION_ERROR("Buffer binding doesn't fit in the buffer");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsAligned(binding.offset, 256)) {
|
||||||
|
return DAWN_VALIDATION_ERROR(
|
||||||
|
"Buffer offset for bind group needs to be 256-byte aligned");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(binding.buffer->GetUsage() & requiredUsage)) {
|
||||||
return DAWN_VALIDATION_ERROR("buffer binding usage mismatch");
|
return DAWN_VALIDATION_ERROR("buffer binding usage mismatch");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +61,7 @@ namespace dawn_native {
|
|||||||
MaybeError ValidateTextureBinding(const BindGroupBinding& binding,
|
MaybeError ValidateTextureBinding(const BindGroupBinding& binding,
|
||||||
dawn::TextureUsageBit requiredUsage) {
|
dawn::TextureUsageBit requiredUsage) {
|
||||||
if (binding.textureView == nullptr || binding.sampler != nullptr ||
|
if (binding.textureView == nullptr || binding.sampler != nullptr ||
|
||||||
binding.bufferView != nullptr) {
|
binding.buffer != nullptr) {
|
||||||
return DAWN_VALIDATION_ERROR("expected texture binding");
|
return DAWN_VALIDATION_ERROR("expected texture binding");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +74,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
MaybeError ValidateSamplerBinding(const BindGroupBinding& binding) {
|
MaybeError ValidateSamplerBinding(const BindGroupBinding& binding) {
|
||||||
if (binding.sampler == nullptr || binding.textureView != nullptr ||
|
if (binding.sampler == nullptr || binding.textureView != nullptr ||
|
||||||
binding.bufferView != nullptr) {
|
binding.buffer != nullptr) {
|
||||||
return DAWN_VALIDATION_ERROR("expected sampler binding");
|
return DAWN_VALIDATION_ERROR("expected sampler binding");
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
@ -142,9 +153,11 @@ namespace dawn_native {
|
|||||||
// Only a single binding type should be set, so once we found it we can skip to the
|
// Only a single binding type should be set, so once we found it we can skip to the
|
||||||
// next loop iteration.
|
// next loop iteration.
|
||||||
|
|
||||||
if (binding.bufferView != nullptr) {
|
if (binding.buffer != nullptr) {
|
||||||
ASSERT(mBindings[bindingIndex].Get() == nullptr);
|
ASSERT(mBindings[bindingIndex].Get() == nullptr);
|
||||||
mBindings[bindingIndex] = binding.bufferView;
|
mBindings[bindingIndex] = binding.buffer;
|
||||||
|
mOffsets[bindingIndex] = binding.offset;
|
||||||
|
mSizes[bindingIndex] = binding.size;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,12 +179,13 @@ namespace dawn_native {
|
|||||||
return mLayout.Get();
|
return mLayout.Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferViewBase* BindGroupBase::GetBindingAsBufferView(size_t binding) {
|
BufferBinding BindGroupBase::GetBindingAsBufferBinding(size_t binding) {
|
||||||
ASSERT(binding < kMaxBindingsPerGroup);
|
ASSERT(binding < kMaxBindingsPerGroup);
|
||||||
ASSERT(mLayout->GetBindingInfo().mask[binding]);
|
ASSERT(mLayout->GetBindingInfo().mask[binding]);
|
||||||
ASSERT(mLayout->GetBindingInfo().types[binding] == dawn::BindingType::UniformBuffer ||
|
ASSERT(mLayout->GetBindingInfo().types[binding] == dawn::BindingType::UniformBuffer ||
|
||||||
mLayout->GetBindingInfo().types[binding] == dawn::BindingType::StorageBuffer);
|
mLayout->GetBindingInfo().types[binding] == dawn::BindingType::StorageBuffer);
|
||||||
return reinterpret_cast<BufferViewBase*>(mBindings[binding].Get());
|
BufferBase* buffer = reinterpret_cast<BufferBase*>(mBindings[binding].Get());
|
||||||
|
return {buffer, mOffsets[binding], mSizes[binding]};
|
||||||
}
|
}
|
||||||
|
|
||||||
SamplerBase* BindGroupBase::GetBindingAsSampler(size_t binding) {
|
SamplerBase* BindGroupBase::GetBindingAsSampler(size_t binding) {
|
||||||
|
@ -32,18 +32,26 @@ namespace dawn_native {
|
|||||||
MaybeError ValidateBindGroupDescriptor(DeviceBase* device,
|
MaybeError ValidateBindGroupDescriptor(DeviceBase* device,
|
||||||
const BindGroupDescriptor* descriptor);
|
const BindGroupDescriptor* descriptor);
|
||||||
|
|
||||||
|
struct BufferBinding {
|
||||||
|
BufferBase* buffer;
|
||||||
|
uint32_t offset;
|
||||||
|
uint32_t size;
|
||||||
|
};
|
||||||
|
|
||||||
class BindGroupBase : public ObjectBase {
|
class BindGroupBase : public ObjectBase {
|
||||||
public:
|
public:
|
||||||
BindGroupBase(DeviceBase* device, const BindGroupDescriptor* descriptor);
|
BindGroupBase(DeviceBase* device, const BindGroupDescriptor* descriptor);
|
||||||
|
|
||||||
const BindGroupLayoutBase* GetLayout() const;
|
const BindGroupLayoutBase* GetLayout() const;
|
||||||
BufferViewBase* GetBindingAsBufferView(size_t binding);
|
BufferBinding GetBindingAsBufferBinding(size_t binding);
|
||||||
SamplerBase* GetBindingAsSampler(size_t binding);
|
SamplerBase* GetBindingAsSampler(size_t binding);
|
||||||
TextureViewBase* GetBindingAsTextureView(size_t binding);
|
TextureViewBase* GetBindingAsTextureView(size_t binding);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ref<BindGroupLayoutBase> mLayout;
|
Ref<BindGroupLayoutBase> mLayout;
|
||||||
std::array<Ref<ObjectBase>, kMaxBindingsPerGroup> mBindings;
|
std::array<Ref<ObjectBase>, kMaxBindingsPerGroup> mBindings;
|
||||||
|
std::array<uint32_t, kMaxBindingsPerGroup> mOffsets;
|
||||||
|
std::array<uint32_t, kMaxBindingsPerGroup> mSizes;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
@ -60,10 +60,6 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferViewBuilder* BufferBase::CreateBufferViewBuilder() {
|
|
||||||
return new BufferViewBuilder(GetDevice(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t BufferBase::GetSize() const {
|
uint32_t BufferBase::GetSize() const {
|
||||||
return mSize;
|
return mSize;
|
||||||
}
|
}
|
||||||
@ -209,62 +205,4 @@ namespace dawn_native {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// BufferViewBase
|
|
||||||
|
|
||||||
BufferViewBase::BufferViewBase(BufferViewBuilder* builder)
|
|
||||||
: ObjectBase(builder->GetDevice()),
|
|
||||||
mBuffer(std::move(builder->mBuffer)),
|
|
||||||
mSize(builder->mSize),
|
|
||||||
mOffset(builder->mOffset) {
|
|
||||||
}
|
|
||||||
|
|
||||||
BufferBase* BufferViewBase::GetBuffer() {
|
|
||||||
return mBuffer.Get();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t BufferViewBase::GetSize() const {
|
|
||||||
return mSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t BufferViewBase::GetOffset() const {
|
|
||||||
return mOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
// BufferViewBuilder
|
|
||||||
|
|
||||||
enum BufferViewSetProperties {
|
|
||||||
BUFFER_VIEW_PROPERTY_EXTENT = 0x1,
|
|
||||||
};
|
|
||||||
|
|
||||||
BufferViewBuilder::BufferViewBuilder(DeviceBase* device, BufferBase* buffer)
|
|
||||||
: Builder(device), mBuffer(buffer) {
|
|
||||||
}
|
|
||||||
|
|
||||||
BufferViewBase* BufferViewBuilder::GetResultImpl() {
|
|
||||||
constexpr int allProperties = BUFFER_VIEW_PROPERTY_EXTENT;
|
|
||||||
if ((mPropertiesSet & allProperties) != allProperties) {
|
|
||||||
HandleError("Buffer view missing properties");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetDevice()->CreateBufferView(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BufferViewBuilder::SetExtent(uint32_t offset, uint32_t size) {
|
|
||||||
if ((mPropertiesSet & BUFFER_VIEW_PROPERTY_EXTENT) != 0) {
|
|
||||||
HandleError("Buffer view extent property set multiple times");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t viewEnd = static_cast<uint64_t>(offset) + static_cast<uint64_t>(size);
|
|
||||||
if (viewEnd > static_cast<uint64_t>(mBuffer->GetSize())) {
|
|
||||||
HandleError("Buffer view end is OOB");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mOffset = offset;
|
|
||||||
mSize = size;
|
|
||||||
mPropertiesSet |= BUFFER_VIEW_PROPERTY_EXTENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
@ -45,7 +45,6 @@ namespace dawn_native {
|
|||||||
MaybeError ValidateCanUseInSubmitNow() const;
|
MaybeError ValidateCanUseInSubmitNow() const;
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
BufferViewBuilder* CreateBufferViewBuilder();
|
|
||||||
void SetSubData(uint32_t start, uint32_t count, const uint8_t* data);
|
void SetSubData(uint32_t start, uint32_t count, const uint8_t* data);
|
||||||
void MapReadAsync(uint32_t start,
|
void MapReadAsync(uint32_t start,
|
||||||
uint32_t size,
|
uint32_t size,
|
||||||
@ -86,40 +85,8 @@ namespace dawn_native {
|
|||||||
bool mIsMapped = false;
|
bool mIsMapped = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BufferViewBase : public ObjectBase {
|
|
||||||
public:
|
|
||||||
BufferViewBase(BufferViewBuilder* builder);
|
|
||||||
|
|
||||||
BufferBase* GetBuffer();
|
|
||||||
uint32_t GetSize() const;
|
|
||||||
uint32_t GetOffset() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ref<BufferBase> mBuffer;
|
|
||||||
uint32_t mSize;
|
|
||||||
uint32_t mOffset;
|
|
||||||
};
|
|
||||||
|
|
||||||
class BufferViewBuilder : public Builder<BufferViewBase> {
|
|
||||||
public:
|
|
||||||
BufferViewBuilder(DeviceBase* device, BufferBase* buffer);
|
|
||||||
|
|
||||||
// Dawn API
|
|
||||||
void SetExtent(uint32_t offset, uint32_t size);
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class BufferViewBase;
|
|
||||||
|
|
||||||
BufferViewBase* GetResultImpl() override;
|
|
||||||
|
|
||||||
Ref<BufferBase> mBuffer;
|
|
||||||
uint32_t mOffset = 0;
|
|
||||||
uint32_t mSize = 0;
|
|
||||||
int mPropertiesSet = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// This builder class is kept around purely for testing but should not be used.
|
// This builder class is kept around purely for testing but should not be used.
|
||||||
class BufferBuilder : public Builder<BufferViewBase> {
|
class BufferBuilder : public Builder<BufferBase> {
|
||||||
public:
|
public:
|
||||||
BufferBuilder(DeviceBase* device) : Builder(device) {
|
BufferBuilder(DeviceBase* device) : Builder(device) {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
|
@ -255,12 +255,12 @@ namespace dawn_native {
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case dawn::BindingType::UniformBuffer: {
|
case dawn::BindingType::UniformBuffer: {
|
||||||
BufferBase* buffer = group->GetBindingAsBufferView(i)->GetBuffer();
|
BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer;
|
||||||
tracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Uniform);
|
tracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Uniform);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dawn::BindingType::StorageBuffer: {
|
case dawn::BindingType::StorageBuffer: {
|
||||||
BufferBase* buffer = group->GetBindingAsBufferView(i)->GetBuffer();
|
BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer;
|
||||||
tracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Storage);
|
tracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Storage);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -52,7 +52,6 @@ namespace dawn_native {
|
|||||||
FenceSignalTracker* GetFenceSignalTracker() const;
|
FenceSignalTracker* GetFenceSignalTracker() const;
|
||||||
|
|
||||||
virtual BlendStateBase* CreateBlendState(BlendStateBuilder* builder) = 0;
|
virtual BlendStateBase* CreateBlendState(BlendStateBuilder* builder) = 0;
|
||||||
virtual BufferViewBase* CreateBufferView(BufferViewBuilder* builder) = 0;
|
|
||||||
virtual CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) = 0;
|
virtual CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) = 0;
|
||||||
virtual DepthStencilStateBase* CreateDepthStencilState(
|
virtual DepthStencilStateBase* CreateDepthStencilState(
|
||||||
DepthStencilStateBuilder* builder) = 0;
|
DepthStencilStateBuilder* builder) = 0;
|
||||||
|
@ -27,8 +27,6 @@ namespace dawn_native {
|
|||||||
class BlendStateBuilder;
|
class BlendStateBuilder;
|
||||||
class BufferBase;
|
class BufferBase;
|
||||||
class BufferBuilder;
|
class BufferBuilder;
|
||||||
class BufferViewBase;
|
|
||||||
class BufferViewBuilder;
|
|
||||||
class ComputePipelineBase;
|
class ComputePipelineBase;
|
||||||
class ComputePipelineBuilder;
|
class ComputePipelineBuilder;
|
||||||
class CommandBufferBase;
|
class CommandBufferBase;
|
||||||
|
@ -43,11 +43,6 @@ namespace dawn_native {
|
|||||||
using BackendType = typename BackendTraits::BufferType;
|
using BackendType = typename BackendTraits::BufferType;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename BackendTraits>
|
|
||||||
struct ToBackendTraits<BufferViewBase, BackendTraits> {
|
|
||||||
using BackendType = typename BackendTraits::BufferViewType;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename BackendTraits>
|
template <typename BackendTraits>
|
||||||
struct ToBackendTraits<CommandBufferBase, BackendTraits> {
|
struct ToBackendTraits<CommandBufferBase, BackendTraits> {
|
||||||
using BackendType = typename BackendTraits::CommandBufferType;
|
using BackendType = typename BackendTraits::CommandBufferType;
|
||||||
|
@ -46,37 +46,54 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
const auto& bindingOffsets = bgl->GetBindingOffsets();
|
const auto& bindingOffsets = bgl->GetBindingOffsets();
|
||||||
|
|
||||||
auto d3d12Device = ToBackend(GetDevice())->GetD3D12Device();
|
auto d3d12Device = ToBackend(GetDevice())->GetD3D12Device();
|
||||||
for (uint32_t binding : IterateBitSet(layout.mask)) {
|
for (uint32_t bindingIndex : IterateBitSet(layout.mask)) {
|
||||||
switch (layout.types[binding]) {
|
switch (layout.types[bindingIndex]) {
|
||||||
case dawn::BindingType::UniformBuffer: {
|
case dawn::BindingType::UniformBuffer: {
|
||||||
auto* view = ToBackend(GetBindingAsBufferView(binding));
|
BufferBinding binding = GetBindingAsBufferBinding(bindingIndex);
|
||||||
auto& cbv = view->GetCBVDescriptor();
|
|
||||||
|
D3D12_CONSTANT_BUFFER_VIEW_DESC desc;
|
||||||
|
// TODO(enga@google.com): investigate if this needs to be a constraint at the
|
||||||
|
// API level
|
||||||
|
desc.SizeInBytes = Align(binding.size, 256);
|
||||||
|
desc.BufferLocation = ToBackend(binding.buffer)->GetVA() + binding.offset;
|
||||||
|
|
||||||
d3d12Device->CreateConstantBufferView(
|
d3d12Device->CreateConstantBufferView(
|
||||||
&cbv, cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
|
&desc, cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
|
||||||
bindingOffsets[binding]));
|
bindingOffsets[bindingIndex]));
|
||||||
} break;
|
} break;
|
||||||
case dawn::BindingType::StorageBuffer: {
|
case dawn::BindingType::StorageBuffer: {
|
||||||
auto* view = ToBackend(GetBindingAsBufferView(binding));
|
BufferBinding binding = GetBindingAsBufferBinding(bindingIndex);
|
||||||
auto& uav = view->GetUAVDescriptor();
|
|
||||||
|
D3D12_UNORDERED_ACCESS_VIEW_DESC desc;
|
||||||
|
// TODO(enga@google.com): investigate if this needs to be a constraint at the
|
||||||
|
// API level
|
||||||
|
desc.Buffer.NumElements = Align(binding.size, 256);
|
||||||
|
desc.Format = DXGI_FORMAT_UNKNOWN;
|
||||||
|
desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
|
||||||
|
desc.Buffer.FirstElement = binding.offset;
|
||||||
|
desc.Buffer.StructureByteStride = 1;
|
||||||
|
desc.Buffer.CounterOffsetInBytes = 0;
|
||||||
|
desc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE;
|
||||||
|
|
||||||
d3d12Device->CreateUnorderedAccessView(
|
d3d12Device->CreateUnorderedAccessView(
|
||||||
ToBackend(view->GetBuffer())->GetD3D12Resource().Get(), nullptr, &uav,
|
ToBackend(binding.buffer)->GetD3D12Resource().Get(), nullptr, &desc,
|
||||||
cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
|
cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
|
||||||
bindingOffsets[binding]));
|
bindingOffsets[bindingIndex]));
|
||||||
} break;
|
} break;
|
||||||
case dawn::BindingType::SampledTexture: {
|
case dawn::BindingType::SampledTexture: {
|
||||||
auto* view = ToBackend(GetBindingAsTextureView(binding));
|
auto* view = ToBackend(GetBindingAsTextureView(bindingIndex));
|
||||||
auto& srv = view->GetSRVDescriptor();
|
auto& srv = view->GetSRVDescriptor();
|
||||||
d3d12Device->CreateShaderResourceView(
|
d3d12Device->CreateShaderResourceView(
|
||||||
ToBackend(view->GetTexture())->GetD3D12Resource(), &srv,
|
ToBackend(view->GetTexture())->GetD3D12Resource(), &srv,
|
||||||
cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
|
cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
|
||||||
bindingOffsets[binding]));
|
bindingOffsets[bindingIndex]));
|
||||||
} break;
|
} break;
|
||||||
case dawn::BindingType::Sampler: {
|
case dawn::BindingType::Sampler: {
|
||||||
auto* sampler = ToBackend(GetBindingAsSampler(binding));
|
auto* sampler = ToBackend(GetBindingAsSampler(bindingIndex));
|
||||||
auto& samplerDesc = sampler->GetSamplerDescriptor();
|
auto& samplerDesc = sampler->GetSamplerDescriptor();
|
||||||
d3d12Device->CreateSampler(
|
d3d12Device->CreateSampler(
|
||||||
&samplerDesc, samplerHeapStart.GetCPUHandle(*samplerHeapOffset +
|
&samplerDesc, samplerHeapStart.GetCPUHandle(*samplerHeapOffset +
|
||||||
bindingOffsets[binding]));
|
bindingOffsets[bindingIndex]));
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,32 +197,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
mWrittenMappedRange = {};
|
mWrittenMappedRange = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferView::BufferView(BufferViewBuilder* builder) : BufferViewBase(builder) {
|
|
||||||
mCbvDesc.BufferLocation = ToBackend(GetBuffer())->GetVA() + GetOffset();
|
|
||||||
mCbvDesc.SizeInBytes = GetD3D12Size();
|
|
||||||
|
|
||||||
mUavDesc.Format = DXGI_FORMAT_UNKNOWN;
|
|
||||||
mUavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
|
|
||||||
mUavDesc.Buffer.FirstElement = GetOffset();
|
|
||||||
mUavDesc.Buffer.NumElements = GetD3D12Size();
|
|
||||||
mUavDesc.Buffer.StructureByteStride = 1;
|
|
||||||
mUavDesc.Buffer.CounterOffsetInBytes = 0;
|
|
||||||
mUavDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t BufferView::GetD3D12Size() const {
|
|
||||||
// TODO(enga@google.com): TODO investigate if this needs to be a constraint at the API level
|
|
||||||
return Align(GetSize(), 256);
|
|
||||||
}
|
|
||||||
|
|
||||||
const D3D12_CONSTANT_BUFFER_VIEW_DESC& BufferView::GetCBVDescriptor() const {
|
|
||||||
return mCbvDesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
const D3D12_UNORDERED_ACCESS_VIEW_DESC& BufferView::GetUAVDescriptor() const {
|
|
||||||
return mUavDesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapRequestTracker::MapRequestTracker(Device* device) : mDevice(device) {
|
MapRequestTracker::MapRequestTracker(Device* device) : mDevice(device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,19 +50,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
D3D12_RANGE mWrittenMappedRange;
|
D3D12_RANGE mWrittenMappedRange;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BufferView : public BufferViewBase {
|
|
||||||
public:
|
|
||||||
BufferView(BufferViewBuilder* builder);
|
|
||||||
|
|
||||||
uint32_t GetD3D12Size() const;
|
|
||||||
const D3D12_CONSTANT_BUFFER_VIEW_DESC& GetCBVDescriptor() const;
|
|
||||||
const D3D12_UNORDERED_ACCESS_VIEW_DESC& GetUAVDescriptor() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
D3D12_CONSTANT_BUFFER_VIEW_DESC mCbvDesc;
|
|
||||||
D3D12_UNORDERED_ACCESS_VIEW_DESC mUavDesc;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MapRequestTracker {
|
class MapRequestTracker {
|
||||||
public:
|
public:
|
||||||
MapRequestTracker(Device* device);
|
MapRequestTracker(Device* device);
|
||||||
|
@ -300,9 +300,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
|
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
|
||||||
return new Buffer(this, descriptor);
|
return new Buffer(this, descriptor);
|
||||||
}
|
}
|
||||||
BufferViewBase* Device::CreateBufferView(BufferViewBuilder* builder) {
|
|
||||||
return new BufferView(builder);
|
|
||||||
}
|
|
||||||
CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
|
CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
|
||||||
return new CommandBuffer(builder);
|
return new CommandBuffer(builder);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
~Device();
|
~Device();
|
||||||
|
|
||||||
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
||||||
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
|
||||||
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
||||||
DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
|
DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
|
||||||
InputStateBase* CreateInputState(InputStateBuilder* builder) override;
|
InputStateBase* CreateInputState(InputStateBuilder* builder) override;
|
||||||
|
@ -23,7 +23,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
class BindGroupLayout;
|
class BindGroupLayout;
|
||||||
class BlendState;
|
class BlendState;
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class BufferView;
|
|
||||||
class CommandBuffer;
|
class CommandBuffer;
|
||||||
class ComputePipeline;
|
class ComputePipeline;
|
||||||
class DepthStencilState;
|
class DepthStencilState;
|
||||||
@ -44,7 +43,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
using BindGroupLayoutType = BindGroupLayout;
|
using BindGroupLayoutType = BindGroupLayout;
|
||||||
using BlendStateType = BlendState;
|
using BlendStateType = BlendState;
|
||||||
using BufferType = Buffer;
|
using BufferType = Buffer;
|
||||||
using BufferViewType = BufferView;
|
|
||||||
using CommandBufferType = CommandBuffer;
|
using CommandBufferType = CommandBuffer;
|
||||||
using ComputePipelineType = ComputePipeline;
|
using ComputePipelineType = ComputePipeline;
|
||||||
using DepthStencilStateType = DepthStencilState;
|
using DepthStencilStateType = DepthStencilState;
|
||||||
|
@ -42,11 +42,6 @@ namespace dawn_native { namespace metal {
|
|||||||
id<MTLBuffer> mMtlBuffer = nil;
|
id<MTLBuffer> mMtlBuffer = nil;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BufferView : public BufferViewBase {
|
|
||||||
public:
|
|
||||||
BufferView(BufferViewBuilder* builder);
|
|
||||||
};
|
|
||||||
|
|
||||||
class MapRequestTracker {
|
class MapRequestTracker {
|
||||||
public:
|
public:
|
||||||
MapRequestTracker(Device* device);
|
MapRequestTracker(Device* device);
|
||||||
|
@ -68,9 +68,6 @@ namespace dawn_native { namespace metal {
|
|||||||
// Nothing to do, Metal StorageModeShared buffers are always mapped.
|
// Nothing to do, Metal StorageModeShared buffers are always mapped.
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferView::BufferView(BufferViewBuilder* builder) : BufferViewBase(builder) {
|
|
||||||
}
|
|
||||||
|
|
||||||
MapRequestTracker::MapRequestTracker(Device* device) : mDevice(device) {
|
MapRequestTracker::MapRequestTracker(Device* device) : mDevice(device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,12 +118,8 @@ namespace dawn_native { namespace metal {
|
|||||||
// TODO(kainino@chromium.org): Maintain buffers and offsets arrays in BindGroup
|
// TODO(kainino@chromium.org): Maintain buffers and offsets arrays in BindGroup
|
||||||
// so that we only have to do one setVertexBuffers and one setFragmentBuffers
|
// so that we only have to do one setVertexBuffers and one setFragmentBuffers
|
||||||
// call here.
|
// call here.
|
||||||
for (size_t binding = 0; binding < layout.mask.size(); ++binding) {
|
for (uint32_t bindingIndex : IterateBitSet(layout.mask)) {
|
||||||
if (!layout.mask[binding]) {
|
auto stage = layout.visibilities[bindingIndex];
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto stage = layout.visibilities[binding];
|
|
||||||
bool hasVertStage = stage & dawn::ShaderStageBit::Vertex && render != nil;
|
bool hasVertStage = stage & dawn::ShaderStageBit::Vertex && render != nil;
|
||||||
bool hasFragStage = stage & dawn::ShaderStageBit::Fragment && render != nil;
|
bool hasFragStage = stage & dawn::ShaderStageBit::Fragment && render != nil;
|
||||||
bool hasComputeStage = stage & dawn::ShaderStageBit::Compute && compute != nil;
|
bool hasComputeStage = stage & dawn::ShaderStageBit::Compute && compute != nil;
|
||||||
@ -134,24 +130,23 @@ namespace dawn_native { namespace metal {
|
|||||||
|
|
||||||
if (hasVertStage) {
|
if (hasVertStage) {
|
||||||
vertIndex = pipelineLayout->GetBindingIndexInfo(
|
vertIndex = pipelineLayout->GetBindingIndexInfo(
|
||||||
dawn::ShaderStage::Vertex)[index][binding];
|
dawn::ShaderStage::Vertex)[index][bindingIndex];
|
||||||
}
|
}
|
||||||
if (hasFragStage) {
|
if (hasFragStage) {
|
||||||
fragIndex = pipelineLayout->GetBindingIndexInfo(
|
fragIndex = pipelineLayout->GetBindingIndexInfo(
|
||||||
dawn::ShaderStage::Fragment)[index][binding];
|
dawn::ShaderStage::Fragment)[index][bindingIndex];
|
||||||
}
|
}
|
||||||
if (hasComputeStage) {
|
if (hasComputeStage) {
|
||||||
computeIndex = pipelineLayout->GetBindingIndexInfo(
|
computeIndex = pipelineLayout->GetBindingIndexInfo(
|
||||||
dawn::ShaderStage::Compute)[index][binding];
|
dawn::ShaderStage::Compute)[index][bindingIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (layout.types[binding]) {
|
switch (layout.types[bindingIndex]) {
|
||||||
case dawn::BindingType::UniformBuffer:
|
case dawn::BindingType::UniformBuffer:
|
||||||
case dawn::BindingType::StorageBuffer: {
|
case dawn::BindingType::StorageBuffer: {
|
||||||
BufferView* view = ToBackend(group->GetBindingAsBufferView(binding));
|
BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex);
|
||||||
auto b = ToBackend(view->GetBuffer());
|
const id<MTLBuffer> buffer = ToBackend(binding.buffer)->GetMTLBuffer();
|
||||||
const id<MTLBuffer> buffer = b->GetMTLBuffer();
|
const NSUInteger offset = binding.offset;
|
||||||
const NSUInteger offset = view->GetOffset();
|
|
||||||
|
|
||||||
if (hasVertStage) {
|
if (hasVertStage) {
|
||||||
[render setVertexBuffers:&buffer
|
[render setVertexBuffers:&buffer
|
||||||
@ -172,7 +167,7 @@ namespace dawn_native { namespace metal {
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dawn::BindingType::Sampler: {
|
case dawn::BindingType::Sampler: {
|
||||||
auto sampler = ToBackend(group->GetBindingAsSampler(binding));
|
auto sampler = ToBackend(group->GetBindingAsSampler(bindingIndex));
|
||||||
if (hasVertStage) {
|
if (hasVertStage) {
|
||||||
[render setVertexSamplerState:sampler->GetMTLSamplerState()
|
[render setVertexSamplerState:sampler->GetMTLSamplerState()
|
||||||
atIndex:vertIndex];
|
atIndex:vertIndex];
|
||||||
@ -188,7 +183,7 @@ namespace dawn_native { namespace metal {
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dawn::BindingType::SampledTexture: {
|
case dawn::BindingType::SampledTexture: {
|
||||||
auto textureView = ToBackend(group->GetBindingAsTextureView(binding));
|
auto textureView = ToBackend(group->GetBindingAsTextureView(bindingIndex));
|
||||||
if (hasVertStage) {
|
if (hasVertStage) {
|
||||||
[render setVertexTexture:textureView->GetMTLTexture()
|
[render setVertexTexture:textureView->GetMTLTexture()
|
||||||
atIndex:vertIndex];
|
atIndex:vertIndex];
|
||||||
|
@ -38,7 +38,6 @@ namespace dawn_native { namespace metal {
|
|||||||
~Device();
|
~Device();
|
||||||
|
|
||||||
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
||||||
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
|
||||||
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
||||||
DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
|
DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
|
||||||
InputStateBase* CreateInputState(InputStateBuilder* builder) override;
|
InputStateBase* CreateInputState(InputStateBuilder* builder) override;
|
||||||
|
@ -176,9 +176,6 @@ namespace dawn_native { namespace metal {
|
|||||||
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
|
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
|
||||||
return new Buffer(this, descriptor);
|
return new Buffer(this, descriptor);
|
||||||
}
|
}
|
||||||
BufferViewBase* Device::CreateBufferView(BufferViewBuilder* builder) {
|
|
||||||
return new BufferView(builder);
|
|
||||||
}
|
|
||||||
CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
|
CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
|
||||||
return new CommandBuffer(builder);
|
return new CommandBuffer(builder);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ namespace dawn_native { namespace metal {
|
|||||||
using BindGroupLayout = BindGroupLayoutBase;
|
using BindGroupLayout = BindGroupLayoutBase;
|
||||||
class BlendState;
|
class BlendState;
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class BufferView;
|
|
||||||
class CommandBuffer;
|
class CommandBuffer;
|
||||||
class ComputePipeline;
|
class ComputePipeline;
|
||||||
class DepthStencilState;
|
class DepthStencilState;
|
||||||
@ -51,7 +50,6 @@ namespace dawn_native { namespace metal {
|
|||||||
using BindGroupLayoutType = BindGroupLayout;
|
using BindGroupLayoutType = BindGroupLayout;
|
||||||
using BlendStateType = BlendState;
|
using BlendStateType = BlendState;
|
||||||
using BufferType = Buffer;
|
using BufferType = Buffer;
|
||||||
using BufferViewType = BufferView;
|
|
||||||
using CommandBufferType = CommandBuffer;
|
using CommandBufferType = CommandBuffer;
|
||||||
using ComputePipelineType = ComputePipeline;
|
using ComputePipelineType = ComputePipeline;
|
||||||
using DepthStencilStateType = DepthStencilState;
|
using DepthStencilStateType = DepthStencilState;
|
||||||
|
@ -48,9 +48,6 @@ namespace dawn_native { namespace null {
|
|||||||
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
|
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
|
||||||
return new Buffer(this, descriptor);
|
return new Buffer(this, descriptor);
|
||||||
}
|
}
|
||||||
BufferViewBase* Device::CreateBufferView(BufferViewBuilder* builder) {
|
|
||||||
return new BufferView(builder);
|
|
||||||
}
|
|
||||||
CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
|
CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
|
||||||
return new CommandBuffer(builder);
|
return new CommandBuffer(builder);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@ namespace dawn_native { namespace null {
|
|||||||
using BindGroupLayout = BindGroupLayoutBase;
|
using BindGroupLayout = BindGroupLayoutBase;
|
||||||
using BlendState = BlendStateBase;
|
using BlendState = BlendStateBase;
|
||||||
class Buffer;
|
class Buffer;
|
||||||
using BufferView = BufferViewBase;
|
|
||||||
class CommandBuffer;
|
class CommandBuffer;
|
||||||
using ComputePipeline = ComputePipelineBase;
|
using ComputePipeline = ComputePipelineBase;
|
||||||
using DepthStencilState = DepthStencilStateBase;
|
using DepthStencilState = DepthStencilStateBase;
|
||||||
@ -63,7 +62,6 @@ namespace dawn_native { namespace null {
|
|||||||
using BindGroupLayoutType = BindGroupLayout;
|
using BindGroupLayoutType = BindGroupLayout;
|
||||||
using BlendStateType = BlendState;
|
using BlendStateType = BlendState;
|
||||||
using BufferType = Buffer;
|
using BufferType = Buffer;
|
||||||
using BufferViewType = BufferView;
|
|
||||||
using CommandBufferType = CommandBuffer;
|
using CommandBufferType = CommandBuffer;
|
||||||
using ComputePipelineType = ComputePipeline;
|
using ComputePipelineType = ComputePipeline;
|
||||||
using DepthStencilStateType = DepthStencilState;
|
using DepthStencilStateType = DepthStencilState;
|
||||||
@ -96,7 +94,6 @@ namespace dawn_native { namespace null {
|
|||||||
~Device();
|
~Device();
|
||||||
|
|
||||||
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
||||||
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
|
||||||
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
||||||
DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
|
DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
|
||||||
InputStateBase* CreateInputState(InputStateBuilder* builder) override;
|
InputStateBase* CreateInputState(InputStateBuilder* builder) override;
|
||||||
|
@ -57,9 +57,4 @@ namespace dawn_native { namespace opengl {
|
|||||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||||
}
|
}
|
||||||
|
|
||||||
// BufferView
|
|
||||||
|
|
||||||
BufferView::BufferView(BufferViewBuilder* builder) : BufferViewBase(builder) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}} // namespace dawn_native::opengl
|
}} // namespace dawn_native::opengl
|
||||||
|
@ -38,11 +38,6 @@ namespace dawn_native { namespace opengl {
|
|||||||
GLuint mBuffer = 0;
|
GLuint mBuffer = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BufferView : public BufferViewBase {
|
|
||||||
public:
|
|
||||||
BufferView(BufferViewBuilder* builder);
|
|
||||||
};
|
|
||||||
|
|
||||||
}} // namespace dawn_native::opengl
|
}} // namespace dawn_native::opengl
|
||||||
|
|
||||||
#endif // DAWNNATIVE_OPENGL_BUFFERGL_H_
|
#endif // DAWNNATIVE_OPENGL_BUFFERGL_H_
|
||||||
|
@ -235,21 +235,21 @@ namespace dawn_native { namespace opengl {
|
|||||||
const auto& indices = pipelineLayout->GetBindingIndexInfo()[index];
|
const auto& indices = pipelineLayout->GetBindingIndexInfo()[index];
|
||||||
const auto& layout = group->GetLayout()->GetBindingInfo();
|
const auto& layout = group->GetLayout()->GetBindingInfo();
|
||||||
|
|
||||||
for (uint32_t binding : IterateBitSet(layout.mask)) {
|
for (uint32_t bindingIndex : IterateBitSet(layout.mask)) {
|
||||||
switch (layout.types[binding]) {
|
switch (layout.types[bindingIndex]) {
|
||||||
case dawn::BindingType::UniformBuffer: {
|
case dawn::BindingType::UniformBuffer: {
|
||||||
BufferView* view = ToBackend(group->GetBindingAsBufferView(binding));
|
BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex);
|
||||||
GLuint buffer = ToBackend(view->GetBuffer())->GetHandle();
|
GLuint buffer = ToBackend(binding.buffer)->GetHandle();
|
||||||
GLuint uboIndex = indices[binding];
|
GLuint uboIndex = indices[bindingIndex];
|
||||||
|
|
||||||
glBindBufferRange(GL_UNIFORM_BUFFER, uboIndex, buffer, view->GetOffset(),
|
glBindBufferRange(GL_UNIFORM_BUFFER, uboIndex, buffer, binding.offset,
|
||||||
view->GetSize());
|
binding.size);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dawn::BindingType::Sampler: {
|
case dawn::BindingType::Sampler: {
|
||||||
GLuint sampler =
|
GLuint sampler =
|
||||||
ToBackend(group->GetBindingAsSampler(binding))->GetHandle();
|
ToBackend(group->GetBindingAsSampler(bindingIndex))->GetHandle();
|
||||||
GLuint samplerIndex = indices[binding];
|
GLuint samplerIndex = indices[bindingIndex];
|
||||||
|
|
||||||
for (auto unit : pipeline->GetTextureUnitsForSampler(samplerIndex)) {
|
for (auto unit : pipeline->GetTextureUnitsForSampler(samplerIndex)) {
|
||||||
glBindSampler(unit, sampler);
|
glBindSampler(unit, sampler);
|
||||||
@ -257,10 +257,10 @@ namespace dawn_native { namespace opengl {
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dawn::BindingType::SampledTexture: {
|
case dawn::BindingType::SampledTexture: {
|
||||||
TextureView* view = ToBackend(group->GetBindingAsTextureView(binding));
|
TextureView* view = ToBackend(group->GetBindingAsTextureView(bindingIndex));
|
||||||
GLuint handle = view->GetHandle();
|
GLuint handle = view->GetHandle();
|
||||||
GLenum target = view->GetGLTarget();
|
GLenum target = view->GetGLTarget();
|
||||||
GLuint viewIndex = indices[binding];
|
GLuint viewIndex = indices[bindingIndex];
|
||||||
|
|
||||||
for (auto unit : pipeline->GetTextureUnitsForTextureView(viewIndex)) {
|
for (auto unit : pipeline->GetTextureUnitsForTextureView(viewIndex)) {
|
||||||
glActiveTexture(GL_TEXTURE0 + unit);
|
glActiveTexture(GL_TEXTURE0 + unit);
|
||||||
@ -269,12 +269,12 @@ namespace dawn_native { namespace opengl {
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dawn::BindingType::StorageBuffer: {
|
case dawn::BindingType::StorageBuffer: {
|
||||||
BufferView* view = ToBackend(group->GetBindingAsBufferView(binding));
|
BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex);
|
||||||
GLuint buffer = ToBackend(view->GetBuffer())->GetHandle();
|
GLuint buffer = ToBackend(binding.buffer)->GetHandle();
|
||||||
GLuint ssboIndex = indices[binding];
|
GLuint ssboIndex = indices[bindingIndex];
|
||||||
|
|
||||||
glBindBufferRange(GL_SHADER_STORAGE_BUFFER, ssboIndex, buffer,
|
glBindBufferRange(GL_SHADER_STORAGE_BUFFER, ssboIndex, buffer,
|
||||||
view->GetOffset(), view->GetSize());
|
binding.offset, binding.size);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,9 +75,6 @@ namespace dawn_native { namespace opengl {
|
|||||||
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
|
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
|
||||||
return new Buffer(this, descriptor);
|
return new Buffer(this, descriptor);
|
||||||
}
|
}
|
||||||
BufferViewBase* Device::CreateBufferView(BufferViewBuilder* builder) {
|
|
||||||
return new BufferView(builder);
|
|
||||||
}
|
|
||||||
CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
|
CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
|
||||||
return new CommandBuffer(builder);
|
return new CommandBuffer(builder);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,6 @@ namespace dawn_native { namespace opengl {
|
|||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
||||||
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
|
||||||
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
||||||
DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
|
DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
|
||||||
InputStateBase* CreateInputState(InputStateBuilder* builder) override;
|
InputStateBase* CreateInputState(InputStateBuilder* builder) override;
|
||||||
|
@ -29,7 +29,6 @@ namespace dawn_native { namespace opengl {
|
|||||||
using BindGroupLayout = BindGroupLayoutBase;
|
using BindGroupLayout = BindGroupLayoutBase;
|
||||||
class BlendState;
|
class BlendState;
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class BufferView;
|
|
||||||
class CommandBuffer;
|
class CommandBuffer;
|
||||||
class ComputePipeline;
|
class ComputePipeline;
|
||||||
class DepthStencilState;
|
class DepthStencilState;
|
||||||
@ -51,7 +50,6 @@ namespace dawn_native { namespace opengl {
|
|||||||
using BindGroupLayoutType = BindGroupLayout;
|
using BindGroupLayoutType = BindGroupLayout;
|
||||||
using BlendStateType = BlendState;
|
using BlendStateType = BlendState;
|
||||||
using BufferType = Buffer;
|
using BufferType = Buffer;
|
||||||
using BufferViewType = BufferView;
|
|
||||||
using CommandBufferType = CommandBuffer;
|
using CommandBufferType = CommandBuffer;
|
||||||
using ComputePipelineType = ComputePipeline;
|
using ComputePipelineType = ComputePipeline;
|
||||||
using DepthStencilStateType = DepthStencilState;
|
using DepthStencilStateType = DepthStencilState;
|
||||||
|
@ -82,12 +82,11 @@ namespace dawn_native { namespace vulkan {
|
|||||||
switch (layoutInfo.types[bindingIndex]) {
|
switch (layoutInfo.types[bindingIndex]) {
|
||||||
case dawn::BindingType::UniformBuffer:
|
case dawn::BindingType::UniformBuffer:
|
||||||
case dawn::BindingType::StorageBuffer: {
|
case dawn::BindingType::StorageBuffer: {
|
||||||
BufferViewBase* view = GetBindingAsBufferView(bindingIndex);
|
BufferBinding binding = GetBindingAsBufferBinding(bindingIndex);
|
||||||
Buffer* buffer = ToBackend(view->GetBuffer());
|
|
||||||
|
|
||||||
writeBufferInfo[numWrites].buffer = buffer->GetHandle();
|
writeBufferInfo[numWrites].buffer = ToBackend(binding.buffer)->GetHandle();
|
||||||
writeBufferInfo[numWrites].offset = view->GetOffset();
|
writeBufferInfo[numWrites].offset = binding.offset;
|
||||||
writeBufferInfo[numWrites].range = view->GetSize();
|
writeBufferInfo[numWrites].range = binding.size;
|
||||||
|
|
||||||
write.pBufferInfo = &writeBufferInfo[numWrites];
|
write.pBufferInfo = &writeBufferInfo[numWrites];
|
||||||
} break;
|
} break;
|
||||||
|
@ -52,8 +52,6 @@ namespace dawn_native { namespace vulkan {
|
|||||||
dawn::BufferUsageBit mLastUsage = dawn::BufferUsageBit::None;
|
dawn::BufferUsageBit mLastUsage = dawn::BufferUsageBit::None;
|
||||||
};
|
};
|
||||||
|
|
||||||
using BufferView = BufferViewBase;
|
|
||||||
|
|
||||||
class MapRequestTracker {
|
class MapRequestTracker {
|
||||||
public:
|
public:
|
||||||
MapRequestTracker(Device* device);
|
MapRequestTracker(Device* device);
|
||||||
|
@ -226,9 +226,6 @@ namespace dawn_native { namespace vulkan {
|
|||||||
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
|
ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
|
||||||
return new Buffer(this, descriptor);
|
return new Buffer(this, descriptor);
|
||||||
}
|
}
|
||||||
BufferViewBase* Device::CreateBufferView(BufferViewBuilder* builder) {
|
|
||||||
return new BufferView(builder);
|
|
||||||
}
|
|
||||||
CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
|
CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
|
||||||
return new CommandBuffer(builder);
|
return new CommandBuffer(builder);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,6 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
||||||
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
|
||||||
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
||||||
DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
|
DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
|
||||||
InputStateBase* CreateInputState(InputStateBuilder* builder) override;
|
InputStateBase* CreateInputState(InputStateBuilder* builder) override;
|
||||||
|
@ -17,17 +17,12 @@
|
|||||||
|
|
||||||
#include "dawn_native/ToBackend.h"
|
#include "dawn_native/ToBackend.h"
|
||||||
|
|
||||||
namespace dawn_native {
|
|
||||||
class BufferViewBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace dawn_native { namespace vulkan {
|
namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
class BindGroup;
|
class BindGroup;
|
||||||
class BindGroupLayout;
|
class BindGroupLayout;
|
||||||
class BlendState;
|
class BlendState;
|
||||||
class Buffer;
|
class Buffer;
|
||||||
using BufferView = BufferViewBase;
|
|
||||||
class CommandBuffer;
|
class CommandBuffer;
|
||||||
class ComputePipeline;
|
class ComputePipeline;
|
||||||
class DepthStencilState;
|
class DepthStencilState;
|
||||||
@ -48,7 +43,6 @@ namespace dawn_native { namespace vulkan {
|
|||||||
using BindGroupLayoutType = BindGroupLayout;
|
using BindGroupLayoutType = BindGroupLayout;
|
||||||
using BlendStateType = BlendState;
|
using BlendStateType = BlendState;
|
||||||
using BufferType = Buffer;
|
using BufferType = Buffer;
|
||||||
using BufferViewType = BufferView;
|
|
||||||
using CommandBufferType = CommandBuffer;
|
using CommandBufferType = CommandBuffer;
|
||||||
using ComputePipelineType = ComputePipeline;
|
using ComputePipelineType = ComputePipeline;
|
||||||
using DepthStencilStateType = DepthStencilState;
|
using DepthStencilStateType = DepthStencilState;
|
||||||
|
@ -66,9 +66,7 @@ TEST_P(BindGroupTests, ReusedBindGroupSingleSubmit) {
|
|||||||
bufferDesc.usage = dawn::BufferUsageBit::TransferDst |
|
bufferDesc.usage = dawn::BufferUsageBit::TransferDst |
|
||||||
dawn::BufferUsageBit::Uniform;
|
dawn::BufferUsageBit::Uniform;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&bufferDesc);
|
dawn::Buffer buffer = device.CreateBuffer(&bufferDesc);
|
||||||
dawn::BufferView bufferView =
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, sizeof(float)}});
|
||||||
buffer.CreateBufferViewBuilder().SetExtent(0, sizeof(float)).GetResult();
|
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {{0, bufferView}});
|
|
||||||
|
|
||||||
dawn::CommandBuffer cb[2];
|
dawn::CommandBuffer cb[2];
|
||||||
cb[0] = CreateSimpleComputeCommandBuffer(cp, bindGroup);
|
cb[0] = CreateSimpleComputeCommandBuffer(cp, bindGroup);
|
||||||
@ -136,13 +134,9 @@ TEST_P(BindGroupTests, ReusedUBO) {
|
|||||||
{ 0.f, 1.f, 0.f, 1.f },
|
{ 0.f, 1.f, 0.f, 1.f },
|
||||||
};
|
};
|
||||||
dawn::Buffer buffer = utils::CreateBufferFromData(device, &data, sizeof(data), dawn::BufferUsageBit::Uniform);
|
dawn::Buffer buffer = utils::CreateBufferFromData(device, &data, sizeof(data), dawn::BufferUsageBit::Uniform);
|
||||||
dawn::BufferView vertUBOBufferView =
|
|
||||||
buffer.CreateBufferViewBuilder().SetExtent(0, sizeof(Data::transform)).GetResult();
|
|
||||||
dawn::BufferView fragUBOBufferView =
|
|
||||||
buffer.CreateBufferViewBuilder().SetExtent(256, sizeof(Data::color)).GetResult();
|
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {
|
||||||
{0, vertUBOBufferView},
|
{0, buffer, 0, sizeof(Data::transform)},
|
||||||
{1, fragUBOBufferView}
|
{1, buffer, 256, sizeof(Data::color)}
|
||||||
});
|
});
|
||||||
|
|
||||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||||
@ -214,8 +208,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
|||||||
constexpr float dummy = 0.0f;
|
constexpr float dummy = 0.0f;
|
||||||
constexpr float transform[] = { 1.f, 0.f, dummy, dummy, 0.f, 1.f, dummy, dummy };
|
constexpr float transform[] = { 1.f, 0.f, dummy, dummy, 0.f, 1.f, dummy, dummy };
|
||||||
dawn::Buffer buffer = utils::CreateBufferFromData(device, &transform, sizeof(transform), dawn::BufferUsageBit::Uniform);
|
dawn::Buffer buffer = utils::CreateBufferFromData(device, &transform, sizeof(transform), dawn::BufferUsageBit::Uniform);
|
||||||
dawn::BufferView vertUBOBufferView =
|
|
||||||
buffer.CreateBufferViewBuilder().SetExtent(0, sizeof(transform)).GetResult();
|
|
||||||
dawn::SamplerDescriptor samplerDescriptor;
|
dawn::SamplerDescriptor samplerDescriptor;
|
||||||
samplerDescriptor.minFilter = dawn::FilterMode::Nearest;
|
samplerDescriptor.minFilter = dawn::FilterMode::Nearest;
|
||||||
samplerDescriptor.magFilter = dawn::FilterMode::Nearest;
|
samplerDescriptor.magFilter = dawn::FilterMode::Nearest;
|
||||||
@ -236,6 +229,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
|||||||
descriptor.usage = dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Sampled;
|
descriptor.usage = dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Sampled;
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
dawn::TextureView textureView = texture.CreateDefaultTextureView();
|
dawn::TextureView textureView = texture.CreateDefaultTextureView();
|
||||||
|
|
||||||
int width = kRTSize, height = kRTSize;
|
int width = kRTSize, height = kRTSize;
|
||||||
int widthInBytes = width * sizeof(RGBA8);
|
int widthInBytes = width * sizeof(RGBA8);
|
||||||
widthInBytes = (widthInBytes + 255) & ~255;
|
widthInBytes = (widthInBytes + 255) & ~255;
|
||||||
@ -246,8 +240,9 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
|||||||
data[i] = RGBA8(0, 255, 0, 255);
|
data[i] = RGBA8(0, 255, 0, 255);
|
||||||
}
|
}
|
||||||
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(device, data.data(), sizeInBytes, dawn::BufferUsageBit::TransferSrc);
|
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(device, data.data(), sizeInBytes, dawn::BufferUsageBit::TransferSrc);
|
||||||
|
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {
|
||||||
{0, vertUBOBufferView},
|
{0, buffer, 0, sizeof(transform)},
|
||||||
{1, sampler},
|
{1, sampler},
|
||||||
{2, textureView}
|
{2, textureView}
|
||||||
});
|
});
|
||||||
|
@ -96,12 +96,7 @@ class BlendStateTest : public DawnTest {
|
|||||||
uint32_t bufferSize = static_cast<uint32_t>(4 * N * sizeof(float));
|
uint32_t bufferSize = static_cast<uint32_t>(4 * N * sizeof(float));
|
||||||
|
|
||||||
dawn::Buffer buffer = utils::CreateBufferFromData(device, &data, bufferSize, dawn::BufferUsageBit::Uniform);
|
dawn::Buffer buffer = utils::CreateBufferFromData(device, &data, bufferSize, dawn::BufferUsageBit::Uniform);
|
||||||
|
return utils::MakeBindGroup(device, bindGroupLayout, {{0, buffer, 0, bufferSize}});
|
||||||
dawn::BufferView view = buffer.CreateBufferViewBuilder()
|
|
||||||
.SetExtent(0, bufferSize)
|
|
||||||
.GetResult();
|
|
||||||
|
|
||||||
return utils::MakeBindGroup(device, bindGroupLayout, {{0, view}});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that after drawing a triangle with the base color, and then the given triangle spec, the color is as expected
|
// Test that after drawing a triangle with the base color, and then the given triangle spec, the color is as expected
|
||||||
|
@ -57,8 +57,6 @@ void ComputeCopyStorageBufferTests::BasicTest(const char* shader) {
|
|||||||
}
|
}
|
||||||
src.SetSubData(0, sizeof(expected), reinterpret_cast<const uint8_t*>(expected.data()));
|
src.SetSubData(0, sizeof(expected), reinterpret_cast<const uint8_t*>(expected.data()));
|
||||||
EXPECT_BUFFER_U32_RANGE_EQ(expected.data(), src, 0, kNumUints);
|
EXPECT_BUFFER_U32_RANGE_EQ(expected.data(), src, 0, kNumUints);
|
||||||
auto srcView =
|
|
||||||
src.CreateBufferViewBuilder().SetExtent(0, kNumUints * sizeof(uint32_t)).GetResult();
|
|
||||||
|
|
||||||
// Set up dst storage buffer
|
// Set up dst storage buffer
|
||||||
dawn::BufferDescriptor dstDesc;
|
dawn::BufferDescriptor dstDesc;
|
||||||
@ -69,13 +67,11 @@ void ComputeCopyStorageBufferTests::BasicTest(const char* shader) {
|
|||||||
|
|
||||||
std::array<uint32_t, kNumUints> zero{};
|
std::array<uint32_t, kNumUints> zero{};
|
||||||
dst.SetSubData(0, sizeof(zero), reinterpret_cast<const uint8_t*>(zero.data()));
|
dst.SetSubData(0, sizeof(zero), reinterpret_cast<const uint8_t*>(zero.data()));
|
||||||
auto dstView =
|
|
||||||
dst.CreateBufferViewBuilder().SetExtent(0, kNumUints * sizeof(uint32_t)).GetResult();
|
|
||||||
|
|
||||||
// Set up bind group and issue dispatch
|
// Set up bind group and issue dispatch
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {
|
||||||
{0, srcView},
|
{0, src, 0, kNumUints * sizeof(uint32_t)},
|
||||||
{1, dstView},
|
{1, dst, 0, kNumUints * sizeof(uint32_t)},
|
||||||
});
|
});
|
||||||
|
|
||||||
dawn::CommandBuffer commands;
|
dawn::CommandBuffer commands;
|
||||||
|
@ -209,12 +209,8 @@ class DepthStencilStateTest : public DawnTest {
|
|||||||
// Upload a buffer for each triangle's depth and color data
|
// Upload a buffer for each triangle's depth and color data
|
||||||
dawn::Buffer buffer = utils::CreateBufferFromData(device, &data, sizeof(TriangleData), dawn::BufferUsageBit::Uniform);
|
dawn::Buffer buffer = utils::CreateBufferFromData(device, &data, sizeof(TriangleData), dawn::BufferUsageBit::Uniform);
|
||||||
|
|
||||||
dawn::BufferView view = buffer.CreateBufferViewBuilder()
|
|
||||||
.SetExtent(0, sizeof(TriangleData))
|
|
||||||
.GetResult();
|
|
||||||
|
|
||||||
// Create a bind group for the data
|
// Create a bind group for the data
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bindGroupLayout, {{0, view}});
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bindGroupLayout, {{0, buffer, 0, sizeof(TriangleData)}});
|
||||||
|
|
||||||
// Create a pipeline for the triangles with the test spec's depth stencil state
|
// Create a pipeline for the triangles with the test spec's depth stencil state
|
||||||
dawn::RenderPipeline pipeline = device.CreateRenderPipelineBuilder()
|
dawn::RenderPipeline pipeline = device.CreateRenderPipelineBuilder()
|
||||||
|
@ -51,20 +51,15 @@ class PushConstantTest: public DawnTest {
|
|||||||
|
|
||||||
dawn::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
dawn::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||||
|
|
||||||
dawn::BufferView views[2] = {
|
|
||||||
buf1.CreateBufferViewBuilder().SetExtent(0, 4).GetResult(),
|
|
||||||
buf2.CreateBufferViewBuilder().SetExtent(0, 4).GetResult(),
|
|
||||||
};
|
|
||||||
|
|
||||||
dawn::BindGroup bg;
|
dawn::BindGroup bg;
|
||||||
if (extraBuffer) {
|
if (extraBuffer) {
|
||||||
bg = utils::MakeBindGroup(device, bgl, {
|
bg = utils::MakeBindGroup(device, bgl, {
|
||||||
{0, views[0]},
|
{0, buf1, 0, 4},
|
||||||
{1, views[1]},
|
{1, buf2, 0, 4},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
bg = utils::MakeBindGroup(device, bgl, {
|
bg = utils::MakeBindGroup(device, bgl, {
|
||||||
{0, views[0]},
|
{0, buf1, 0, 4},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -504,12 +504,12 @@ TEST_F(WireTests, OptionalObjectValue) {
|
|||||||
EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _))
|
EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _))
|
||||||
.WillOnce(Return(apiBindGroupLayout));
|
.WillOnce(Return(apiBindGroupLayout));
|
||||||
|
|
||||||
// The `sampler`, `textureView` and `bufferView` members of a binding are optional.
|
// The `sampler`, `textureView` and `buffer` members of a binding are optional.
|
||||||
dawnBindGroupBinding binding;
|
dawnBindGroupBinding binding;
|
||||||
binding.binding = 0;
|
binding.binding = 0;
|
||||||
binding.sampler = nullptr;
|
binding.sampler = nullptr;
|
||||||
binding.textureView = nullptr;
|
binding.textureView = nullptr;
|
||||||
binding.bufferView = nullptr;
|
binding.buffer = nullptr;
|
||||||
|
|
||||||
dawnBindGroupDescriptor bgDesc;
|
dawnBindGroupDescriptor bgDesc;
|
||||||
bgDesc.nextInChain = nullptr;
|
bgDesc.nextInChain = nullptr;
|
||||||
@ -523,7 +523,7 @@ TEST_F(WireTests, OptionalObjectValue) {
|
|||||||
desc->numBindings == 1 &&
|
desc->numBindings == 1 &&
|
||||||
desc->bindings[0].binding == 0 &&
|
desc->bindings[0].binding == 0 &&
|
||||||
desc->bindings[0].sampler == nullptr &&
|
desc->bindings[0].sampler == nullptr &&
|
||||||
desc->bindings[0].bufferView == nullptr &&
|
desc->bindings[0].buffer == nullptr &&
|
||||||
desc->bindings[0].textureView == nullptr;
|
desc->bindings[0].textureView == nullptr;
|
||||||
})))
|
})))
|
||||||
.WillOnce(Return(nullptr));
|
.WillOnce(Return(nullptr));
|
||||||
|
@ -135,7 +135,9 @@ TEST_F(BindGroupValidationTest, SamplerBindingType) {
|
|||||||
binding.binding = 0;
|
binding.binding = 0;
|
||||||
binding.sampler = nullptr;
|
binding.sampler = nullptr;
|
||||||
binding.textureView = nullptr;
|
binding.textureView = nullptr;
|
||||||
binding.bufferView = nullptr;
|
binding.buffer = nullptr;
|
||||||
|
binding.offset = 0;
|
||||||
|
binding.size = 0;
|
||||||
|
|
||||||
dawn::BindGroupDescriptor descriptor;
|
dawn::BindGroupDescriptor descriptor;
|
||||||
descriptor.nextInChain = nullptr;
|
descriptor.nextInChain = nullptr;
|
||||||
@ -155,10 +157,10 @@ TEST_F(BindGroupValidationTest, SamplerBindingType) {
|
|||||||
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
||||||
binding.textureView = nullptr;
|
binding.textureView = nullptr;
|
||||||
|
|
||||||
// Setting the buffer view as well is an error
|
// Setting the buffer as well is an error
|
||||||
binding.bufferView = mUBO.CreateBufferViewBuilder().SetExtent(0, 256).GetResult();
|
binding.buffer = mUBO;
|
||||||
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
||||||
binding.bufferView = nullptr;
|
binding.buffer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that a texture binding must contain exactly a texture view
|
// Check that a texture binding must contain exactly a texture view
|
||||||
@ -171,7 +173,9 @@ TEST_F(BindGroupValidationTest, TextureBindingType) {
|
|||||||
binding.binding = 0;
|
binding.binding = 0;
|
||||||
binding.sampler = nullptr;
|
binding.sampler = nullptr;
|
||||||
binding.textureView = nullptr;
|
binding.textureView = nullptr;
|
||||||
binding.bufferView = nullptr;
|
binding.buffer = nullptr;
|
||||||
|
binding.offset = 0;
|
||||||
|
binding.size = 0;
|
||||||
|
|
||||||
dawn::BindGroupDescriptor descriptor;
|
dawn::BindGroupDescriptor descriptor;
|
||||||
descriptor.nextInChain = nullptr;
|
descriptor.nextInChain = nullptr;
|
||||||
@ -191,13 +195,13 @@ TEST_F(BindGroupValidationTest, TextureBindingType) {
|
|||||||
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
||||||
binding.textureView = nullptr;
|
binding.textureView = nullptr;
|
||||||
|
|
||||||
// Setting the buffer view as well is an error
|
// Setting the buffer as well is an error
|
||||||
binding.bufferView = mUBO.CreateBufferViewBuilder().SetExtent(0, 256).GetResult();
|
binding.buffer = mUBO;
|
||||||
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
||||||
binding.bufferView = nullptr;
|
binding.buffer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that a buffer binding must contain exactly a buffer view
|
// Check that a buffer binding must contain exactly a buffer
|
||||||
TEST_F(BindGroupValidationTest, BufferBindingType) {
|
TEST_F(BindGroupValidationTest, BufferBindingType) {
|
||||||
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {
|
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {
|
||||||
{0, dawn::ShaderStageBit::Fragment, dawn::BindingType::UniformBuffer}
|
{0, dawn::ShaderStageBit::Fragment, dawn::BindingType::UniformBuffer}
|
||||||
@ -207,7 +211,9 @@ TEST_F(BindGroupValidationTest, BufferBindingType) {
|
|||||||
binding.binding = 0;
|
binding.binding = 0;
|
||||||
binding.sampler = nullptr;
|
binding.sampler = nullptr;
|
||||||
binding.textureView = nullptr;
|
binding.textureView = nullptr;
|
||||||
binding.bufferView = nullptr;
|
binding.buffer = nullptr;
|
||||||
|
binding.offset = 0;
|
||||||
|
binding.size = 0;
|
||||||
|
|
||||||
dawn::BindGroupDescriptor descriptor;
|
dawn::BindGroupDescriptor descriptor;
|
||||||
descriptor.nextInChain = nullptr;
|
descriptor.nextInChain = nullptr;
|
||||||
@ -218,8 +224,8 @@ TEST_F(BindGroupValidationTest, BufferBindingType) {
|
|||||||
// Not setting anything fails
|
// Not setting anything fails
|
||||||
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
||||||
|
|
||||||
// Control case: setting just the buffer view works
|
// Control case: setting just the buffer works
|
||||||
binding.bufferView = mUBO.CreateBufferViewBuilder().SetExtent(0, 256).GetResult();
|
binding.buffer = mUBO;
|
||||||
device.CreateBindGroup(&descriptor);
|
device.CreateBindGroup(&descriptor);
|
||||||
|
|
||||||
// Setting the texture view as well is an error
|
// Setting the texture view as well is an error
|
||||||
@ -261,14 +267,11 @@ TEST_F(BindGroupValidationTest, BufferUsageUBO) {
|
|||||||
{0, dawn::ShaderStageBit::Fragment, dawn::BindingType::UniformBuffer}
|
{0, dawn::ShaderStageBit::Fragment, dawn::BindingType::UniformBuffer}
|
||||||
});
|
});
|
||||||
|
|
||||||
dawn::BufferView uboView = mUBO.CreateBufferViewBuilder().SetExtent(0, 256).GetResult();
|
|
||||||
dawn::BufferView ssboView = mSSBO.CreateBufferViewBuilder().SetExtent(0, 256).GetResult();
|
|
||||||
|
|
||||||
// Control case: using a buffer with the uniform usage works
|
// Control case: using a buffer with the uniform usage works
|
||||||
utils::MakeBindGroup(device, layout, {{0, uboView}});
|
utils::MakeBindGroup(device, layout, {{0, mUBO, 0, 256}});
|
||||||
|
|
||||||
// Using a buffer without the uniform usage fails
|
// Using a buffer without the uniform usage fails
|
||||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, ssboView}}));
|
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, mSSBO, 0, 256}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that a SSBO must have the correct usage
|
// Check that a SSBO must have the correct usage
|
||||||
@ -277,57 +280,63 @@ TEST_F(BindGroupValidationTest, BufferUsageSSBO) {
|
|||||||
{0, dawn::ShaderStageBit::Fragment, dawn::BindingType::StorageBuffer}
|
{0, dawn::ShaderStageBit::Fragment, dawn::BindingType::StorageBuffer}
|
||||||
});
|
});
|
||||||
|
|
||||||
dawn::BufferView uboView = mUBO.CreateBufferViewBuilder().SetExtent(0, 256).GetResult();
|
|
||||||
dawn::BufferView ssboView = mSSBO.CreateBufferViewBuilder().SetExtent(0, 256).GetResult();
|
|
||||||
|
|
||||||
// Control case: using a buffer with the storage usage works
|
// Control case: using a buffer with the storage usage works
|
||||||
utils::MakeBindGroup(device, layout, {{0, ssboView}});
|
utils::MakeBindGroup(device, layout, {{0, mSSBO, 0, 256}});
|
||||||
|
|
||||||
// Using a buffer without the storage usage fails
|
// Using a buffer without the storage usage fails
|
||||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, uboView}}));
|
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, mUBO, 0, 256}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests constraints on the buffer view offset for bind groups.
|
// Tests constraints on the buffer offset for bind groups.
|
||||||
TEST_F(BindGroupValidationTest, BufferViewOffset) {
|
TEST_F(BindGroupValidationTest, BufferOffsetAlignment) {
|
||||||
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {
|
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {
|
||||||
{0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
|
{0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check that offset 0 is valid
|
// Check that offset 0 is valid
|
||||||
{
|
utils::MakeBindGroup(device, layout, {{0, mUBO, 0, 512}});
|
||||||
dawn::BufferView bufferView = mUBO.CreateBufferViewBuilder()
|
|
||||||
.SetExtent(0, 512)
|
|
||||||
.GetResult();
|
|
||||||
utils::MakeBindGroup(device, layout, {{0, bufferView}});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that offset 256 (aligned) is valid
|
// Check that offset 256 (aligned) is valid
|
||||||
{
|
utils::MakeBindGroup(device, layout, {{0, mUBO, 256, 256}});
|
||||||
dawn::BufferView bufferView = mUBO.CreateBufferViewBuilder()
|
|
||||||
.SetExtent(256, 256)
|
|
||||||
.GetResult();
|
|
||||||
utils::MakeBindGroup(device, layout, {{0, bufferView}});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check cases where unaligned buffer view offset is invalid
|
// Check cases where unaligned buffer offset is invalid
|
||||||
{
|
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, mUBO, 1, 256}}));
|
||||||
dawn::BufferView bufferView = mUBO.CreateBufferViewBuilder()
|
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, mUBO, 128, 256}}));
|
||||||
.SetExtent(1, 256)
|
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, mUBO, 255, 256}}));
|
||||||
.GetResult();
|
}
|
||||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, bufferView}}));
|
|
||||||
}
|
// Tests constraints to be sure the buffer binding fits in the buffer
|
||||||
{
|
TEST_F(BindGroupValidationTest, BufferBindingOOB) {
|
||||||
dawn::BufferView bufferView = mUBO.CreateBufferViewBuilder()
|
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {
|
||||||
.SetExtent(128, 256)
|
{0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
|
||||||
.GetResult();
|
});
|
||||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, bufferView}}));
|
|
||||||
}
|
dawn::BufferDescriptor descriptor;
|
||||||
{
|
descriptor.size = 1024;
|
||||||
dawn::BufferView bufferView = mUBO.CreateBufferViewBuilder()
|
descriptor.usage = dawn::BufferUsageBit::Uniform;
|
||||||
.SetExtent(255, 256)
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
.GetResult();
|
|
||||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, bufferView}}));
|
// Success case, touching the start of the buffer works
|
||||||
}
|
utils::MakeBindGroup(device, layout, {{0, buffer, 0, 256}});
|
||||||
|
|
||||||
|
// Success case, touching the end of the buffer works
|
||||||
|
utils::MakeBindGroup(device, layout, {{0, buffer, 3*256, 256}});
|
||||||
|
utils::MakeBindGroup(device, layout, {{0, buffer, 1024, 0}});
|
||||||
|
|
||||||
|
// Success case, touching the full buffer works
|
||||||
|
utils::MakeBindGroup(device, layout, {{0, buffer, 0, 1024}});
|
||||||
|
|
||||||
|
// Error case, offset is OOB
|
||||||
|
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 256*5, 0}}));
|
||||||
|
|
||||||
|
// Error case, size is OOB
|
||||||
|
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 0, 256*5}}));
|
||||||
|
|
||||||
|
// Error case, offset+size is OOB
|
||||||
|
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 1024, 1}}));
|
||||||
|
|
||||||
|
// Error case, offset+size overflows to be 0
|
||||||
|
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 256, uint32_t(0) - uint32_t(256)}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
class BindGroupLayoutValidationTest : public ValidationTest {
|
class BindGroupLayoutValidationTest : public ValidationTest {
|
||||||
|
@ -74,8 +74,7 @@ TEST_F(CommandBufferValidationTest, BufferWithReadAndWriteUsage) {
|
|||||||
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout(device, {{
|
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout(device, {{
|
||||||
0, dawn::ShaderStageBit::Vertex, dawn::BindingType::StorageBuffer
|
0, dawn::ShaderStageBit::Vertex, dawn::BindingType::StorageBuffer
|
||||||
}});
|
}});
|
||||||
dawn::BufferView view = buffer.CreateBufferViewBuilder().SetExtent(0, 4).GetResult();
|
dawn::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, 4}});
|
||||||
dawn::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}});
|
|
||||||
|
|
||||||
// Use the buffer as both index and storage in the same pass
|
// Use the buffer as both index and storage in the same pass
|
||||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||||
|
@ -236,8 +236,10 @@ namespace utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BindingInitializationHelper::BindingInitializationHelper(uint32_t binding,
|
BindingInitializationHelper::BindingInitializationHelper(uint32_t binding,
|
||||||
const dawn::BufferView& bufferView)
|
const dawn::Buffer& buffer,
|
||||||
: binding(binding), bufferView(bufferView) {
|
uint32_t offset,
|
||||||
|
uint32_t size)
|
||||||
|
: binding(binding), buffer(buffer), offset(offset), size(size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::BindGroupBinding BindingInitializationHelper::GetAsBinding() const {
|
dawn::BindGroupBinding BindingInitializationHelper::GetAsBinding() const {
|
||||||
@ -246,7 +248,9 @@ namespace utils {
|
|||||||
result.binding = binding;
|
result.binding = binding;
|
||||||
result.sampler = sampler;
|
result.sampler = sampler;
|
||||||
result.textureView = textureView;
|
result.textureView = textureView;
|
||||||
result.bufferView = bufferView;
|
result.buffer = buffer;
|
||||||
|
result.offset = offset;
|
||||||
|
result.size = size;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ namespace utils {
|
|||||||
//
|
//
|
||||||
// utils::MakeBindGroup(device, layout, {
|
// utils::MakeBindGroup(device, layout, {
|
||||||
// {0, mySampler},
|
// {0, mySampler},
|
||||||
// {1, myBufferView},
|
// {1, myBuffer, offset, size},
|
||||||
// {3, myTexture}
|
// {3, myTexture}
|
||||||
// });
|
// });
|
||||||
|
|
||||||
@ -78,14 +78,19 @@ namespace utils {
|
|||||||
struct BindingInitializationHelper {
|
struct BindingInitializationHelper {
|
||||||
BindingInitializationHelper(uint32_t binding, const dawn::Sampler& sampler);
|
BindingInitializationHelper(uint32_t binding, const dawn::Sampler& sampler);
|
||||||
BindingInitializationHelper(uint32_t binding, const dawn::TextureView& textureView);
|
BindingInitializationHelper(uint32_t binding, const dawn::TextureView& textureView);
|
||||||
BindingInitializationHelper(uint32_t binding, const dawn::BufferView& bufferView);
|
BindingInitializationHelper(uint32_t binding,
|
||||||
|
const dawn::Buffer& buffer,
|
||||||
|
uint32_t offset,
|
||||||
|
uint32_t size);
|
||||||
|
|
||||||
dawn::BindGroupBinding GetAsBinding() const;
|
dawn::BindGroupBinding GetAsBinding() const;
|
||||||
|
|
||||||
uint32_t binding;
|
uint32_t binding;
|
||||||
dawn::Sampler sampler;
|
dawn::Sampler sampler;
|
||||||
dawn::TextureView textureView;
|
dawn::TextureView textureView;
|
||||||
dawn::BufferView bufferView;
|
dawn::Buffer buffer;
|
||||||
|
uint32_t offset = 0;
|
||||||
|
uint32_t size = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
dawn::BindGroup MakeBindGroup(
|
dawn::BindGroup MakeBindGroup(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user