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:
parent
24cad6e2c3
commit
43ce892284
|
@ -319,11 +319,11 @@ namespace dawn_native { namespace d3d12 {
|
||||||
Device* device,
|
Device* device,
|
||||||
const RenderPipelineDescriptor* descriptor) {
|
const RenderPipelineDescriptor* descriptor) {
|
||||||
Ref<RenderPipeline> pipeline = AcquireRef(new RenderPipeline(device, descriptor));
|
Ref<RenderPipeline> pipeline = AcquireRef(new RenderPipeline(device, descriptor));
|
||||||
DAWN_TRY(pipeline->Initialize(descriptor));
|
DAWN_TRY(pipeline->Initialize());
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError RenderPipeline::Initialize(const RenderPipelineDescriptor* descriptor) {
|
MaybeError RenderPipeline::Initialize() {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
uint32_t compileFlags = 0;
|
uint32_t compileFlags = 0;
|
||||||
|
|
||||||
|
@ -340,13 +340,16 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
D3D12_GRAPHICS_PIPELINE_STATE_DESC descriptorD3D12 = {};
|
D3D12_GRAPHICS_PIPELINE_STATE_DESC descriptorD3D12 = {};
|
||||||
|
|
||||||
|
const ProgrammableStage& vertexStage = GetStage(SingleShaderStage::Vertex);
|
||||||
|
const ProgrammableStage& fragmentStage = GetStage(SingleShaderStage::Fragment);
|
||||||
|
|
||||||
PerStage<const char*> entryPoints;
|
PerStage<const char*> entryPoints;
|
||||||
entryPoints[SingleShaderStage::Vertex] = descriptor->vertex.entryPoint;
|
entryPoints[SingleShaderStage::Vertex] = vertexStage.entryPoint.c_str();
|
||||||
entryPoints[SingleShaderStage::Fragment] = descriptor->fragment->entryPoint;
|
entryPoints[SingleShaderStage::Fragment] = fragmentStage.entryPoint.c_str();
|
||||||
|
|
||||||
PerStage<ShaderModule*> modules;
|
PerStage<ShaderModule*> modules;
|
||||||
modules[SingleShaderStage::Vertex] = ToBackend(descriptor->vertex.module);
|
modules[SingleShaderStage::Vertex] = ToBackend(vertexStage.module.Get());
|
||||||
modules[SingleShaderStage::Fragment] = ToBackend(descriptor->fragment->module);
|
modules[SingleShaderStage::Fragment] = ToBackend(fragmentStage.module.Get());
|
||||||
|
|
||||||
PerStage<D3D12_SHADER_BYTECODE*> shaders;
|
PerStage<D3D12_SHADER_BYTECODE*> shaders;
|
||||||
shaders[SingleShaderStage::Vertex] = &descriptorD3D12.VS;
|
shaders[SingleShaderStage::Vertex] = &descriptorD3D12.VS;
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
private:
|
private:
|
||||||
~RenderPipeline() override;
|
~RenderPipeline() override;
|
||||||
using RenderPipelineBase::RenderPipelineBase;
|
using RenderPipelineBase::RenderPipelineBase;
|
||||||
MaybeError Initialize(const RenderPipelineDescriptor* descriptor);
|
MaybeError Initialize();
|
||||||
D3D12_INPUT_LAYOUT_DESC ComputeInputLayout(
|
D3D12_INPUT_LAYOUT_DESC ComputeInputLayout(
|
||||||
std::array<D3D12_INPUT_ELEMENT_DESC, kMaxVertexAttributes>* inputElementDescriptors);
|
std::array<D3D12_INPUT_ELEMENT_DESC, kMaxVertexAttributes>* inputElementDescriptors);
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using RenderPipelineBase::RenderPipelineBase;
|
using RenderPipelineBase::RenderPipelineBase;
|
||||||
MaybeError Initialize(const RenderPipelineDescriptor* descriptor);
|
MaybeError Initialize();
|
||||||
|
|
||||||
MTLVertexDescriptor* MakeVertexDesc();
|
MTLVertexDescriptor* MakeVertexDesc();
|
||||||
|
|
||||||
|
|
|
@ -314,11 +314,11 @@ namespace dawn_native { namespace metal {
|
||||||
Device* device,
|
Device* device,
|
||||||
const RenderPipelineDescriptor* descriptor) {
|
const RenderPipelineDescriptor* descriptor) {
|
||||||
Ref<RenderPipeline> pipeline = AcquireRef(new RenderPipeline(device, descriptor));
|
Ref<RenderPipeline> pipeline = AcquireRef(new RenderPipeline(device, descriptor));
|
||||||
DAWN_TRY(pipeline->Initialize(descriptor));
|
DAWN_TRY(pipeline->Initialize());
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError RenderPipeline::Initialize(const RenderPipelineDescriptor* descriptor) {
|
MaybeError RenderPipeline::Initialize() {
|
||||||
mMtlPrimitiveTopology = MTLPrimitiveTopology(GetPrimitiveTopology());
|
mMtlPrimitiveTopology = MTLPrimitiveTopology(GetPrimitiveTopology());
|
||||||
mMtlFrontFace = MTLFrontFace(GetFrontFace());
|
mMtlFrontFace = MTLFrontFace(GetFrontFace());
|
||||||
mMtlCullMode = ToMTLCullMode(GetCullMode());
|
mMtlCullMode = ToMTLCullMode(GetCullMode());
|
||||||
|
@ -338,8 +338,9 @@ namespace dawn_native { namespace metal {
|
||||||
}
|
}
|
||||||
descriptorMTL.vertexDescriptor = vertexDesc.Get();
|
descriptorMTL.vertexDescriptor = vertexDesc.Get();
|
||||||
|
|
||||||
ShaderModule* vertexModule = ToBackend(descriptor->vertex.module);
|
const ProgrammableStage& vertexStage = GetStage(SingleShaderStage::Vertex);
|
||||||
const char* vertexEntryPoint = descriptor->vertex.entryPoint;
|
ShaderModule* vertexModule = ToBackend(vertexStage.module.Get());
|
||||||
|
const char* vertexEntryPoint = vertexStage.entryPoint.c_str();
|
||||||
ShaderModule::MetalFunctionData vertexData;
|
ShaderModule::MetalFunctionData vertexData;
|
||||||
DAWN_TRY(vertexModule->CreateFunction(vertexEntryPoint, SingleShaderStage::Vertex,
|
DAWN_TRY(vertexModule->CreateFunction(vertexEntryPoint, SingleShaderStage::Vertex,
|
||||||
ToBackend(GetLayout()), &vertexData, 0xFFFFFFFF,
|
ToBackend(GetLayout()), &vertexData, 0xFFFFFFFF,
|
||||||
|
@ -350,8 +351,9 @@ namespace dawn_native { namespace metal {
|
||||||
mStagesRequiringStorageBufferLength |= wgpu::ShaderStage::Vertex;
|
mStagesRequiringStorageBufferLength |= wgpu::ShaderStage::Vertex;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderModule* fragmentModule = ToBackend(descriptor->fragment->module);
|
const ProgrammableStage& fragmentStage = GetStage(SingleShaderStage::Fragment);
|
||||||
const char* fragmentEntryPoint = descriptor->fragment->entryPoint;
|
ShaderModule* fragmentModule = ToBackend(fragmentStage.module.Get());
|
||||||
|
const char* fragmentEntryPoint = fragmentStage.entryPoint.c_str();
|
||||||
ShaderModule::MetalFunctionData fragmentData;
|
ShaderModule::MetalFunctionData fragmentData;
|
||||||
DAWN_TRY(fragmentModule->CreateFunction(fragmentEntryPoint, SingleShaderStage::Fragment,
|
DAWN_TRY(fragmentModule->CreateFunction(fragmentEntryPoint, SingleShaderStage::Fragment,
|
||||||
ToBackend(GetLayout()), &fragmentData,
|
ToBackend(GetLayout()), &fragmentData,
|
||||||
|
|
|
@ -323,38 +323,40 @@ namespace dawn_native { namespace vulkan {
|
||||||
Device* device,
|
Device* device,
|
||||||
const RenderPipelineDescriptor* descriptor) {
|
const RenderPipelineDescriptor* descriptor) {
|
||||||
Ref<RenderPipeline> pipeline = AcquireRef(new RenderPipeline(device, descriptor));
|
Ref<RenderPipeline> pipeline = AcquireRef(new RenderPipeline(device, descriptor));
|
||||||
DAWN_TRY(pipeline->Initialize(descriptor));
|
DAWN_TRY(pipeline->Initialize());
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError RenderPipeline::Initialize(const RenderPipelineDescriptor* descriptor) {
|
MaybeError RenderPipeline::Initialize() {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
|
|
||||||
VkPipelineShaderStageCreateInfo shaderStages[2];
|
VkPipelineShaderStageCreateInfo shaderStages[2];
|
||||||
{
|
{
|
||||||
// Generate a new VkShaderModule with BindingRemapper tint transform for each
|
// Generate a new VkShaderModule with BindingRemapper tint transform for each
|
||||||
// pipeline
|
// pipeline
|
||||||
|
const ProgrammableStage& vertexStage = GetStage(SingleShaderStage::Vertex);
|
||||||
DAWN_TRY_ASSIGN(shaderStages[0].module,
|
DAWN_TRY_ASSIGN(shaderStages[0].module,
|
||||||
ToBackend(descriptor->vertex.module)
|
ToBackend(vertexStage.module.Get())
|
||||||
->GetTransformedModuleHandle(descriptor->vertex.entryPoint,
|
->GetTransformedModuleHandle(vertexStage.entryPoint.c_str(),
|
||||||
ToBackend(GetLayout())));
|
ToBackend(GetLayout())));
|
||||||
|
const ProgrammableStage& fragmentStage = GetStage(SingleShaderStage::Fragment);
|
||||||
DAWN_TRY_ASSIGN(shaderStages[1].module,
|
DAWN_TRY_ASSIGN(shaderStages[1].module,
|
||||||
ToBackend(descriptor->fragment->module)
|
ToBackend(fragmentStage.module.Get())
|
||||||
->GetTransformedModuleHandle(descriptor->fragment->entryPoint,
|
->GetTransformedModuleHandle(fragmentStage.entryPoint.c_str(),
|
||||||
ToBackend(GetLayout())));
|
ToBackend(GetLayout())));
|
||||||
shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||||
shaderStages[0].pNext = nullptr;
|
shaderStages[0].pNext = nullptr;
|
||||||
shaderStages[0].flags = 0;
|
shaderStages[0].flags = 0;
|
||||||
shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
|
shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
|
||||||
shaderStages[0].pSpecializationInfo = nullptr;
|
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].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||||
shaderStages[1].pNext = nullptr;
|
shaderStages[1].pNext = nullptr;
|
||||||
shaderStages[1].flags = 0;
|
shaderStages[1].flags = 0;
|
||||||
shaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
|
shaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||||
shaderStages[1].pSpecializationInfo = nullptr;
|
shaderStages[1].pSpecializationInfo = nullptr;
|
||||||
shaderStages[1].pName = descriptor->fragment->entryPoint;
|
shaderStages[1].pName = fragmentStage.entryPoint.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
PipelineVertexInputStateCreateInfoTemporaryAllocations tempAllocations;
|
PipelineVertexInputStateCreateInfoTemporaryAllocations tempAllocations;
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
private:
|
private:
|
||||||
~RenderPipeline() override;
|
~RenderPipeline() override;
|
||||||
using RenderPipelineBase::RenderPipelineBase;
|
using RenderPipelineBase::RenderPipelineBase;
|
||||||
MaybeError Initialize(const RenderPipelineDescriptor* descriptor);
|
MaybeError Initialize();
|
||||||
|
|
||||||
struct PipelineVertexInputStateCreateInfoTemporaryAllocations {
|
struct PipelineVertexInputStateCreateInfoTemporaryAllocations {
|
||||||
std::array<VkVertexInputBindingDescription, kMaxVertexBuffers> bindings;
|
std::array<VkVertexInputBindingDescription, kMaxVertexBuffers> bindings;
|
||||||
|
|
Loading…
Reference in New Issue