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:
Corentin Wallez 2019-07-15 20:47:56 +00:00 committed by Commit Bot service account
parent dd15b11b21
commit f07e85c604
19 changed files with 123 additions and 20 deletions

View File

@ -56,7 +56,8 @@
{"name": "binding", "type": "uint32_t"}, {"name": "binding", "type": "uint32_t"},
{"name": "visibility", "type": "shader stage bit"}, {"name": "visibility", "type": "shader stage bit"},
{"name": "type", "type": "binding type"}, {"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": { "bind group layout descriptor": {
@ -72,8 +73,10 @@
"values": [ "values": [
{"value": 0, "name": "uniform buffer"}, {"value": 0, "name": "uniform buffer"},
{"value": 1, "name": "storage buffer"}, {"value": 1, "name": "storage buffer"},
{"value": 2, "name": "sampler"}, {"value": 2, "name": "readonly storage buffer"},
{"value": 3, "name": "sampled texture"} {"value": 3, "name": "sampler"},
{"value": 4, "name": "sampled texture"},
{"value": 5, "name": "storage texture"}
] ]
}, },
"blend descriptor": { "blend descriptor": {
@ -906,7 +909,9 @@
{"name": "sample count", "type": "uint32_t", "default": "1"}, {"name": "sample count", "type": "uint32_t", "default": "1"},
{"name": "depth stencil state", "type": "depth stencil state descriptor", "annotation": "const*", "optional": true}, {"name": "depth stencil state", "type": "depth stencil state descriptor", "annotation": "const*", "optional": true},
{"name": "color state count", "type": "uint32_t"}, {"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": { "sampler": {
@ -1054,7 +1059,9 @@
"texture dimension": { "texture dimension": {
"category": "enum", "category": "enum",
"values": [ "values": [
{"value": 0, "name": "2D"} {"value": 0, "name": "1D"},
{"value": 1, "name": "2D"},
{"value": 2, "name": "3D"}
] ]
}, },
"texture format": { "texture format": {
@ -1162,10 +1169,12 @@
"texture view dimension": { "texture view dimension": {
"category": "enum", "category": "enum",
"values": [ "values": [
{"value": 0, "name": "2D"}, {"value": 0, "name": "1D"},
{"value": 1, "name": "2D array"}, {"value": 1, "name": "2D"},
{"value": 2, "name": "cube"}, {"value": 2, "name": "2D array"},
{"value": 3, "name": "cube array"} {"value": 3, "name": "cube"},
{"value": 4, "name": "cube array"},
{"value": 5, "name": "3D"}
], ],
"TODO": [ "TODO": [
"jiawei.shao@intel.com: support 1D and 3D texture views" "jiawei.shao@intel.com: support 1D and 3D texture views"

View File

@ -112,6 +112,8 @@ void init() {
descriptor.rasterizationState = &rasterizationState; descriptor.rasterizationState = &rasterizationState;
descriptor.primitiveTopology = DAWN_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; descriptor.primitiveTopology = DAWN_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
descriptor.sampleMask = 0xFFFFFFFF;
descriptor.alphaToCoverageEnabled = false;
descriptor.depthStencilState = nullptr; descriptor.depthStencilState = nullptr;

View File

@ -138,6 +138,10 @@ namespace dawn_native {
case dawn::BindingType::Sampler: case dawn::BindingType::Sampler:
DAWN_TRY(ValidateSamplerBinding(device, binding)); DAWN_TRY(ValidateSamplerBinding(device, binding));
break; break;
case dawn::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer:
UNREACHABLE();
break;
} }
} }

View File

@ -52,6 +52,15 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR("Samplers and textures cannot be dynamic"); return DAWN_VALIDATION_ERROR("Samplers and textures cannot be dynamic");
} }
break; 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); bindingsSet.set(binding.binding);
@ -62,6 +71,7 @@ namespace dawn_native {
namespace { namespace {
size_t HashBindingInfo(const BindGroupLayoutBase::LayoutBindingInfo& info) { size_t HashBindingInfo(const BindGroupLayoutBase::LayoutBindingInfo& info) {
size_t hash = Hash(info.mask); size_t hash = Hash(info.mask);
HashCombine(&hash, info.dynamic, info.multisampled);
for (uint32_t binding : IterateBitSet(info.mask)) { for (uint32_t binding : IterateBitSet(info.mask)) {
HashCombine(&hash, info.visibilities[binding], info.types[binding]); HashCombine(&hash, info.visibilities[binding], info.types[binding]);
@ -72,7 +82,7 @@ namespace dawn_native {
bool operator==(const BindGroupLayoutBase::LayoutBindingInfo& a, bool operator==(const BindGroupLayoutBase::LayoutBindingInfo& a,
const BindGroupLayoutBase::LayoutBindingInfo& b) { const BindGroupLayoutBase::LayoutBindingInfo& b) {
if (a.mask != b.mask) { if (a.mask != b.mask || a.dynamic != b.dynamic || a.multisampled != b.multisampled) {
return false; return false;
} }
@ -105,6 +115,8 @@ namespace dawn_native {
mDynamicBufferCount++; mDynamicBufferCount++;
} }
mBindingInfo.multisampled.set(index, binding.multisampled);
ASSERT(!mBindingInfo.mask[index]); ASSERT(!mBindingInfo.mask[index]);
mBindingInfo.mask.set(index); mBindingInfo.mask.set(index);
} }

View File

@ -43,6 +43,7 @@ namespace dawn_native {
std::array<dawn::ShaderStageBit, kMaxBindingsPerGroup> visibilities; std::array<dawn::ShaderStageBit, kMaxBindingsPerGroup> visibilities;
std::array<dawn::BindingType, kMaxBindingsPerGroup> types; std::array<dawn::BindingType, kMaxBindingsPerGroup> types;
std::bitset<kMaxBindingsPerGroup> dynamic; std::bitset<kMaxBindingsPerGroup> dynamic;
std::bitset<kMaxBindingsPerGroup> multisampled;
std::bitset<kMaxBindingsPerGroup> mask; std::bitset<kMaxBindingsPerGroup> mask;
}; };
const LayoutBindingInfo& GetBindingInfo() const; const LayoutBindingInfo& GetBindingInfo() const;

View File

@ -610,6 +610,11 @@ namespace dawn_native {
case dawn::BindingType::Sampler: case dawn::BindingType::Sampler:
break; break;
case dawn::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer:
UNREACHABLE();
break;
} }
} }
} }

View File

@ -305,6 +305,14 @@ namespace dawn_native {
DAWN_TRY(ValidateDepthStencilStateDescriptor(descriptor->depthStencilState)); 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 {}; return {};
} }
@ -341,6 +349,8 @@ namespace dawn_native {
mPrimitiveTopology(descriptor->primitiveTopology), mPrimitiveTopology(descriptor->primitiveTopology),
mRasterizationState(*descriptor->rasterizationState), mRasterizationState(*descriptor->rasterizationState),
mSampleCount(descriptor->sampleCount), mSampleCount(descriptor->sampleCount),
mSampleMask(descriptor->sampleMask),
mAlphaToCoverageEnabled(descriptor->alphaToCoverageEnabled),
mVertexModule(descriptor->vertexStage->module), mVertexModule(descriptor->vertexStage->module),
mVertexEntryPoint(descriptor->vertexStage->entryPoint), mVertexEntryPoint(descriptor->vertexStage->entryPoint),
mFragmentModule(descriptor->fragmentStage->module), mFragmentModule(descriptor->fragmentStage->module),
@ -589,7 +599,8 @@ namespace dawn_native {
} }
// Hash other state // Hash other state
HashCombine(&hash, pipeline->mSampleCount, pipeline->mPrimitiveTopology); HashCombine(&hash, pipeline->mSampleCount, pipeline->mPrimitiveTopology,
pipeline->mSampleMask, pipeline->mAlphaToCoverageEnabled);
return hash; return hash;
} }
@ -700,7 +711,9 @@ namespace dawn_native {
} }
// Check other state // 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; return false;
} }

View File

@ -111,6 +111,8 @@ namespace dawn_native {
dawn::PrimitiveTopology mPrimitiveTopology; dawn::PrimitiveTopology mPrimitiveTopology;
RasterizationStateDescriptor mRasterizationState; RasterizationStateDescriptor mRasterizationState;
uint32_t mSampleCount; uint32_t mSampleCount;
uint32_t mSampleMask;
bool mAlphaToCoverageEnabled;
// Stage information // Stage information
// TODO(cwallez@chromium.org): Store a crypto hash of the modules instead. // TODO(cwallez@chromium.org): Store a crypto hash of the modules instead.

View File

@ -323,6 +323,10 @@ namespace dawn_native {
"Non-renderable format used with OutputAttachment usage"); "Non-renderable format used with OutputAttachment usage");
} }
if (descriptor->usage & dawn::TextureUsageBit::Storage) {
return DAWN_VALIDATION_ERROR("storage textures aren't supported (yet)");
}
return {}; return {};
} }
@ -347,6 +351,10 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR("Cannot create an empty texture"); 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)); DAWN_TRY(ValidateTextureSize(descriptor, format));
return {}; return {};

