Browse Source
shader: Rework varyings and implement passthrough geometry shaders
shader: Rework varyings and implement passthrough geometry shaders
Put all varyings into a single std::bitset with helpers to access it. Implement passthrough geometry shaders using host's.nce_cpp
committed by
ameerj
29 changed files with 345 additions and 331 deletions
-
1src/shader_recompiler/CMakeLists.txt
-
15src/shader_recompiler/backend/glasm/emit_context.cpp
-
6src/shader_recompiler/backend/glasm/emit_glasm.cpp
-
6src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp
-
58src/shader_recompiler/backend/glsl/emit_context.cpp
-
2src/shader_recompiler/backend/glsl/emit_glsl.cpp
-
2src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp
-
4src/shader_recompiler/backend/glsl/emit_glsl_special.cpp
-
97src/shader_recompiler/backend/spirv/emit_context.cpp
-
2src/shader_recompiler/backend/spirv/emit_context.h
-
19src/shader_recompiler/backend/spirv/emit_spirv.cpp
-
2src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
-
5src/shader_recompiler/environment.h
-
6src/shader_recompiler/frontend/ir/attribute.h
-
1src/shader_recompiler/frontend/ir/program.h
-
18src/shader_recompiler/frontend/maxwell/translate_program.cpp
-
202src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
-
1src/shader_recompiler/profile.h
-
62src/shader_recompiler/program_header.h
-
3src/shader_recompiler/runtime_info.h
-
37src/shader_recompiler/shader_info.h
-
69src/shader_recompiler/varying_state.h
-
7src/video_core/engines/maxwell_3d.h
-
7src/video_core/renderer_opengl/gl_shader_cache.cpp
-
6src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
-
16src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
-
10src/video_core/shader_environment.cpp
-
6src/video_core/vulkan_common/vulkan_device.cpp
-
6src/video_core/vulkan_common/vulkan_device.h
@ -0,0 +1,69 @@ |
|||
// Copyright 2021 yuzu Emulator Project |
|||
// Licensed under GPLv2 or any later version |
|||
// Refer to the license.txt file included. |
|||
|
|||
#pragma once |
|||
|
|||
#include <bitset> |
|||
#include <cstddef> |
|||
|
|||
#include "shader_recompiler/frontend/ir/attribute.h" |
|||
|
|||
namespace Shader { |
|||
|
|||
struct VaryingState { |
|||
std::bitset<256> mask{}; |
|||
|
|||
void Set(IR::Attribute attribute, bool state = true) { |
|||
mask[static_cast<size_t>(attribute)] = state; |
|||
} |
|||
|
|||
[[nodiscard]] bool operator[](IR::Attribute attribute) const noexcept { |
|||
return mask[static_cast<size_t>(attribute)]; |
|||
} |
|||
|
|||
[[nodiscard]] bool AnyComponent(IR::Attribute base) const noexcept { |
|||
return mask[static_cast<size_t>(base) + 0] || mask[static_cast<size_t>(base) + 1] || |
|||
mask[static_cast<size_t>(base) + 2] || mask[static_cast<size_t>(base) + 3]; |
|||
} |
|||
|
|||
[[nodiscard]] bool AllComponents(IR::Attribute base) const noexcept { |
|||
return mask[static_cast<size_t>(base) + 0] && mask[static_cast<size_t>(base) + 1] && |
|||
mask[static_cast<size_t>(base) + 2] && mask[static_cast<size_t>(base) + 3]; |
|||
} |
|||
|
|||
[[nodiscard]] bool IsUniform(IR::Attribute base) const noexcept { |
|||
return AnyComponent(base) == AllComponents(base); |
|||
} |
|||
|
|||
[[nodiscard]] bool Generic(size_t index, size_t component) const noexcept { |
|||
return mask[static_cast<size_t>(IR::Attribute::Generic0X) + index * 4 + component]; |
|||
} |
|||
|
|||
[[nodiscard]] bool Generic(size_t index) const noexcept { |
|||
return Generic(index, 0) || Generic(index, 1) || Generic(index, 2) || Generic(index, 3); |
|||
} |
|||
|
|||
[[nodiscard]] bool ClipDistances() const noexcept { |
|||
return AnyComponent(IR::Attribute::ClipDistance0) || |
|||
AnyComponent(IR::Attribute::ClipDistance4); |
|||
} |
|||
|
|||
[[nodiscard]] bool Legacy() const noexcept { |
|||
return AnyComponent(IR::Attribute::ColorFrontDiffuseR) || |
|||
AnyComponent(IR::Attribute::ColorFrontSpecularR) || |
|||
AnyComponent(IR::Attribute::ColorBackDiffuseR) || |
|||
AnyComponent(IR::Attribute::ColorBackSpecularR) || FixedFunctionTexture(); |
|||
} |
|||
|
|||
[[nodiscard]] bool FixedFunctionTexture() const noexcept { |
|||
for (size_t index = 0; index < 10; ++index) { |
|||
if (AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { |
|||
return true; |
|||
} |
|||
} |
|||
return false; |
|||
} |
|||
}; |
|||
|
|||
} // namespace Shader |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue