mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2024-12-26 21:41:21 -08:00
glsl: Add passthrough geometry shader support
This commit is contained in:
parent
8612b5fec5
commit
f7352411f0
@ -236,6 +236,9 @@ void SetupOutPerVertex(EmitContext& ctx, std::string& header) {
|
|||||||
if (!StoresPerVertexAttributes(ctx.stage)) {
|
if (!StoresPerVertexAttributes(ctx.stage)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (ctx.uses_geometry_passthrough) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
header += "out gl_PerVertex{vec4 gl_Position;";
|
header += "out gl_PerVertex{vec4 gl_Position;";
|
||||||
if (ctx.info.stores[IR::Attribute::PointSize]) {
|
if (ctx.info.stores[IR::Attribute::PointSize]) {
|
||||||
header += "float gl_PointSize;";
|
header += "float gl_PointSize;";
|
||||||
@ -272,12 +275,13 @@ void SetupLegacyInPerFragment(EmitContext& ctx, std::string& header) {
|
|||||||
|
|
||||||
EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_,
|
EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_,
|
||||||
const RuntimeInfo& runtime_info_)
|
const RuntimeInfo& runtime_info_)
|
||||||
: info{program.info}, profile{profile_}, runtime_info{runtime_info_} {
|
: info{program.info}, profile{profile_}, runtime_info{runtime_info_}, stage{program.stage},
|
||||||
|
uses_geometry_passthrough{program.is_geometry_passthrough &&
|
||||||
|
profile.support_geometry_shader_passthrough} {
|
||||||
if (profile.need_fastmath_off) {
|
if (profile.need_fastmath_off) {
|
||||||
header += "#pragma optionNV(fastmath off)\n";
|
header += "#pragma optionNV(fastmath off)\n";
|
||||||
}
|
}
|
||||||
SetupExtensions();
|
SetupExtensions();
|
||||||
stage = program.stage;
|
|
||||||
switch (program.stage) {
|
switch (program.stage) {
|
||||||
case Stage::VertexA:
|
case Stage::VertexA:
|
||||||
case Stage::VertexB:
|
case Stage::VertexB:
|
||||||
@ -295,9 +299,16 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
|
|||||||
break;
|
break;
|
||||||
case Stage::Geometry:
|
case Stage::Geometry:
|
||||||
stage_name = "gs";
|
stage_name = "gs";
|
||||||
header += fmt::format("layout({})in;layout({},max_vertices={})out;"
|
header += fmt::format("layout({})in;", InputPrimitive(runtime_info.input_topology));
|
||||||
"in gl_PerVertex{{vec4 gl_Position;}}gl_in[];",
|
if (uses_geometry_passthrough) {
|
||||||
InputPrimitive(runtime_info.input_topology),
|
header += "layout(passthrough)in gl_PerVertex{vec4 gl_Position;};";
|
||||||
|
break;
|
||||||
|
} else if (program.is_geometry_passthrough &&
|
||||||
|
!profile.support_geometry_shader_passthrough) {
|
||||||
|
LOG_WARNING(Shader_GLSL, "Passthrough geometry program used but not supported");
|
||||||
|
}
|
||||||
|
header += fmt::format(
|
||||||
|
"layout({},max_vertices={})out;in gl_PerVertex{{vec4 gl_Position;}}gl_in[];",
|
||||||
OutputPrimitive(program.output_topology), program.output_vertices);
|
OutputPrimitive(program.output_topology), program.output_vertices);
|
||||||
break;
|
break;
|
||||||
case Stage::Fragment:
|
case Stage::Fragment:
|
||||||
@ -329,7 +340,9 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
|
|||||||
if (!info.loads.Generic(index) || !runtime_info.previous_stage_stores.Generic(index)) {
|
if (!info.loads.Generic(index) || !runtime_info.previous_stage_stores.Generic(index)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
header += fmt::format("layout(location={}){}in vec4 in_attr{}{};", index,
|
const auto qualifier{uses_geometry_passthrough ? "passthrough"
|
||||||
|
: fmt::format("location={}", index)};
|
||||||
|
header += fmt::format("layout({}){}in vec4 in_attr{}{};", qualifier,
|
||||||
InterpDecorator(info.interpolation[index]), index,
|
InterpDecorator(info.interpolation[index]), index,
|
||||||
InputArrayDecorator(stage));
|
InputArrayDecorator(stage));
|
||||||
}
|
}
|
||||||
@ -412,6 +425,9 @@ void EmitContext::SetupExtensions() {
|
|||||||
if (info.uses_derivatives && profile.support_gl_derivative_control) {
|
if (info.uses_derivatives && profile.support_gl_derivative_control) {
|
||||||
header += "#extension GL_ARB_derivative_control : enable\n";
|
header += "#extension GL_ARB_derivative_control : enable\n";
|
||||||
}
|
}
|
||||||
|
if (uses_geometry_passthrough) {
|
||||||
|
header += "#extension GL_NV_geometry_shader_passthrough : enable\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitContext::DefineConstantBuffers(Bindings& bindings) {
|
void EmitContext::DefineConstantBuffers(Bindings& bindings) {
|
||||||
|
@ -157,6 +157,7 @@ public:
|
|||||||
|
|
||||||
bool uses_y_direction{};
|
bool uses_y_direction{};
|
||||||
bool uses_cc_carry{};
|
bool uses_cc_carry{};
|
||||||
|
bool uses_geometry_passthrough{};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetupExtensions();
|
void SetupExtensions();
|
||||||
|
@ -17,6 +17,9 @@ std::string_view OutputVertexIndex(EmitContext& ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InitializeOutputVaryings(EmitContext& ctx) {
|
void InitializeOutputVaryings(EmitContext& ctx) {
|
||||||
|
if (ctx.uses_geometry_passthrough) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ctx.stage == Stage::VertexB || ctx.stage == Stage::Geometry) {
|
if (ctx.stage == Stage::VertexB || ctx.stage == Stage::Geometry) {
|
||||||
ctx.Add("gl_Position=vec4(0,0,0,1);");
|
ctx.Add("gl_Position=vec4(0,0,0,1);");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user