View File

@ -96,6 +96,11 @@ namespace dawn_native { namespace d3d12 {
bindingOffsets[bindingIndex])); bindingOffsets[bindingIndex]));
} break; } break;
case dawn::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer:
UNREACHABLE();
break;
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset. // TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
} }
} }

View File

@ -37,6 +37,12 @@ namespace dawn_native { namespace d3d12 {
case dawn::BindingType::Sampler: case dawn::BindingType::Sampler:
mBindingOffsets[binding] = mDescriptorCounts[Sampler]++; mBindingOffsets[binding] = mDescriptorCounts[Sampler]++;
break; break;
case dawn::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer:
UNREACHABLE();
break;
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset. // TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
} }
} }
@ -96,6 +102,12 @@ namespace dawn_native { namespace d3d12 {
case dawn::BindingType::Sampler: case dawn::BindingType::Sampler:
mBindingOffsets[binding] += descriptorOffsets[Sampler]; mBindingOffsets[binding] += descriptorOffsets[Sampler];
break; break;
case dawn::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer:
UNREACHABLE();
break;
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset. // TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
} }
} }

View File

@ -292,6 +292,11 @@ namespace dawn_native { namespace metal {
[compute setTexture:textureView->GetMTLTexture() atIndex:computeIndex]; [compute setTexture:textureView->GetMTLTexture() atIndex:computeIndex];
} }
} break; } break;
case dawn::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer:
UNREACHABLE();
break;
} }
} }
} }

