Remove descriptor in RenderPipeline::Initialize

This patch removes the parameter "descriptor" from the function
RenderPipeline::Initialize() on D3D12, Metal and Vulkan backends as
a preparation of creating render pipeline asynchronously.

BUG=dawn:529

Change-Id: I6bdd74ad0af6a1924fac3703908cd5f66b75994b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64163
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao 2021-09-15 01:41:42 +00:00 committed by Dawn LUCI CQ
parent 24cad6e2c3
commit 43ce892284
6 changed files with 30 additions and 23 deletions

View File

@ -319,11 +319,11 @@ namespace dawn_native { namespace d3d12 {
Device* device,
const RenderPipelineDescriptor* descriptor) {
Ref<RenderPipeline> pipeline = AcquireRef(new RenderPipeline(device, descriptor));
DAWN_TRY(pipeline->Initialize(descriptor));
DAWN_TRY(pipeline->Initialize());
return pipeline;
}
MaybeError RenderPipeline::Initialize(const RenderPipelineDescriptor* descriptor) {
MaybeError RenderPipeline::Initialize() {
Device* device = ToBackend(GetDevice());
uint32_t compileFlags = 0;
@ -340,13 +340,16 @@ namespace dawn_native { namespace d3d12 {
D3D12_GRAPHICS_PIPELINE_STATE_DESC descriptorD3D12 = {};
const ProgrammableStage& vertexStage = GetStage(SingleShaderStage::Vertex);
const ProgrammableStage& fragmentStage = GetStage(SingleShaderStage::Fragment);
PerStage<const char*> entryPoints;
entryPoints[SingleShaderStage::Vertex] = descriptor->vertex.entryPoint;
entryPoints[SingleShaderStage::Fragment] = descriptor->fragment->entryPoint;
entryPoints[SingleShaderStage::Vertex] = vertexStage.entryPoint.c_str();
entryPoints[SingleShaderStage::Fragment] = fragmentStage.entryPoint.c_str();
PerStage<ShaderModule*> modules;
modules[SingleShaderStage::Vertex] = ToBackend(descriptor->vertex.module);
modules[SingleShaderStage::Fragment] = ToBackend(descriptor->fragment->module);
modules[SingleShaderStage::Vertex] = ToBackend(vertexStage.module.Get());
modules[SingleShaderStage::Fragment] = ToBackend(fragmentStage.module.Get());
PerStage<D3D12_SHADER_BYTECODE*> shaders;
shaders[SingleShaderStage::Vertex] = &descriptorD3D12.VS;

View File

@ -42,7 +42,7 @@ namespace dawn_native { namespace d3d12 {
private:
~RenderPipeline() override;
using RenderPipelineBase::RenderPipelineBase;
MaybeError Initialize(const RenderPipelineDescriptor* descriptor);
MaybeError Initialize();
D3D12_INPUT_LAYOUT_DESC ComputeInputLayout(
std::array<D3D12_INPUT_ELEMENT_DESC, kMaxVertexAttributes>* inputElementDescriptors);

View File

@ -47,7 +47,7 @@ namespace dawn_native { namespace metal {
private:
using RenderPipelineBase::RenderPipelineBase;
MaybeError Initialize(const RenderPipelineDescriptor* descriptor);
MaybeError Initialize();
MTLVertexDescriptor* MakeVertexDesc();

View File

@ -314,11 +314,11 @@ namespace dawn_native { namespace metal {
Device* device,
const RenderPipelineDescriptor* descriptor) {
Ref<RenderPipeline> pipeline = AcquireRef(new RenderPipeline(device, descriptor));
DAWN_TRY(pipeline->Initialize(descriptor));
DAWN_TRY(pipeline->Initialize());
return pipeline;
}
MaybeError RenderPipeline::Initialize(const RenderPipelineDescriptor* descriptor) {
MaybeError RenderPipeline::Initialize() {
mMtlPrimitiveTopology = MTLPrimitiveTopology(GetPrimitiveTopology());
mMtlFrontFace = MTLFrontFace(GetFrontFace());
mMtlCullMode = ToMTLCullMode(GetCullMode());
@ -338,8 +338,9 @@ namespace dawn_native { namespace metal {
}
descriptorMTL.vertexDescriptor = vertexDesc.Get();
ShaderModule* vertexModule = ToBackend(descriptor->vertex.module);
const char* vertexEntryPoint = descriptor->vertex.entryPoint;
const ProgrammableStage& vertexStage = GetStage(SingleShaderStage::Vertex);
ShaderModule* vertexModule = ToBackend(vertexStage.module.Get());
const char* vertexEntryPoint = vertexStage.entryPoint.c_str();
ShaderModule::MetalFunctionData vertexData;
DAWN_TRY(vertexModule->CreateFunction(vertexEntryPoint, SingleShaderStage::Vertex,
ToBackend(GetLayout()), &vertexData, 0xFFFFFFFF,
@ -350,8 +351,9 @@ namespace dawn_native { namespace metal {
mStagesRequiringStorageBufferLength |= wgpu::ShaderStage::Vertex;
}
ShaderModule* fragmentModule = ToBackend(descriptor->fragment->module);
const char* fragmentEntryPoint = descriptor->fragment->entryPoint;
const ProgrammableStage& fragmentStage = GetStage(SingleShaderStage::Fragment);
ShaderModule* fragmentModule = ToBackend(fragmentStage.module.Get());
const char* fragmentEntryPoint = fragmentStage.entryPoint.c_str();
ShaderModule::MetalFunctionData fragmentData;
DAWN_TRY(fragmentModule->CreateFunction(fragmentEntryPoint, SingleShaderStage::Fragment,
ToBackend(GetLayout()), &fragmentData,

View File

@ -323,38 +323,40 @@ namespace dawn_native { namespace vulkan {
Device* device,
const RenderPipelineDescriptor* descriptor) {
Ref<RenderPipeline> pipeline = AcquireRef(new RenderPipeline(device, descriptor));
DAWN_TRY(pipeline->Initialize(descriptor));
DAWN_TRY(pipeline->Initialize());
return pipeline;
}
MaybeError RenderPipeline::Initialize(const RenderPipelineDescriptor* descriptor) {
MaybeError RenderPipeline::Initialize() {
Device* device = ToBackend(GetDevice());
VkPipelineShaderStageCreateInfo shaderStages[2];
{
// Generate a new VkShaderModule with BindingRemapper tint transform for each
// pipeline
const ProgrammableStage& vertexStage = GetStage(SingleShaderStage::Vertex);
DAWN_TRY_ASSIGN(shaderStages[0].module,
ToBackend(descriptor->vertex.module)
->GetTransformedModuleHandle(descriptor->vertex.entryPoint,
ToBackend(vertexStage.module.Get())
->GetTransformedModuleHandle(vertexStage.entryPoint.c_str(),
ToBackend(GetLayout())));
const ProgrammableStage& fragmentStage = GetStage(SingleShaderStage::Fragment);
DAWN_TRY_ASSIGN(shaderStages[1].module,
ToBackend(descriptor->fragment->module)
->GetTransformedModuleHandle(descriptor->fragment->entryPoint,
ToBackend(fragmentStage.module.Get())
->GetTransformedModuleHandle(fragmentStage.entryPoint.c_str(),
ToBackend(GetLayout())));
shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
shaderStages[0].pNext = nullptr;
shaderStages[0].flags = 0;
shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
shaderStages[0].pSpecializationInfo = nullptr;
shaderStages[0].pName = descriptor->vertex.entryPoint;
shaderStages[0].pName = vertexStage.entryPoint.c_str();
shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
shaderStages[1].pNext = nullptr;
shaderStages[1].flags = 0;
shaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
shaderStages[1].pSpecializationInfo = nullptr;
shaderStages[1].pName = descriptor->fragment->entryPoint;
shaderStages[1].pName = fragmentStage.entryPoint.c_str();
}
PipelineVertexInputStateCreateInfoTemporaryAllocations tempAllocations;

View File

@ -38,7 +38,7 @@ namespace dawn_native { namespace vulkan {
private:
~RenderPipeline() override;
using RenderPipelineBase::RenderPipelineBase;
MaybeError Initialize(const RenderPipelineDescriptor* descriptor);
MaybeError Initialize();
struct PipelineVertexInputStateCreateInfoTemporaryAllocations {
std::array<VkVertexInputBindingDescription, kMaxVertexBuffers> bindings;