Remove indirection for computeStage

This is to match the work in progress webgpu.h header.

BUG=dawn:22

Change-Id: I0904297bb4411b12f9d99e8457d32613058ef9b2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9380
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez 2019-09-05 09:41:17 +00:00 committed by Commit Bot service account
parent a560104617
commit a900ccebcf
17 changed files with 48 additions and 81 deletions

View File

@ -401,7 +401,7 @@
"extensible": true,
"members": [
{"name": "layout", "type": "pipeline layout"},
{"name": "compute stage", "type": "pipeline stage descriptor", "annotation": "const*"}
{"name": "compute stage", "type": "pipeline stage descriptor"}
]
},
"cull mode": {

View File

@ -248,12 +248,8 @@ void initSim() {
dawn::ComputePipelineDescriptor csDesc;
csDesc.layout = pl;
dawn::PipelineStageDescriptor computeStage;
computeStage.module = module;
computeStage.entryPoint = "main";
csDesc.computeStage = &computeStage;
csDesc.computeStage.module = module;
csDesc.computeStage.entryPoint = "main";
updatePipeline = device.CreateComputePipeline(&csDesc);
for (uint32_t i = 0; i < 2; ++i) {

View File

@ -26,7 +26,7 @@ namespace dawn_native {
}
DAWN_TRY(device->ValidateObject(descriptor->layout));
DAWN_TRY(ValidatePipelineStageDescriptor(device, descriptor->computeStage,
DAWN_TRY(ValidatePipelineStageDescriptor(device, &descriptor->computeStage,
descriptor->layout, SingleShaderStage::Compute));
return {};
}
@ -37,8 +37,8 @@ namespace dawn_native {
const ComputePipelineDescriptor* descriptor,
bool blueprint)
: PipelineBase(device, descriptor->layout, dawn::ShaderStage::Compute),
mModule(descriptor->computeStage->module),
mEntryPoint(descriptor->computeStage->entryPoint),
mModule(descriptor->computeStage.module),
mEntryPoint(descriptor->computeStage.entryPoint),
mIsBlueprint(blueprint) {
}

View File

@ -32,7 +32,7 @@ namespace dawn_native { namespace d3d12 {
// SPRIV-cross does matrix multiplication expecting row major matrices
compileFlags |= D3DCOMPILE_PACK_MATRIX_ROW_MAJOR;
const ShaderModule* module = ToBackend(descriptor->computeStage->module);
const ShaderModule* module = ToBackend(descriptor->computeStage.module);
const std::string& hlslSource = module->GetHLSLSource(ToBackend(GetLayout()));
ComPtr<ID3DBlob> compiledShader;
@ -40,7 +40,7 @@ namespace dawn_native { namespace d3d12 {
const PlatformFunctions* functions = device->GetFunctions();
if (FAILED(functions->d3dCompile(hlslSource.c_str(), hlslSource.length(), nullptr, nullptr,
nullptr, descriptor->computeStage->entryPoint, "cs_5_1",
nullptr, descriptor->computeStage.entryPoint, "cs_5_1",
compileFlags, 0, &compiledShader, &errors))) {
printf("%s\n", reinterpret_cast<char*>(errors->GetBufferPointer()));
ASSERT(false);

View File

@ -23,8 +23,8 @@ namespace dawn_native { namespace metal {
: ComputePipelineBase(device, descriptor) {
auto mtlDevice = ToBackend(GetDevice())->GetMTLDevice();
const ShaderModule* computeModule = ToBackend(descriptor->computeStage->module);
const char* computeEntryPoint = descriptor->computeStage->entryPoint;
const ShaderModule* computeModule = ToBackend(descriptor->computeStage.module);
const char* computeEntryPoint = descriptor->computeStage.entryPoint;
ShaderModule::MetalFunctionData computeData = computeModule->GetFunction(
computeEntryPoint, SingleShaderStage::Compute, ToBackend(GetLayout()));

View File

@ -21,7 +21,7 @@ namespace dawn_native { namespace opengl {
ComputePipeline::ComputePipeline(Device* device, const ComputePipelineDescriptor* descriptor)
: ComputePipelineBase(device, descriptor) {
PerStage<const ShaderModule*> modules(nullptr);
modules[SingleShaderStage::Compute] = ToBackend(descriptor->computeStage->module);
modules[SingleShaderStage::Compute] = ToBackend(descriptor->computeStage.module);
PipelineGL::Initialize(device->gl, ToBackend(descriptor->layout), modules);
}

View File

@ -35,8 +35,8 @@ namespace dawn_native { namespace vulkan {
createInfo.stage.pNext = nullptr;
createInfo.stage.flags = 0;
createInfo.stage.stage = VK_SHADER_STAGE_COMPUTE_BIT;
createInfo.stage.module = ToBackend(descriptor->computeStage->module)->GetHandle();
createInfo.stage.pName = descriptor->computeStage->entryPoint;
createInfo.stage.module = ToBackend(descriptor->computeStage.module)->GetHandle();
createInfo.stage.pName = descriptor->computeStage.entryPoint;
createInfo.stage.pSpecializationInfo = nullptr;
if (device->fn.CreateComputePipelines(device->GetVkDevice(), VK_NULL_HANDLE, 1, &createInfo,

View File

@ -65,14 +65,11 @@ TEST_P(BindGroupTests, ReusedBindGroupSingleSubmit) {
dawn::ShaderModule module =
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, shader);
dawn::ComputePipelineDescriptor cpDesc;
cpDesc.layout = pl;
dawn::PipelineStageDescriptor computeStage;
computeStage.module = module;
computeStage.entryPoint = "main";
cpDesc.computeStage = &computeStage;
cpDesc.computeStage.module = module;
cpDesc.computeStage.entryPoint = "main";
dawn::ComputePipeline cp = device.CreateComputePipeline(&cpDesc);
dawn::BufferDescriptor bufferDesc;

View File

@ -40,11 +40,8 @@ void ComputeCopyStorageBufferTests::BasicTest(const char* shader) {
dawn::ComputePipelineDescriptor csDesc;
csDesc.layout = pl;
dawn::PipelineStageDescriptor computeStage;
computeStage.module = module;
computeStage.entryPoint = "main";
csDesc.computeStage = &computeStage;
csDesc.computeStage.module = module;
csDesc.computeStage.entryPoint = "main";
dawn::ComputePipeline pipeline = device.CreateComputePipeline(&csDesc);

View File

@ -58,12 +58,8 @@ void ComputeIndirectTests::BasicTest(std::initializer_list<uint32_t> bufferList,
dawn::ComputePipelineDescriptor csDesc;
csDesc.layout = pl;
dawn::PipelineStageDescriptor computeStage;
computeStage.module = module;
computeStage.entryPoint = "main";
csDesc.computeStage = &computeStage;
csDesc.computeStage.module = module;
csDesc.computeStage.entryPoint = "main";
dawn::ComputePipeline pipeline = device.CreateComputePipeline(&csDesc);
// Set up dst storage buffer to contain dispatch x, y, z

View File

@ -37,12 +37,8 @@ void ComputeSharedMemoryTests::BasicTest(const char* shader) {
dawn::ComputePipelineDescriptor csDesc;
csDesc.layout = pl;
dawn::PipelineStageDescriptor computeStage;
computeStage.module = module;
computeStage.entryPoint = "main";
csDesc.computeStage = &computeStage;
csDesc.computeStage.module = module;
csDesc.computeStage.entryPoint = "main";
dawn::ComputePipeline pipeline = device.CreateComputePipeline(&csDesc);
// Set up dst storage buffer

View File

@ -194,10 +194,8 @@ class DynamicBufferOffsetTests : public DawnTest {
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, cs.str().c_str());
dawn::ComputePipelineDescriptor csDesc;
dawn::PipelineStageDescriptor computeStage;
computeStage.module = csModule;
computeStage.entryPoint = "main";
csDesc.computeStage = &computeStage;
csDesc.computeStage.module = csModule;
csDesc.computeStage.entryPoint = "main";
dawn::PipelineLayoutDescriptor pipelineLayoutDescriptor;
if (isInheritedPipeline) {

View File

@ -140,20 +140,17 @@ TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnShaderModule) {
dawn::PipelineLayout layout = utils::MakeBasicPipelineLayout(device, nullptr);
dawn::PipelineStageDescriptor stageDesc;
stageDesc.entryPoint = "main";
stageDesc.module = module;
dawn::ComputePipelineDescriptor desc;
desc.computeStage = &stageDesc;
desc.computeStage.entryPoint = "main";
desc.layout = layout;
desc.computeStage.module = module;
dawn::ComputePipeline pipeline = device.CreateComputePipeline(&desc);
stageDesc.module = sameModule;
desc.computeStage.module = sameModule;
dawn::ComputePipeline samePipeline = device.CreateComputePipeline(&desc);
stageDesc.module = otherModule;
desc.computeStage.module = otherModule;
dawn::ComputePipeline otherPipeline = device.CreateComputePipeline(&desc);
EXPECT_NE(pipeline.Get(), otherPipeline.Get());
@ -174,17 +171,15 @@ TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnLayout) {
EXPECT_NE(pl.Get(), otherPl.Get());
EXPECT_EQ(pl.Get() == samePl.Get(), !UsesWire());
dawn::PipelineStageDescriptor stageDesc;
stageDesc.entryPoint = "main";
stageDesc.module = utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
dawn::ComputePipelineDescriptor desc;
desc.computeStage.entryPoint = "main";
desc.computeStage.module =
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
#version 450
void main() {
int i = 0;
})");
dawn::ComputePipelineDescriptor desc;
desc.computeStage = &stageDesc;
desc.layout = pl;
dawn::ComputePipeline pipeline = device.CreateComputePipeline(&desc);

View File

@ -111,10 +111,12 @@ TEST_P(OpArrayLengthTest, Compute) {
plDesc.bindGroupLayouts = bgls;
dawn::PipelineLayout pl = device.CreatePipelineLayout(&plDesc);
dawn::PipelineStageDescriptor computeStage;
computeStage.entryPoint = "main";
computeStage.module = utils::CreateShaderModule(device, utils::SingleShaderStage::Compute,
(R"(#version 450
dawn::ComputePipelineDescriptor pipelineDesc;
pipelineDesc.layout = pl;
pipelineDesc.computeStage.entryPoint = "main";
pipelineDesc.computeStage.module =
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute,
(R"(#version 450
layout(std430, set = 1, binding = 0) buffer ResultBuffer {
uint result[3];
};
@ -124,11 +126,7 @@ TEST_P(OpArrayLengthTest, Compute) {
result[1] = buffer2.data.length();
result[2] = buffer3.data.length();
})")
.c_str());
dawn::ComputePipelineDescriptor pipelineDesc;
pipelineDesc.layout = pl;
pipelineDesc.computeStage = &computeStage;
.c_str());
dawn::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDesc);
// Run a single instance of the compute shader

View File

@ -531,9 +531,9 @@ TEST_P(TextureZeroInitTest, ComputePassSampledTextureClear) {
bufferTex.result =
texelFetch(sampler2D(sampleTex, sampler0), ivec2(0,0), 0);
})";
computeStage.module = utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, cs);
computeStage.entryPoint = "main";
computePipelineDescriptor.computeStage = &computeStage;
computePipelineDescriptor.computeStage.module =
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, cs);
computePipelineDescriptor.computeStage.entryPoint = "main";
dawn::ComputePipeline computePipeline =
device.CreateComputePipeline(&computePipelineDescriptor);

View File

@ -656,15 +656,13 @@ class SetBindGroupValidationTest : public ValidationTest {
void main() {
})");
dawn::ComputePipelineDescriptor csDesc;
dawn::PipelineLayout pipelineLayout =
utils::MakeBasicPipelineLayout(device, &mBindGroupLayout);
csDesc.layout = pipelineLayout;
dawn::PipelineStageDescriptor computeStage;
computeStage.module = csModule;
computeStage.entryPoint = "main";
csDesc.computeStage = &computeStage;
dawn::ComputePipelineDescriptor csDesc;
csDesc.layout = pipelineLayout;
csDesc.computeStage.module = csModule;
csDesc.computeStage.entryPoint = "main";
return device.CreateComputePipeline(&csDesc);
}

View File

@ -34,12 +34,8 @@ class ComputeIndirectValidationTest : public ValidationTest {
dawn::ComputePipelineDescriptor csDesc;
csDesc.layout = pl;
dawn::PipelineStageDescriptor computeStage;
computeStage.module = computeModule;
computeStage.entryPoint = "main";
csDesc.computeStage = &computeStage;
csDesc.computeStage.module = computeModule;
csDesc.computeStage.entryPoint = "main";
pipeline = device.CreateComputePipeline(&csDesc);
}