mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-08 22:26:06 +00:00
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:
parent
437655216e
commit
2eca22f6d7
@ -1269,9 +1269,7 @@
|
|||||||
"category": "structure",
|
"category": "structure",
|
||||||
"extensible": true,
|
"extensible": true,
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen", "optional": true},
|
{"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}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"shader module SPIRV descriptor": {
|
"shader module SPIRV descriptor": {
|
||||||
|
@ -318,17 +318,6 @@ namespace dawn_native {
|
|||||||
|
|
||||||
MaybeError ValidateShaderModuleDescriptor(DeviceBase* device,
|
MaybeError ValidateShaderModuleDescriptor(DeviceBase* device,
|
||||||
const ShaderModuleDescriptor* descriptor) {
|
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;
|
const ChainedStruct* chainedDescriptor = descriptor->nextInChain;
|
||||||
if (chainedDescriptor == nullptr) {
|
if (chainedDescriptor == nullptr) {
|
||||||
return DAWN_VALIDATION_ERROR("Shader module descriptor missing chained descriptor");
|
return DAWN_VALIDATION_ERROR("Shader module descriptor missing chained descriptor");
|
||||||
@ -363,17 +352,12 @@ namespace dawn_native {
|
|||||||
|
|
||||||
ShaderModuleBase::ShaderModuleBase(DeviceBase* device, const ShaderModuleDescriptor* descriptor)
|
ShaderModuleBase::ShaderModuleBase(DeviceBase* device, const ShaderModuleDescriptor* descriptor)
|
||||||
: CachedObject(device) {
|
: CachedObject(device) {
|
||||||
// Extract the correct SPIRV from the descriptor.
|
ASSERT(descriptor->nextInChain != nullptr);
|
||||||
if (descriptor->codeSize != 0) {
|
ASSERT(descriptor->nextInChain->sType == wgpu::SType::ShaderModuleSPIRVDescriptor);
|
||||||
mSpirv.assign(descriptor->code, descriptor->code + descriptor->codeSize);
|
|
||||||
} else {
|
|
||||||
ASSERT(descriptor->nextInChain != nullptr);
|
|
||||||
ASSERT(descriptor->nextInChain->sType == wgpu::SType::ShaderModuleSPIRVDescriptor);
|
|
||||||
|
|
||||||
const ShaderModuleSPIRVDescriptor* spirvDesc =
|
const ShaderModuleSPIRVDescriptor* spirvDesc =
|
||||||
static_cast<const ShaderModuleSPIRVDescriptor*>(descriptor->nextInChain);
|
static_cast<const ShaderModuleSPIRVDescriptor*>(descriptor->nextInChain);
|
||||||
mSpirv.assign(spirvDesc->code, spirvDesc->code + spirvDesc->codeSize);
|
mSpirv.assign(spirvDesc->code, spirvDesc->code + spirvDesc->codeSize);
|
||||||
}
|
|
||||||
|
|
||||||
mFragmentOutputFormatBaseTypes.fill(Format::Other);
|
mFragmentOutputFormatBaseTypes.fill(Format::Other);
|
||||||
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvcParser)) {
|
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvcParser)) {
|
||||||
|
@ -56,64 +56,6 @@ class DeprecationTests : public DawnTest {
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} 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
|
// Tests for BufferCopyView.rowPitch/imageHeight -> bytesPerRow/rowsPerImage
|
||||||
|
|
||||||
class BufferCopyViewDeprecationTests : public DeprecationTests {
|
class BufferCopyViewDeprecationTests : public DeprecationTests {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user