Remove ShaderModule::code/codeSize

It was deprecated in favor of chaining a
wgpu::ShaderModuleSPIRVDescriptor.

Bug: dawn:22
Change-Id: I210cd7c21c33c6ca8dd286ea64389b774a4355e5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/21683
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez 2020-05-13 17:23:35 +00:00 committed by Commit Bot service account
parent 437655216e
commit 2eca22f6d7
3 changed files with 6 additions and 82 deletions

View File

@ -1269,9 +1269,7 @@
"category": "structure",
"extensible": true,
"members": [
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen", "optional": true},
{"name": "code size", "type": "uint32_t", "default": 0},
{"name": "code", "type": "uint32_t", "annotation": "const*", "length": "code size", "optional": true}
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen", "optional": true}
]
},
"shader module SPIRV descriptor": {

View File

@ -318,17 +318,6 @@ namespace dawn_native {
MaybeError ValidateShaderModuleDescriptor(DeviceBase* device,
const ShaderModuleDescriptor* descriptor) {
if (descriptor->codeSize != 0) {
if (descriptor->nextInChain != nullptr) {
return DAWN_VALIDATION_ERROR("Cannot set both code/codeSize and nextInChain");
}
device->EmitDeprecationWarning(
"ShaderModuleDescriptor::code/codeSize is deprecated, chain "
"ShaderModuleSPIRVDescriptor instead.");
return ValidateSpirv(device, descriptor->code, descriptor->codeSize);
}
const ChainedStruct* chainedDescriptor = descriptor->nextInChain;
if (chainedDescriptor == nullptr) {
return DAWN_VALIDATION_ERROR("Shader module descriptor missing chained descriptor");
@ -363,17 +352,12 @@ namespace dawn_native {
ShaderModuleBase::ShaderModuleBase(DeviceBase* device, const ShaderModuleDescriptor* descriptor)
: CachedObject(device) {
// Extract the correct SPIRV from the descriptor.
if (descriptor->codeSize != 0) {
mSpirv.assign(descriptor->code, descriptor->code + descriptor->codeSize);
} else {
ASSERT(descriptor->nextInChain != nullptr);
ASSERT(descriptor->nextInChain->sType == wgpu::SType::ShaderModuleSPIRVDescriptor);
ASSERT(descriptor->nextInChain != nullptr);
ASSERT(descriptor->nextInChain->sType == wgpu::SType::ShaderModuleSPIRVDescriptor);
const ShaderModuleSPIRVDescriptor* spirvDesc =
static_cast<const ShaderModuleSPIRVDescriptor*>(descriptor->nextInChain);
mSpirv.assign(spirvDesc->code, spirvDesc->code + spirvDesc->codeSize);
}
const ShaderModuleSPIRVDescriptor* spirvDesc =
static_cast<const ShaderModuleSPIRVDescriptor*>(descriptor->nextInChain);
mSpirv.assign(spirvDesc->code, spirvDesc->code + spirvDesc->codeSize);
mFragmentOutputFormatBaseTypes.fill(Format::Other);
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvcParser)) {

View File

@ -56,64 +56,6 @@ class DeprecationTests : public DawnTest {
} \
} while (0)
// Tests for ShaderModuleDescriptor.code/codeSize -> ShaderModuleSPIRVDescriptor
static const char kEmptyShader[] = R"(#version 450
void main() {
})";
// That creating a ShaderModule without the chained descriptor gives a warning.
TEST_P(DeprecationTests, ShaderModuleNoSubDescriptorIsDeprecated) {
std::vector<uint32_t> spirv =
CompileGLSLToSpirv(utils::SingleShaderStage::Compute, kEmptyShader);
wgpu::ShaderModuleDescriptor descriptor;
descriptor.codeSize = static_cast<uint32_t>(spirv.size());
descriptor.code = spirv.data();
EXPECT_DEPRECATION_WARNING(device.CreateShaderModule(&descriptor));
}
// That creating a ShaderModule with both inline code and the chained descriptor is an error.
TEST_P(DeprecationTests, ShaderModuleBothInlinedAndChainedIsInvalid) {
std::vector<uint32_t> spirv =
CompileGLSLToSpirv(utils::SingleShaderStage::Compute, kEmptyShader);
wgpu::ShaderModuleSPIRVDescriptor spirvDesc;
spirvDesc.codeSize = static_cast<uint32_t>(spirv.size());
spirvDesc.code = spirv.data();
wgpu::ShaderModuleDescriptor descriptor;
descriptor.nextInChain = &spirvDesc;
descriptor.codeSize = static_cast<uint32_t>(spirv.size());
descriptor.code = spirv.data();
ASSERT_DEVICE_ERROR(device.CreateShaderModule(&descriptor));
}
// That creating a ShaderModule with both inline code still does correct state tracking
TEST_P(DeprecationTests, ShaderModuleInlinedCodeStateTracking) {
std::vector<uint32_t> spirv =
CompileGLSLToSpirv(utils::SingleShaderStage::Compute, kEmptyShader);
wgpu::ShaderModuleDescriptor descriptor;
descriptor.codeSize = static_cast<uint32_t>(spirv.size());
descriptor.code = spirv.data();
wgpu::ShaderModule module;
EXPECT_DEPRECATION_WARNING(module = device.CreateShaderModule(&descriptor));
// Creating a compute pipeline works, because it is a compute module.
wgpu::ComputePipelineDescriptor computePipelineDesc;
computePipelineDesc.layout = nullptr;
computePipelineDesc.computeStage.module = module;
computePipelineDesc.computeStage.entryPoint = "main";
device.CreateComputePipeline(&computePipelineDesc);
utils::ComboRenderPipelineDescriptor renderPipelineDesc(device);
renderPipelineDesc.vertexStage.module =
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, kEmptyShader);
renderPipelineDesc.cFragmentStage.module = module;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&renderPipelineDesc));
}
// Tests for BufferCopyView.rowPitch/imageHeight -> bytesPerRow/rowsPerImage
class BufferCopyViewDeprecationTests : public DeprecationTests {