Add missing WebGPU enums and defaulted members.
These additions to dawn.json don't require changes to users of the C++ API so they are done now to prepare for webgpu.h. Validation is added that forbids using the new enum values and non-default values for members until they are implemented. BUG=dawn:22 Change-Id: Ie6f3384243d6874e7aca4b94733409755a066c93 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8862 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
dd15b11b21
commit
f07e85c604
27
dawn.json
27
dawn.json
|
@ -56,7 +56,8 @@
|
|||
{"name": "binding", "type": "uint32_t"},
|
||||
{"name": "visibility", "type": "shader stage bit"},
|
||||
{"name": "type", "type": "binding type"},
|
||||
{"name": "dynamic", "type": "bool", "default": "false" }
|
||||
{"name": "dynamic", "type": "bool", "default": "false" },
|
||||
{"name": "multisampled", "type": "bool", "default": "false" }
|
||||
]
|
||||
},
|
||||
"bind group layout descriptor": {
|
||||
|
@ -72,8 +73,10 @@
|
|||
"values": [
|
||||
{"value": 0, "name": "uniform buffer"},
|
||||
{"value": 1, "name": "storage buffer"},
|
||||
{"value": 2, "name": "sampler"},
|
||||
{"value": 3, "name": "sampled texture"}
|
||||
{"value": 2, "name": "readonly storage buffer"},
|
||||
{"value": 3, "name": "sampler"},
|
||||
{"value": 4, "name": "sampled texture"},
|
||||
{"value": 5, "name": "storage texture"}
|
||||
]
|
||||
},
|
||||
"blend descriptor": {
|
||||
|
@ -906,7 +909,9 @@
|
|||
{"name": "sample count", "type": "uint32_t", "default": "1"},
|
||||
{"name": "depth stencil state", "type": "depth stencil state descriptor", "annotation": "const*", "optional": true},
|
||||
{"name": "color state count", "type": "uint32_t"},
|
||||
{"name": "color states", "type": "color state descriptor", "annotation": "const*const*", "length": "color state count"}
|
||||
{"name": "color states", "type": "color state descriptor", "annotation": "const*const*", "length": "color state count"},
|
||||
{"name": "sample mask", "type": "uint32_t", "default": "0xFFFFFFFF"},
|
||||
{"name": "alpha to coverage enabled", "type": "bool", "default": "false"}
|
||||
]
|
||||
},
|
||||
"sampler": {
|
||||
|
@ -1054,7 +1059,9 @@
|
|||
"texture dimension": {
|
||||
"category": "enum",
|
||||
"values": [
|
||||
{"value": 0, "name": "2D"}
|
||||
{"value": 0, "name": "1D"},
|
||||
{"value": 1, "name": "2D"},
|
||||
{"value": 2, "name": "3D"}
|
||||
]
|
||||
},
|
||||
"texture format": {
|
||||
|
@ -1162,10 +1169,12 @@
|
|||
"texture view dimension": {
|
||||
"category": "enum",
|
||||
"values": [
|
||||
{"value": 0, "name": "2D"},
|
||||
{"value": 1, "name": "2D array"},
|
||||
{"value": 2, "name": "cube"},
|
||||
{"value": 3, "name": "cube array"}
|
||||
{"value": 0, "name": "1D"},
|
||||
{"value": 1, "name": "2D"},
|
||||
{"value": 2, "name": "2D array"},
|
||||
{"value": 3, "name": "cube"},
|
||||
{"value": 4, "name": "cube array"},
|
||||
{"value": 5, "name": "3D"}
|
||||
],
|
||||
"TODO": [
|
||||
"jiawei.shao@intel.com: support 1D and 3D texture views"
|
||||
|
|
|
@ -112,6 +112,8 @@ void init() {
|
|||
descriptor.rasterizationState = &rasterizationState;
|
||||
|
||||
descriptor.primitiveTopology = DAWN_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||
descriptor.sampleMask = 0xFFFFFFFF;
|
||||
descriptor.alphaToCoverageEnabled = false;
|
||||
|
||||
descriptor.depthStencilState = nullptr;
|
||||
|
||||
|
|
|
@ -138,6 +138,10 @@ namespace dawn_native {
|
|||
case dawn::BindingType::Sampler:
|
||||
DAWN_TRY(ValidateSamplerBinding(device, binding));
|
||||
break;
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,15 @@ namespace dawn_native {
|
|||
return DAWN_VALIDATION_ERROR("Samplers and textures cannot be dynamic");
|
||||
}
|
||||
break;
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
return DAWN_VALIDATION_ERROR("readonly storage buffers aren't supported (yet)");
|
||||
case dawn::BindingType::StorageTexture:
|
||||
return DAWN_VALIDATION_ERROR("storage textures aren't supported (yet)");
|
||||
}
|
||||
|
||||
if (binding.multisampled) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"BindGroupLayoutBinding::multisampled must be false (for now)");
|
||||
}
|
||||
|
||||
bindingsSet.set(binding.binding);
|
||||
|
@ -62,6 +71,7 @@ namespace dawn_native {
|
|||
namespace {
|
||||
size_t HashBindingInfo(const BindGroupLayoutBase::LayoutBindingInfo& info) {
|
||||
size_t hash = Hash(info.mask);
|
||||
HashCombine(&hash, info.dynamic, info.multisampled);
|
||||
|
||||
for (uint32_t binding : IterateBitSet(info.mask)) {
|
||||
HashCombine(&hash, info.visibilities[binding], info.types[binding]);
|
||||
|
@ -72,7 +82,7 @@ namespace dawn_native {
|
|||
|
||||
bool operator==(const BindGroupLayoutBase::LayoutBindingInfo& a,
|
||||
const BindGroupLayoutBase::LayoutBindingInfo& b) {
|
||||
if (a.mask != b.mask) {
|
||||
if (a.mask != b.mask || a.dynamic != b.dynamic || a.multisampled != b.multisampled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -105,6 +115,8 @@ namespace dawn_native {
|
|||
mDynamicBufferCount++;
|
||||
}
|
||||
|
||||
mBindingInfo.multisampled.set(index, binding.multisampled);
|
||||
|
||||
ASSERT(!mBindingInfo.mask[index]);
|
||||
mBindingInfo.mask.set(index);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ namespace dawn_native {
|
|||
std::array<dawn::ShaderStageBit, kMaxBindingsPerGroup> visibilities;
|
||||
std::array<dawn::BindingType, kMaxBindingsPerGroup> types;
|
||||
std::bitset<kMaxBindingsPerGroup> dynamic;
|
||||
std::bitset<kMaxBindingsPerGroup> multisampled;
|
||||
std::bitset<kMaxBindingsPerGroup> mask;
|
||||
};
|
||||
const LayoutBindingInfo& GetBindingInfo() const;
|
||||
|
|
|
@ -610,6 +610,11 @@ namespace dawn_native {
|
|||
|
||||
case dawn::BindingType::Sampler:
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -305,6 +305,14 @@ namespace dawn_native {
|
|||
DAWN_TRY(ValidateDepthStencilStateDescriptor(descriptor->depthStencilState));
|
||||
}
|
||||
|
||||
if (descriptor->sampleMask != 0xFFFFFFFF) {
|
||||
return DAWN_VALIDATION_ERROR("sampleMask must be 0xFFFFFFFF (for now)");
|
||||
}
|
||||
|
||||
if (descriptor->alphaToCoverageEnabled) {
|
||||
return DAWN_VALIDATION_ERROR("alphaToCoverageEnabled isn't supported (yet)");
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -341,6 +349,8 @@ namespace dawn_native {
|
|||
mPrimitiveTopology(descriptor->primitiveTopology),
|
||||
mRasterizationState(*descriptor->rasterizationState),
|
||||
mSampleCount(descriptor->sampleCount),
|
||||
mSampleMask(descriptor->sampleMask),
|
||||
mAlphaToCoverageEnabled(descriptor->alphaToCoverageEnabled),
|
||||
mVertexModule(descriptor->vertexStage->module),
|
||||
mVertexEntryPoint(descriptor->vertexStage->entryPoint),
|
||||
mFragmentModule(descriptor->fragmentStage->module),
|
||||
|
@ -589,7 +599,8 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
// Hash other state
|
||||
HashCombine(&hash, pipeline->mSampleCount, pipeline->mPrimitiveTopology);
|
||||
HashCombine(&hash, pipeline->mSampleCount, pipeline->mPrimitiveTopology,
|
||||
pipeline->mSampleMask, pipeline->mAlphaToCoverageEnabled);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
@ -700,7 +711,9 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
// Check other state
|
||||
if (a->mSampleCount != b->mSampleCount || a->mPrimitiveTopology != b->mPrimitiveTopology) {
|
||||
if (a->mSampleCount != b->mSampleCount || a->mPrimitiveTopology != b->mPrimitiveTopology ||
|
||||
a->mSampleMask != b->mSampleMask ||
|
||||
a->mAlphaToCoverageEnabled != b->mAlphaToCoverageEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,6 +111,8 @@ namespace dawn_native {
|
|||
dawn::PrimitiveTopology mPrimitiveTopology;
|
||||
RasterizationStateDescriptor mRasterizationState;
|
||||
uint32_t mSampleCount;
|
||||
uint32_t mSampleMask;
|
||||
bool mAlphaToCoverageEnabled;
|
||||
|
||||
// Stage information
|
||||
// TODO(cwallez@chromium.org): Store a crypto hash of the modules instead.
|
||||
|
|
|
@ -323,6 +323,10 @@ namespace dawn_native {
|
|||
"Non-renderable format used with OutputAttachment usage");
|
||||
}
|
||||
|
||||
if (descriptor->usage & dawn::TextureUsageBit::Storage) {
|
||||
return DAWN_VALIDATION_ERROR("storage textures aren't supported (yet)");
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -347,6 +351,10 @@ namespace dawn_native {
|
|||
return DAWN_VALIDATION_ERROR("Cannot create an empty texture");
|
||||
}
|
||||
|
||||
if (descriptor->dimension != dawn::TextureDimension::e2D) {
|
||||
return DAWN_VALIDATION_ERROR("Texture dimension must be 2D (for now)");
|
||||
}
|
||||
|
||||
DAWN_TRY(ValidateTextureSize(descriptor, format));
|
||||
|
||||
return {};
|
||||
|
|
|
@ -96,6 +96,11 @@ namespace dawn_native { namespace d3d12 {
|
|||
bindingOffsets[bindingIndex]));
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
|
||||
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,12 @@ namespace dawn_native { namespace d3d12 {
|
|||
case dawn::BindingType::Sampler:
|
||||
mBindingOffsets[binding] = mDescriptorCounts[Sampler]++;
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
|
||||
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
||||
}
|
||||
}
|
||||
|
@ -96,6 +102,12 @@ namespace dawn_native { namespace d3d12 {
|
|||
case dawn::BindingType::Sampler:
|
||||
mBindingOffsets[binding] += descriptorOffsets[Sampler];
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
|
||||
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -292,6 +292,11 @@ namespace dawn_native { namespace metal {
|
|||
[compute setTexture:textureView->GetMTLTexture() atIndex:computeIndex];
|
||||
}
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,10 @@ namespace dawn_native { namespace metal {
|
|||
mIndexInfo[stage][group][binding] = textureIndex;
|
||||
textureIndex++;
|
||||
break;
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,8 @@ namespace dawn_native { namespace metal {
|
|||
} else {
|
||||
return (arrayLayers > 1) ? MTLTextureType2DArray : MTLTextureType2D;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -266,6 +266,11 @@ namespace dawn_native { namespace opengl {
|
|||
binding.offset, binding.size);
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
|
||||
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,6 +135,11 @@ namespace dawn_native { namespace opengl {
|
|||
// emulation
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
|
||||
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,11 @@ namespace dawn_native { namespace opengl {
|
|||
ssboIndex++;
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
|
||||
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,6 +179,8 @@ TEST_F(WireArgumentTests, CStringArgument) {
|
|||
pipelineDescriptor.colorStates = colorStatesPtr;
|
||||
|
||||
pipelineDescriptor.sampleCount = 1;
|
||||
pipelineDescriptor.sampleMask = 0xFFFFFFFF;
|
||||
pipelineDescriptor.alphaToCoverageEnabled = false;
|
||||
pipelineDescriptor.layout = layout;
|
||||
pipelineDescriptor.vertexInput = &vertexInput;
|
||||
pipelineDescriptor.primitiveTopology = DAWN_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||
|
@ -330,12 +332,12 @@ TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
|
|||
TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) {
|
||||
static constexpr int NUM_BINDINGS = 3;
|
||||
DawnBindGroupLayoutBinding bindings[NUM_BINDINGS]{
|
||||
{0, DAWN_SHADER_STAGE_BIT_VERTEX, DAWN_BINDING_TYPE_SAMPLER},
|
||||
{1, DAWN_SHADER_STAGE_BIT_VERTEX, DAWN_BINDING_TYPE_SAMPLED_TEXTURE},
|
||||
{0, DAWN_SHADER_STAGE_BIT_VERTEX, DAWN_BINDING_TYPE_SAMPLER, false, false},
|
||||
{1, DAWN_SHADER_STAGE_BIT_VERTEX, DAWN_BINDING_TYPE_SAMPLED_TEXTURE, false, false},
|
||||
{2,
|
||||
static_cast<DawnShaderStageBit>(DAWN_SHADER_STAGE_BIT_VERTEX |
|
||||
DAWN_SHADER_STAGE_BIT_FRAGMENT),
|
||||
DAWN_BINDING_TYPE_UNIFORM_BUFFER},
|
||||
DAWN_BINDING_TYPE_UNIFORM_BUFFER, false, false},
|
||||
};
|
||||
DawnBindGroupLayoutDescriptor bglDescriptor;
|
||||
bglDescriptor.bindingCount = NUM_BINDINGS;
|
||||
|
|
|
@ -149,6 +149,8 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
|
|||
pipelineDescriptor.colorStates = colorStatesPtr;
|
||||
|
||||
pipelineDescriptor.sampleCount = 1;
|
||||
pipelineDescriptor.sampleMask = 0xFFFFFFFF;
|
||||
pipelineDescriptor.alphaToCoverageEnabled = false;
|
||||
pipelineDescriptor.layout = layout;
|
||||
pipelineDescriptor.vertexInput = &vertexInput;
|
||||
pipelineDescriptor.primitiveTopology = DAWN_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||
|
|
Loading…
Reference in New Issue