View File

@ -53,6 +53,10 @@ namespace dawn_native { namespace metal {
mIndexInfo[stage][group][binding] = textureIndex; mIndexInfo[stage][group][binding] = textureIndex;
textureIndex++; textureIndex++;
break; break;
case dawn::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer:
UNREACHABLE();
break;
} }
} }
} }

View File

@ -60,6 +60,8 @@ namespace dawn_native { namespace metal {
} else { } else {
return (arrayLayers > 1) ? MTLTextureType2DArray : MTLTextureType2D; return (arrayLayers > 1) ? MTLTextureType2DArray : MTLTextureType2D;
} }
default:
UNREACHABLE();
} }
} }

View File

@ -266,6 +266,11 @@ namespace dawn_native { namespace opengl {
binding.offset, binding.size); binding.offset, binding.size);
} break; } break;
case dawn::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer:
UNREACHABLE();
break;
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset. // TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
} }
} }

View File

@ -135,6 +135,11 @@ namespace dawn_native { namespace opengl {
// emulation // emulation
break; break;
case dawn::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer:
UNREACHABLE();
break;
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset. // TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
} }
} }

View File

@ -54,6 +54,11 @@ namespace dawn_native { namespace opengl {
ssboIndex++; ssboIndex++;
break; break;
case dawn::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer:
UNREACHABLE();
break;
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset // TODO(shaobo.yan@intel.com): Implement dynamic buffer offset
} }
} }

View File

@ -179,6 +179,8 @@ TEST_F(WireArgumentTests, CStringArgument) {
pipelineDescriptor.colorStates = colorStatesPtr; pipelineDescriptor.colorStates = colorStatesPtr;
pipelineDescriptor.sampleCount = 1; pipelineDescriptor.sampleCount = 1;
pipelineDescriptor.sampleMask = 0xFFFFFFFF;
pipelineDescriptor.alphaToCoverageEnabled = false;
pipelineDescriptor.layout = layout; pipelineDescriptor.layout = layout;
pipelineDescriptor.vertexInput = &vertexInput; pipelineDescriptor.vertexInput = &vertexInput;
pipelineDescriptor.primitiveTopology = DAWN_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; pipelineDescriptor.primitiveTopology = DAWN_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
@ -330,12 +332,12 @@ TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) { TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) {
static constexpr int NUM_BINDINGS = 3; static constexpr int NUM_BINDINGS = 3;
DawnBindGroupLayoutBinding bindings[NUM_BINDINGS]{ DawnBindGroupLayoutBinding bindings[NUM_BINDINGS]{
{0, DAWN_SHADER_STAGE_BIT_VERTEX, DAWN_BINDING_TYPE_SAMPLER}, {0, DAWN_SHADER_STAGE_BIT_VERTEX, DAWN_BINDING_TYPE_SAMPLER, false, false},
{1, DAWN_SHADER_STAGE_BIT_VERTEX, DAWN_BINDING_TYPE_SAMPLED_TEXTURE}, {1, DAWN_SHADER_STAGE_BIT_VERTEX, DAWN_BINDING_TYPE_SAMPLED_TEXTURE, false, false},
{2, {2,
static_cast<DawnShaderStageBit>(DAWN_SHADER_STAGE_BIT_VERTEX | static_cast<DawnShaderStageBit>(DAWN_SHADER_STAGE_BIT_VERTEX |
DAWN_SHADER_STAGE_BIT_FRAGMENT), DAWN_SHADER_STAGE_BIT_FRAGMENT),
DAWN_BINDING_TYPE_UNIFORM_BUFFER}, DAWN_BINDING_TYPE_UNIFORM_BUFFER, false, false},
}; };
DawnBindGroupLayoutDescriptor bglDescriptor; DawnBindGroupLayoutDescriptor bglDescriptor;
bglDescriptor.bindingCount = NUM_BINDINGS; bglDescriptor.bindingCount = NUM_BINDINGS;

View File

@ -149,6 +149,8 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
pipelineDescriptor.colorStates = colorStatesPtr; pipelineDescriptor.colorStates = colorStatesPtr;
pipelineDescriptor.sampleCount = 1; pipelineDescriptor.sampleCount = 1;
pipelineDescriptor.sampleMask = 0xFFFFFFFF;
pipelineDescriptor.alphaToCoverageEnabled = false;
pipelineDescriptor.layout = layout; pipelineDescriptor.layout = layout;
pipelineDescriptor.vertexInput = &vertexInput; pipelineDescriptor.vertexInput = &vertexInput;
pipelineDescriptor.primitiveTopology = DAWN_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; pipelineDescriptor.primitiveTopology = DAWN_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;