shader: Fix fixed pipeline point size on geometry shaders

This commit is contained in:
ReinUsesLisp 2021-04-12 22:26:15 -03:00 committed by ameerj
parent 2597cee85b
commit c070991def

View file

@ -15,6 +15,13 @@ void ConvertDepthMode(EmitContext& ctx) {
const Id vector{ctx.OpCompositeInsert(ctx.F32[4], screen_depth, position, 2u)}; const Id vector{ctx.OpCompositeInsert(ctx.F32[4], screen_depth, position, 2u)};
ctx.OpStore(ctx.output_position, vector); ctx.OpStore(ctx.output_position, vector);
} }
void SetFixedPipelinePointSize(EmitContext& ctx) {
if (ctx.profile.fixed_state_point_size) {
const float point_size{*ctx.profile.fixed_state_point_size};
ctx.OpStore(ctx.output_point_size, ctx.Constant(ctx.F32[1], point_size));
}
}
} // Anonymous namespace } // Anonymous namespace
void EmitPrologue(EmitContext& ctx) { void EmitPrologue(EmitContext& ctx) {
@ -28,10 +35,9 @@ void EmitPrologue(EmitContext& ctx) {
ctx.OpStore(generic_id, default_vector); ctx.OpStore(generic_id, default_vector);
} }
} }
if (ctx.profile.fixed_state_point_size) {
const float point_size{*ctx.profile.fixed_state_point_size};
ctx.OpStore(ctx.output_point_size, ctx.Constant(ctx.F32[1], point_size));
} }
if (ctx.stage == Stage::VertexB || ctx.stage == Stage::Geometry) {
SetFixedPipelinePointSize(ctx);
} }
} }
@ -45,21 +51,23 @@ void EmitEmitVertex(EmitContext& ctx, const IR::Value& stream) {
if (ctx.profile.convert_depth_mode) { if (ctx.profile.convert_depth_mode) {
ConvertDepthMode(ctx); ConvertDepthMode(ctx);
} }
if (!stream.IsImmediate()) { if (stream.IsImmediate()) {
ctx.OpEmitStreamVertex(ctx.Def(stream));
} else {
// LOG_WARNING(..., "EmitVertex's stream is not constant"); // LOG_WARNING(..., "EmitVertex's stream is not constant");
ctx.OpEmitStreamVertex(ctx.u32_zero_value); ctx.OpEmitStreamVertex(ctx.u32_zero_value);
return;
} }
ctx.OpEmitStreamVertex(ctx.Def(stream)); // Restore fixed pipeline point size after emitting the vertex
SetFixedPipelinePointSize(ctx);
} }
void EmitEndPrimitive(EmitContext& ctx, const IR::Value& stream) { void EmitEndPrimitive(EmitContext& ctx, const IR::Value& stream) {
if (!stream.IsImmediate()) { if (stream.IsImmediate()) {
ctx.OpEndStreamPrimitive(ctx.Def(stream));
} else {
// LOG_WARNING(..., "EndPrimitive's stream is not constant"); // LOG_WARNING(..., "EndPrimitive's stream is not constant");
ctx.OpEndStreamPrimitive(ctx.u32_zero_value); ctx.OpEndStreamPrimitive(ctx.u32_zero_value);
return;
} }
ctx.OpEndStreamPrimitive(ctx.Def(stream));
} }
} // namespace Shader::Backend::SPIRV } // namespace Shader::Backend::SPIRV