mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-03 04:39:59 +00:00
shader: Fix disabled and unwritten attributes and varyings
This commit is contained in:
parent
65daec8b75
commit
5643a909bc
3 changed files with 31 additions and 18 deletions
|
@ -179,8 +179,12 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr,
|
||||||
const char swizzle{"xyzw"[element]};
|
const char swizzle{"xyzw"[element]};
|
||||||
if (IR::IsGeneric(attr)) {
|
if (IR::IsGeneric(attr)) {
|
||||||
const u32 index{IR::GenericAttributeIndex(attr)};
|
const u32 index{IR::GenericAttributeIndex(attr)};
|
||||||
if (!ctx.runtime_info.previous_stage_stores.Generic(index)) {
|
if (!ctx.runtime_info.previous_stage_stores.Generic(index, element)) {
|
||||||
ctx.AddF32("{}=0.f;", inst, attr);
|
if (element == 3) {
|
||||||
|
ctx.AddF32("{}=1.f;", inst, attr);
|
||||||
|
} else {
|
||||||
|
ctx.AddF32("{}=0.f;", inst, attr);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ctx.AddF32("{}=in_attr{}{}.{};", inst, index, InputVertexIndex(ctx, vertex), swizzle);
|
ctx.AddF32("{}=in_attr{}{}.{};", inst, index, InputVertexIndex(ctx, vertex), swizzle);
|
||||||
|
|
|
@ -298,10 +298,14 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) {
|
||||||
if (IR::IsGeneric(attr)) {
|
if (IR::IsGeneric(attr)) {
|
||||||
const u32 index{IR::GenericAttributeIndex(attr)};
|
const u32 index{IR::GenericAttributeIndex(attr)};
|
||||||
const std::optional<AttrInfo> type{AttrTypes(ctx, index)};
|
const std::optional<AttrInfo> type{AttrTypes(ctx, index)};
|
||||||
if (!type || !ctx.runtime_info.previous_stage_stores.Generic(index)) {
|
if (!type) {
|
||||||
// Attribute is disabled
|
// Attribute is disabled
|
||||||
return ctx.Const(0.0f);
|
return ctx.Const(0.0f);
|
||||||
}
|
}
|
||||||
|
if (!ctx.runtime_info.previous_stage_stores.Generic(index, element)) {
|
||||||
|
// Varying component is not written
|
||||||
|
return ctx.Const(type && element == 3 ? 1.0f : 0.0f);
|
||||||
|
}
|
||||||
const Id generic_id{ctx.input_generics.at(index)};
|
const Id generic_id{ctx.input_generics.at(index)};
|
||||||
const Id pointer{AttrPointer(ctx, type->pointer, vertex, generic_id, ctx.Const(element))};
|
const Id pointer{AttrPointer(ctx, type->pointer, vertex, generic_id, ctx.Const(element))};
|
||||||
const Id value{ctx.OpLoad(type->id, pointer)};
|
const Id value{ctx.OpLoad(type->id, pointer)};
|
||||||
|
|
|
@ -140,6 +140,26 @@ RendererOpenGL::RendererOpenGL(Core::TelemetrySession& telemetry_session_,
|
||||||
}
|
}
|
||||||
AddTelemetryFields();
|
AddTelemetryFields();
|
||||||
InitOpenGLObjects();
|
InitOpenGLObjects();
|
||||||
|
|
||||||
|
// Initialize default attributes to match hardware's disabled attributes
|
||||||
|
GLint max_attribs{};
|
||||||
|
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_attribs);
|
||||||
|
for (GLint attrib = 0; attrib < max_attribs; ++attrib) {
|
||||||
|
glVertexAttrib4f(attrib, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
// Enable seamless cubemaps when per texture parameters are not available
|
||||||
|
if (!GLAD_GL_ARB_seamless_cubemap_per_texture && !GLAD_GL_AMD_seamless_cubemap_per_texture) {
|
||||||
|
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
|
||||||
|
}
|
||||||
|
// Enable unified vertex attributes and query vertex buffer address when the driver supports it
|
||||||
|
if (device.HasVertexBufferUnifiedMemory()) {
|
||||||
|
glEnableClientState(GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV);
|
||||||
|
glEnableClientState(GL_ELEMENT_ARRAY_UNIFIED_NV);
|
||||||
|
|
||||||
|
glMakeNamedBufferResidentNV(vertex_buffer.handle, GL_READ_ONLY);
|
||||||
|
glGetNamedBufferParameterui64vNV(vertex_buffer.handle, GL_BUFFER_GPU_ADDRESS_NV,
|
||||||
|
&vertex_buffer_address);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RendererOpenGL::~RendererOpenGL() = default;
|
RendererOpenGL::~RendererOpenGL() = default;
|
||||||
|
@ -256,21 +276,6 @@ void RendererOpenGL::InitOpenGLObjects() {
|
||||||
|
|
||||||
// Clear screen to black
|
// Clear screen to black
|
||||||
LoadColorToActiveGLTexture(0, 0, 0, 0, screen_info.texture);
|
LoadColorToActiveGLTexture(0, 0, 0, 0, screen_info.texture);
|
||||||
|
|
||||||
// Enable seamless cubemaps when per texture parameters are not available
|
|
||||||
if (!GLAD_GL_ARB_seamless_cubemap_per_texture && !GLAD_GL_AMD_seamless_cubemap_per_texture) {
|
|
||||||
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable unified vertex attributes and query vertex buffer address when the driver supports it
|
|
||||||
if (device.HasVertexBufferUnifiedMemory()) {
|
|
||||||
glEnableClientState(GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV);
|
|
||||||
glEnableClientState(GL_ELEMENT_ARRAY_UNIFIED_NV);
|
|
||||||
|
|
||||||
glMakeNamedBufferResidentNV(vertex_buffer.handle, GL_READ_ONLY);
|
|
||||||
glGetNamedBufferParameterui64vNV(vertex_buffer.handle, GL_BUFFER_GPU_ADDRESS_NV,
|
|
||||||
&vertex_buffer_address);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererOpenGL::AddTelemetryFields() {
|
void RendererOpenGL::AddTelemetryFields() {
|
||||||
|
|
Loading…
Reference in a new issue