Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dual source blending #4022

Merged
merged 6 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions wgpu-core/src/device/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2564,6 +2564,7 @@ impl<A: HalApi> Device<A> {
let mut vertex_steps = Vec::with_capacity(desc.vertex.buffers.len());
let mut vertex_buffers = Vec::with_capacity(desc.vertex.buffers.len());
let mut total_attributes = 0;
let mut shader_expects_dual_source_blending = false;
let mut pipeline_expects_dual_source_blending = false;
for (i, vb_state) in desc.vertex.buffers.iter().enumerate() {
vertex_steps.push(pipeline::VertexStep {
Expand Down Expand Up @@ -2889,7 +2890,8 @@ impl<A: HalApi> Device<A> {
}

if let Some(ref interface) = shader_module.interface {
shader_expects_dual_source_blending = interface.is_fragment_entry_dual_source(fragment);
shader_expects_dual_source_blending =
interface.is_fragment_entry_dual_source(fragment).expect("Internal error: Fragment entrypoint should not be set in function if not present in shader interface");
teoxoy marked this conversation as resolved.
Show resolved Hide resolved
}

Some(hal::ProgrammableStage {
Expand All @@ -2901,10 +2903,14 @@ impl<A: HalApi> Device<A> {
};

if !pipeline_expects_dual_source_blending && shader_expects_dual_source_blending {
return Err(pipeline::CreateRenderPipelineError::ShaderExpectsPipelineToUseDualSourceBlending);
return Err(
pipeline::CreateRenderPipelineError::ShaderExpectsPipelineToUseDualSourceBlending,
);
}
if pipeline_expects_dual_source_blending && !shader_expects_dual_source_blending {
return Err(pipeline::CreateRenderPipelineError::PipelineExpectsShaderToUseDualSourceBlending);
return Err(
pipeline::CreateRenderPipelineError::PipelineExpectsShaderToUseDualSourceBlending,
);
}

if validated_stages.contains(wgt::ShaderStages::FRAGMENT) {
Expand Down
2 changes: 0 additions & 2 deletions wgpu-core/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,6 @@ pub enum CreateRenderPipelineError {
PipelineExpectsShaderToUseDualSourceBlending,
#[error("Shader entry point expects the pipeline to make use of dual-source blending.")]
ShaderExpectsPipelineToUseDualSourceBlending,
#[error("Shader entry point expects the pipeline to make use of dual-source blending, but pipeline contains no fragment stage.")]
ShaderExpectsPipelineToUseDualSourceBlendingNoFragmentStage,
}

bitflags::bitflags! {
Expand Down
Loading