video_core: Limit g_state usage in rasterizers
* Makes the code cleaner and should help in future refactoring endeavors
This commit is contained in:
@ -7,7 +7,6 @@
|
||||
#include "core/memory.h"
|
||||
#include "video_core/pica_state.h"
|
||||
#include "video_core/rasterizer_accelerated.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
namespace VideoCore {
|
||||
|
||||
@ -51,7 +50,8 @@ RasterizerAccelerated::HardwareVertex::HardwareVertex(const Pica::Shader::Output
|
||||
}
|
||||
}
|
||||
|
||||
RasterizerAccelerated::RasterizerAccelerated() {
|
||||
RasterizerAccelerated::RasterizerAccelerated(Memory::MemorySystem& memory_)
|
||||
: memory{memory_}, regs{Pica::g_state.regs} {
|
||||
uniform_block_data.lighting_lut_dirty.fill(true);
|
||||
}
|
||||
|
||||
@ -90,7 +90,6 @@ void RasterizerAccelerated::AddTriangle(const Pica::Shader::OutputVertex& v0,
|
||||
|
||||
RasterizerAccelerated::VertexArrayInfo RasterizerAccelerated::AnalyzeVertexArray(
|
||||
bool is_indexed, u32 stride_alignment) {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
const auto& vertex_attributes = regs.pipeline.vertex_attributes;
|
||||
|
||||
u32 vertex_min;
|
||||
@ -98,7 +97,7 @@ RasterizerAccelerated::VertexArrayInfo RasterizerAccelerated::AnalyzeVertexArray
|
||||
if (is_indexed) {
|
||||
const auto& index_info = regs.pipeline.index_array;
|
||||
const PAddr address = vertex_attributes.GetPhysicalBaseAddress() + index_info.offset;
|
||||
const u8* index_address_8 = VideoCore::g_memory->GetPhysicalPointer(address);
|
||||
const u8* index_address_8 = memory.GetPhysicalPointer(address);
|
||||
const u16* index_address_16 = reinterpret_cast<const u16*>(index_address_8);
|
||||
const bool index_u16 = index_info.format != 0;
|
||||
|
||||
@ -139,9 +138,10 @@ void RasterizerAccelerated::SyncEntireState() {
|
||||
SyncDepthOffset();
|
||||
SyncAlphaTest();
|
||||
SyncCombinerColor();
|
||||
auto& tev_stages = Pica::g_state.regs.texturing.GetTevStages();
|
||||
for (std::size_t index = 0; index < tev_stages.size(); ++index)
|
||||
auto& tev_stages = regs.texturing.GetTevStages();
|
||||
for (std::size_t index = 0; index < tev_stages.size(); ++index) {
|
||||
SyncTevConstColor(index, tev_stages[index]);
|
||||
}
|
||||
|
||||
SyncGlobalAmbient();
|
||||
for (unsigned light_index = 0; light_index < 8; light_index++) {
|
||||
@ -166,8 +166,6 @@ void RasterizerAccelerated::SyncEntireState() {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::NotifyPicaRegisterChanged(u32 id) {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
|
||||
switch (id) {
|
||||
// Depth modifiers
|
||||
case PICA_REG_INDEX(rasterizer.viewport_depth_range):
|
||||
@ -614,8 +612,7 @@ void RasterizerAccelerated::NotifyPicaRegisterChanged(u32 id) {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncDepthScale() {
|
||||
float depth_scale =
|
||||
Pica::float24::FromRaw(Pica::g_state.regs.rasterizer.viewport_depth_range).ToFloat32();
|
||||
float depth_scale = Pica::float24::FromRaw(regs.rasterizer.viewport_depth_range).ToFloat32();
|
||||
|
||||
if (depth_scale != uniform_block_data.data.depth_scale) {
|
||||
uniform_block_data.data.depth_scale = depth_scale;
|
||||
@ -625,7 +622,7 @@ void RasterizerAccelerated::SyncDepthScale() {
|
||||
|
||||
void RasterizerAccelerated::SyncDepthOffset() {
|
||||
float depth_offset =
|
||||
Pica::float24::FromRaw(Pica::g_state.regs.rasterizer.viewport_depth_near_plane).ToFloat32();
|
||||
Pica::float24::FromRaw(regs.rasterizer.viewport_depth_near_plane).ToFloat32();
|
||||
|
||||
if (depth_offset != uniform_block_data.data.depth_offset) {
|
||||
uniform_block_data.data.depth_offset = depth_offset;
|
||||
@ -634,7 +631,7 @@ void RasterizerAccelerated::SyncDepthOffset() {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncFogColor() {
|
||||
const auto& fog_color_regs = Pica::g_state.regs.texturing.fog_color;
|
||||
const auto& fog_color_regs = regs.texturing.fog_color;
|
||||
const Common::Vec3f fog_color = {
|
||||
fog_color_regs.r.Value() / 255.0f,
|
||||
fog_color_regs.g.Value() / 255.0f,
|
||||
@ -648,18 +645,17 @@ void RasterizerAccelerated::SyncFogColor() {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncProcTexNoise() {
|
||||
const auto& regs = Pica::g_state.regs.texturing;
|
||||
const Common::Vec2f proctex_noise_f = {
|
||||
Pica::float16::FromRaw(regs.proctex_noise_frequency.u).ToFloat32(),
|
||||
Pica::float16::FromRaw(regs.proctex_noise_frequency.v).ToFloat32(),
|
||||
Pica::float16::FromRaw(regs.texturing.proctex_noise_frequency.u).ToFloat32(),
|
||||
Pica::float16::FromRaw(regs.texturing.proctex_noise_frequency.v).ToFloat32(),
|
||||
};
|
||||
const Common::Vec2f proctex_noise_a = {
|
||||
regs.proctex_noise_u.amplitude / 4095.0f,
|
||||
regs.proctex_noise_v.amplitude / 4095.0f,
|
||||
regs.texturing.proctex_noise_u.amplitude / 4095.0f,
|
||||
regs.texturing.proctex_noise_v.amplitude / 4095.0f,
|
||||
};
|
||||
const Common::Vec2f proctex_noise_p = {
|
||||
Pica::float16::FromRaw(regs.proctex_noise_u.phase).ToFloat32(),
|
||||
Pica::float16::FromRaw(regs.proctex_noise_v.phase).ToFloat32(),
|
||||
Pica::float16::FromRaw(regs.texturing.proctex_noise_u.phase).ToFloat32(),
|
||||
Pica::float16::FromRaw(regs.texturing.proctex_noise_v.phase).ToFloat32(),
|
||||
};
|
||||
|
||||
if (proctex_noise_f != uniform_block_data.data.proctex_noise_f ||
|
||||
@ -673,10 +669,9 @@ void RasterizerAccelerated::SyncProcTexNoise() {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncProcTexBias() {
|
||||
const auto& regs = Pica::g_state.regs.texturing;
|
||||
const auto proctex_bias =
|
||||
Pica::float16::FromRaw(regs.proctex.bias_low | (regs.proctex_lut.bias_high << 8))
|
||||
.ToFloat32();
|
||||
const auto proctex_bias = Pica::float16::FromRaw(regs.texturing.proctex.bias_low |
|
||||
(regs.texturing.proctex_lut.bias_high << 8))
|
||||
.ToFloat32();
|
||||
if (proctex_bias != uniform_block_data.data.proctex_bias) {
|
||||
uniform_block_data.data.proctex_bias = proctex_bias;
|
||||
uniform_block_data.dirty = true;
|
||||
@ -684,7 +679,6 @@ void RasterizerAccelerated::SyncProcTexBias() {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncAlphaTest() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
if (regs.framebuffer.output_merger.alpha_test.ref != uniform_block_data.data.alphatest_ref) {
|
||||
uniform_block_data.data.alphatest_ref = regs.framebuffer.output_merger.alpha_test.ref;
|
||||
uniform_block_data.dirty = true;
|
||||
@ -692,7 +686,7 @@ void RasterizerAccelerated::SyncAlphaTest() {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncCombinerColor() {
|
||||
auto combiner_color = ColorRGBA8(Pica::g_state.regs.texturing.tev_combiner_buffer_color.raw);
|
||||
auto combiner_color = ColorRGBA8(regs.texturing.tev_combiner_buffer_color.raw);
|
||||
if (combiner_color != uniform_block_data.data.tev_combiner_buffer_color) {
|
||||
uniform_block_data.data.tev_combiner_buffer_color = combiner_color;
|
||||
uniform_block_data.dirty = true;
|
||||
@ -712,7 +706,7 @@ void RasterizerAccelerated::SyncTevConstColor(
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncGlobalAmbient() {
|
||||
auto color = LightColor(Pica::g_state.regs.lighting.global_ambient);
|
||||
auto color = LightColor(regs.lighting.global_ambient);
|
||||
if (color != uniform_block_data.data.lighting_global_ambient) {
|
||||
uniform_block_data.data.lighting_global_ambient = color;
|
||||
uniform_block_data.dirty = true;
|
||||
@ -720,7 +714,7 @@ void RasterizerAccelerated::SyncGlobalAmbient() {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncLightSpecular0(int light_index) {
|
||||
auto color = LightColor(Pica::g_state.regs.lighting.light[light_index].specular_0);
|
||||
auto color = LightColor(regs.lighting.light[light_index].specular_0);
|
||||
if (color != uniform_block_data.data.light_src[light_index].specular_0) {
|
||||
uniform_block_data.data.light_src[light_index].specular_0 = color;
|
||||
uniform_block_data.dirty = true;
|
||||
@ -728,7 +722,7 @@ void RasterizerAccelerated::SyncLightSpecular0(int light_index) {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncLightSpecular1(int light_index) {
|
||||
auto color = LightColor(Pica::g_state.regs.lighting.light[light_index].specular_1);
|
||||
auto color = LightColor(regs.lighting.light[light_index].specular_1);
|
||||
if (color != uniform_block_data.data.light_src[light_index].specular_1) {
|
||||
uniform_block_data.data.light_src[light_index].specular_1 = color;
|
||||
uniform_block_data.dirty = true;
|
||||
@ -736,7 +730,7 @@ void RasterizerAccelerated::SyncLightSpecular1(int light_index) {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncLightDiffuse(int light_index) {
|
||||
auto color = LightColor(Pica::g_state.regs.lighting.light[light_index].diffuse);
|
||||
auto color = LightColor(regs.lighting.light[light_index].diffuse);
|
||||
if (color != uniform_block_data.data.light_src[light_index].diffuse) {
|
||||
uniform_block_data.data.light_src[light_index].diffuse = color;
|
||||
uniform_block_data.dirty = true;
|
||||
@ -744,7 +738,7 @@ void RasterizerAccelerated::SyncLightDiffuse(int light_index) {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncLightAmbient(int light_index) {
|
||||
auto color = LightColor(Pica::g_state.regs.lighting.light[light_index].ambient);
|
||||
auto color = LightColor(regs.lighting.light[light_index].ambient);
|
||||
if (color != uniform_block_data.data.light_src[light_index].ambient) {
|
||||
uniform_block_data.data.light_src[light_index].ambient = color;
|
||||
uniform_block_data.dirty = true;
|
||||
@ -753,9 +747,9 @@ void RasterizerAccelerated::SyncLightAmbient(int light_index) {
|
||||
|
||||
void RasterizerAccelerated::SyncLightPosition(int light_index) {
|
||||
const Common::Vec3f position = {
|
||||
Pica::float16::FromRaw(Pica::g_state.regs.lighting.light[light_index].x).ToFloat32(),
|
||||
Pica::float16::FromRaw(Pica::g_state.regs.lighting.light[light_index].y).ToFloat32(),
|
||||
Pica::float16::FromRaw(Pica::g_state.regs.lighting.light[light_index].z).ToFloat32(),
|
||||
Pica::float16::FromRaw(regs.lighting.light[light_index].x).ToFloat32(),
|
||||
Pica::float16::FromRaw(regs.lighting.light[light_index].y).ToFloat32(),
|
||||
Pica::float16::FromRaw(regs.lighting.light[light_index].z).ToFloat32(),
|
||||
};
|
||||
|
||||
if (position != uniform_block_data.data.light_src[light_index].position) {
|
||||
@ -765,7 +759,7 @@ void RasterizerAccelerated::SyncLightPosition(int light_index) {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncLightSpotDirection(int light_index) {
|
||||
const auto& light = Pica::g_state.regs.lighting.light[light_index];
|
||||
const auto& light = regs.lighting.light[light_index];
|
||||
const auto spot_direction =
|
||||
Common::Vec3f{light.spot_x / 2047.0f, light.spot_y / 2047.0f, light.spot_z / 2047.0f};
|
||||
|
||||
@ -777,8 +771,7 @@ void RasterizerAccelerated::SyncLightSpotDirection(int light_index) {
|
||||
|
||||
void RasterizerAccelerated::SyncLightDistanceAttenuationBias(int light_index) {
|
||||
float dist_atten_bias =
|
||||
Pica::float20::FromRaw(Pica::g_state.regs.lighting.light[light_index].dist_atten_bias)
|
||||
.ToFloat32();
|
||||
Pica::float20::FromRaw(regs.lighting.light[light_index].dist_atten_bias).ToFloat32();
|
||||
|
||||
if (dist_atten_bias != uniform_block_data.data.light_src[light_index].dist_atten_bias) {
|
||||
uniform_block_data.data.light_src[light_index].dist_atten_bias = dist_atten_bias;
|
||||
@ -788,8 +781,7 @@ void RasterizerAccelerated::SyncLightDistanceAttenuationBias(int light_index) {
|
||||
|
||||
void RasterizerAccelerated::SyncLightDistanceAttenuationScale(int light_index) {
|
||||
float dist_atten_scale =
|
||||
Pica::float20::FromRaw(Pica::g_state.regs.lighting.light[light_index].dist_atten_scale)
|
||||
.ToFloat32();
|
||||
Pica::float20::FromRaw(regs.lighting.light[light_index].dist_atten_scale).ToFloat32();
|
||||
|
||||
if (dist_atten_scale != uniform_block_data.data.light_src[light_index].dist_atten_scale) {
|
||||
uniform_block_data.data.light_src[light_index].dist_atten_scale = dist_atten_scale;
|
||||
@ -798,7 +790,7 @@ void RasterizerAccelerated::SyncLightDistanceAttenuationScale(int light_index) {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncShadowBias() {
|
||||
const auto& shadow = Pica::g_state.regs.framebuffer.shadow;
|
||||
const auto& shadow = regs.framebuffer.shadow;
|
||||
float constant = Pica::float16::FromRaw(shadow.constant).ToFloat32();
|
||||
float linear = Pica::float16::FromRaw(shadow.linear).ToFloat32();
|
||||
|
||||
@ -811,7 +803,7 @@ void RasterizerAccelerated::SyncShadowBias() {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncShadowTextureBias() {
|
||||
int bias = Pica::g_state.regs.texturing.shadow.bias << 1;
|
||||
int bias = regs.texturing.shadow.bias << 1;
|
||||
if (bias != uniform_block_data.data.shadow_texture_bias) {
|
||||
uniform_block_data.data.shadow_texture_bias = bias;
|
||||
uniform_block_data.dirty = true;
|
||||
@ -819,7 +811,7 @@ void RasterizerAccelerated::SyncShadowTextureBias() {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncTextureLodBias(int tex_index) {
|
||||
const auto pica_textures = Pica::g_state.regs.texturing.GetTextures();
|
||||
const auto pica_textures = regs.texturing.GetTextures();
|
||||
const float bias = pica_textures[tex_index].config.lod.bias / 256.0f;
|
||||
if (bias != uniform_block_data.data.tex_lod_bias[tex_index]) {
|
||||
uniform_block_data.data.tex_lod_bias[tex_index] = bias;
|
||||
@ -828,7 +820,7 @@ void RasterizerAccelerated::SyncTextureLodBias(int tex_index) {
|
||||
}
|
||||
|
||||
void RasterizerAccelerated::SyncClipCoef() {
|
||||
const auto raw_clip_coef = Pica::g_state.regs.rasterizer.GetClipCoef();
|
||||
const auto raw_clip_coef = regs.rasterizer.GetClipCoef();
|
||||
const Common::Vec4f new_clip_coef = {raw_clip_coef.x.ToFloat32(), raw_clip_coef.y.ToFloat32(),
|
||||
raw_clip_coef.z.ToFloat32(), raw_clip_coef.w.ToFloat32()};
|
||||
if (new_clip_coef != uniform_block_data.data.clip_coef) {
|
||||
|
@ -9,11 +9,19 @@
|
||||
#include "video_core/regs_texturing.h"
|
||||
#include "video_core/shader/shader_uniforms.h"
|
||||
|
||||
namespace Memory {
|
||||
class MemorySystem;
|
||||
}
|
||||
|
||||
namespace Pica {
|
||||
struct Regs;
|
||||
}
|
||||
|
||||
namespace VideoCore {
|
||||
|
||||
class RasterizerAccelerated : public RasterizerInterface {
|
||||
public:
|
||||
RasterizerAccelerated();
|
||||
RasterizerAccelerated(Memory::MemorySystem& memory);
|
||||
virtual ~RasterizerAccelerated() = default;
|
||||
|
||||
void AddTriangle(const Pica::Shader::OutputVertex& v0, const Pica::Shader::OutputVertex& v1,
|
||||
@ -132,6 +140,9 @@ protected:
|
||||
VertexArrayInfo AnalyzeVertexArray(bool is_indexed, u32 stride_alignment = 1);
|
||||
|
||||
protected:
|
||||
Memory::MemorySystem& memory;
|
||||
Pica::Regs& regs;
|
||||
|
||||
std::vector<HardwareVertex> vertex_batch;
|
||||
bool shader_dirty = true;
|
||||
|
||||
|
@ -25,7 +25,7 @@ constexpr std::size_t TEXTURE_BUFFER_SIZE = 1 * 1024 * 1024;
|
||||
|
||||
RasterizerOpenGL::RasterizerOpenGL(Memory::MemorySystem& memory_, Frontend::EmuWindow& emu_window,
|
||||
Driver& driver_)
|
||||
: memory{memory_}, driver{driver_}, runtime{driver}, res_cache{memory, runtime},
|
||||
: RasterizerAccelerated{memory_}, driver{driver_}, runtime{driver}, res_cache{memory, runtime},
|
||||
shader_program_manager{emu_window, driver, !driver.IsOpenGLES()},
|
||||
vertex_buffer{GL_ARRAY_BUFFER, VERTEX_BUFFER_SIZE}, uniform_buffer{GL_UNIFORM_BUFFER,
|
||||
UNIFORM_BUFFER_SIZE},
|
||||
@ -160,7 +160,6 @@ MICROPROFILE_DEFINE(OpenGL_VAO, "OpenGL", "Vertex Array Setup", MP_RGB(255, 128,
|
||||
void RasterizerOpenGL::SetupVertexArray(u8* array_ptr, GLintptr buffer_offset,
|
||||
GLuint vs_input_index_min, GLuint vs_input_index_max) {
|
||||
MICROPROFILE_SCOPE(OpenGL_VAO);
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
const auto& vertex_attributes = regs.pipeline.vertex_attributes;
|
||||
PAddr base_address = vertex_attributes.GetPhysicalBaseAddress();
|
||||
|
||||
@ -239,13 +238,12 @@ void RasterizerOpenGL::SetupVertexArray(u8* array_ptr, GLintptr buffer_offset,
|
||||
MICROPROFILE_DEFINE(OpenGL_VS, "OpenGL", "Vertex Shader Setup", MP_RGB(192, 128, 128));
|
||||
bool RasterizerOpenGL::SetupVertexShader() {
|
||||
MICROPROFILE_SCOPE(OpenGL_VS);
|
||||
return shader_program_manager.UseProgrammableVertexShader(Pica::g_state.regs, Pica::g_state.vs);
|
||||
return shader_program_manager.UseProgrammableVertexShader(regs, Pica::g_state.vs);
|
||||
}
|
||||
|
||||
MICROPROFILE_DEFINE(OpenGL_GS, "OpenGL", "Geometry Shader Setup", MP_RGB(128, 192, 128));
|
||||
bool RasterizerOpenGL::SetupGeometryShader() {
|
||||
MICROPROFILE_SCOPE(OpenGL_GS);
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
|
||||
if (regs.pipeline.use_gs != Pica::PipelineRegs::UseGS::No) {
|
||||
LOG_ERROR(Render_OpenGL, "Accelerate draw doesn't support geometry shader");
|
||||
@ -257,7 +255,6 @@ bool RasterizerOpenGL::SetupGeometryShader() {
|
||||
}
|
||||
|
||||
bool RasterizerOpenGL::AccelerateDrawBatch(bool is_indexed) {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
if (regs.pipeline.use_gs != Pica::PipelineRegs::UseGS::No) {
|
||||
if (regs.pipeline.gs_config.mode != Pica::PipelineRegs::GSMode::Point) {
|
||||
return false;
|
||||
@ -276,9 +273,8 @@ bool RasterizerOpenGL::AccelerateDrawBatch(bool is_indexed) {
|
||||
return Draw(true, is_indexed);
|
||||
}
|
||||
|
||||
static GLenum GetCurrentPrimitiveMode() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
switch (regs.pipeline.triangle_topology) {
|
||||
static GLenum MakePrimitiveMode(Pica::PipelineRegs::TriangleTopology topology) {
|
||||
switch (topology) {
|
||||
case Pica::PipelineRegs::TriangleTopology::Shader:
|
||||
case Pica::PipelineRegs::TriangleTopology::List:
|
||||
return GL_TRIANGLES;
|
||||
@ -294,9 +290,7 @@ static GLenum GetCurrentPrimitiveMode() {
|
||||
}
|
||||
|
||||
bool RasterizerOpenGL::AccelerateDrawBatchInternal(bool is_indexed) {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
GLenum primitive_mode = GetCurrentPrimitiveMode();
|
||||
|
||||
const GLenum primitive_mode = MakePrimitiveMode(regs.pipeline.triangle_topology);
|
||||
auto [vs_input_index_min, vs_input_index_max, vs_input_size] = AnalyzeVertexArray(is_indexed);
|
||||
|
||||
if (vs_input_size > VERTEX_BUFFER_SIZE) {
|
||||
@ -351,7 +345,6 @@ void RasterizerOpenGL::DrawTriangles() {
|
||||
MICROPROFILE_DEFINE(OpenGL_Drawing, "OpenGL", "Drawing", MP_RGB(128, 128, 192));
|
||||
bool RasterizerOpenGL::Draw(bool accelerate, bool is_indexed) {
|
||||
MICROPROFILE_SCOPE(OpenGL_Drawing);
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
|
||||
const bool shadow_rendering = regs.framebuffer.IsShadowRendering();
|
||||
const bool has_stencil = regs.framebuffer.HasStencil();
|
||||
@ -1020,16 +1013,14 @@ void RasterizerOpenGL::SamplerInfo::SyncWithConfig(
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SetShader() {
|
||||
shader_program_manager.UseFragmentShader(Pica::g_state.regs);
|
||||
shader_program_manager.UseFragmentShader(regs);
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncClipEnabled() {
|
||||
state.clip_distance[1] = Pica::g_state.regs.rasterizer.clip_enable != 0;
|
||||
state.clip_distance[1] = regs.rasterizer.clip_enable != 0;
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncCullMode() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
|
||||
switch (regs.rasterizer.cull_mode) {
|
||||
case Pica::RasterizerRegs::CullMode::KeepAll:
|
||||
state.cull.enabled = false;
|
||||
@ -1054,11 +1045,10 @@ void RasterizerOpenGL::SyncCullMode() {
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncBlendEnabled() {
|
||||
state.blend.enabled = (Pica::g_state.regs.framebuffer.output_merger.alphablend_enable == 1);
|
||||
state.blend.enabled = (regs.framebuffer.output_merger.alphablend_enable == 1);
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncBlendFuncs() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
state.blend.rgb_equation =
|
||||
PicaToGL::BlendEquation(regs.framebuffer.output_merger.alpha_blending.blend_equation_rgb);
|
||||
state.blend.a_equation =
|
||||
@ -1074,8 +1064,7 @@ void RasterizerOpenGL::SyncBlendFuncs() {
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncBlendColor() {
|
||||
auto blend_color =
|
||||
PicaToGL::ColorRGBA8(Pica::g_state.regs.framebuffer.output_merger.blend_const.raw);
|
||||
auto blend_color = PicaToGL::ColorRGBA8(regs.framebuffer.output_merger.blend_const.raw);
|
||||
state.blend.color.red = blend_color[0];
|
||||
state.blend.color.green = blend_color[1];
|
||||
state.blend.color.blue = blend_color[2];
|
||||
@ -1088,7 +1077,6 @@ void RasterizerOpenGL::SyncLogicOp() {
|
||||
shader_dirty = true;
|
||||
}
|
||||
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
state.logic_op = PicaToGL::LogicOp(regs.framebuffer.output_merger.logic_op);
|
||||
|
||||
if (driver.IsOpenGLES()) {
|
||||
@ -1103,7 +1091,6 @@ void RasterizerOpenGL::SyncLogicOp() {
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncColorWriteMask() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
if (driver.IsOpenGLES()) {
|
||||
if (!regs.framebuffer.output_merger.alphablend_enable) {
|
||||
if (regs.framebuffer.output_merger.logic_op == Pica::FramebufferRegs::LogicOp::NoOp) {
|
||||
@ -1128,7 +1115,6 @@ void RasterizerOpenGL::SyncColorWriteMask() {
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncStencilWriteMask() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
state.stencil.write_mask =
|
||||
(regs.framebuffer.framebuffer.allow_depth_stencil_write != 0)
|
||||
? static_cast<GLuint>(regs.framebuffer.output_merger.stencil_test.write_mask)
|
||||
@ -1136,7 +1122,6 @@ void RasterizerOpenGL::SyncStencilWriteMask() {
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncDepthWriteMask() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
state.depth.write_mask = (regs.framebuffer.framebuffer.allow_depth_stencil_write != 0 &&
|
||||
regs.framebuffer.output_merger.depth_write_enable)
|
||||
? GL_TRUE
|
||||
@ -1144,7 +1129,6 @@ void RasterizerOpenGL::SyncDepthWriteMask() {
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncStencilTest() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
state.stencil.test_enabled =
|
||||
regs.framebuffer.output_merger.stencil_test.enable &&
|
||||
regs.framebuffer.framebuffer.depth_format == Pica::FramebufferRegs::DepthFormat::D24S8;
|
||||
@ -1161,7 +1145,6 @@ void RasterizerOpenGL::SyncStencilTest() {
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncDepthTest() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
state.depth.test_enabled = regs.framebuffer.output_merger.depth_test_enable == 1 ||
|
||||
regs.framebuffer.output_merger.depth_write_enable == 1;
|
||||
state.depth.test_func =
|
||||
@ -1179,12 +1162,11 @@ void RasterizerOpenGL::SyncAndUploadLUTsLF() {
|
||||
return;
|
||||
}
|
||||
|
||||
u8* buffer;
|
||||
GLintptr offset;
|
||||
bool invalidate;
|
||||
std::size_t bytes_used = 0;
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, texture_lf_buffer.Handle());
|
||||
std::tie(buffer, offset, invalidate) = texture_lf_buffer.Map(max_size, sizeof(Common::Vec4f));
|
||||
|
||||
std::size_t bytes_used = 0;
|
||||
const auto [buffer, offset, invalidate] =
|
||||
texture_lf_buffer.Map(max_size, sizeof(Common::Vec4f));
|
||||
|
||||
// Sync the lighting luts
|
||||
if (uniform_block_data.lighting_lut_dirty_any || invalidate) {
|
||||
@ -1237,6 +1219,7 @@ void RasterizerOpenGL::SyncAndUploadLUTsLF() {
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncAndUploadLUTs() {
|
||||
const auto& proctex = Pica::g_state.proctex;
|
||||
constexpr std::size_t max_size =
|
||||
sizeof(Common::Vec2f) * 128 * 3 + // proctex: noise + color + alpha
|
||||
sizeof(Common::Vec4f) * 256 + // proctex
|
||||
@ -1249,49 +1232,48 @@ void RasterizerOpenGL::SyncAndUploadLUTs() {
|
||||
return;
|
||||
}
|
||||
|
||||
u8* buffer;
|
||||
GLintptr offset;
|
||||
bool invalidate;
|
||||
std::size_t bytes_used = 0;
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, texture_buffer.Handle());
|
||||
std::tie(buffer, offset, invalidate) = texture_buffer.Map(max_size, sizeof(Common::Vec4f));
|
||||
|
||||
std::size_t bytes_used = 0;
|
||||
const auto [buffer, offset, invalidate] = texture_buffer.Map(max_size, sizeof(Common::Vec4f));
|
||||
|
||||
// helper function for SyncProcTexNoiseLUT/ColorMap/AlphaMap
|
||||
auto SyncProcTexValueLUT = [this, buffer, offset, invalidate, &bytes_used](
|
||||
const std::array<Pica::State::ProcTex::ValueEntry, 128>& lut,
|
||||
std::array<Common::Vec2f, 128>& lut_data, GLint& lut_offset) {
|
||||
std::array<Common::Vec2f, 128> new_data;
|
||||
std::transform(lut.begin(), lut.end(), new_data.begin(), [](const auto& entry) {
|
||||
return Common::Vec2f{entry.ToFloat(), entry.DiffToFloat()};
|
||||
});
|
||||
auto SyncProcTexValueLUT =
|
||||
[this, buffer = buffer, offset = offset, invalidate = invalidate,
|
||||
&bytes_used](const std::array<Pica::State::ProcTex::ValueEntry, 128>& lut,
|
||||
std::array<Common::Vec2f, 128>& lut_data, GLint& lut_offset) {
|
||||
std::array<Common::Vec2f, 128> new_data;
|
||||
std::transform(lut.begin(), lut.end(), new_data.begin(), [](const auto& entry) {
|
||||
return Common::Vec2f{entry.ToFloat(), entry.DiffToFloat()};
|
||||
});
|
||||
|
||||
if (new_data != lut_data || invalidate) {
|
||||
lut_data = new_data;
|
||||
std::memcpy(buffer + bytes_used, new_data.data(),
|
||||
new_data.size() * sizeof(Common::Vec2f));
|
||||
lut_offset = static_cast<GLint>((offset + bytes_used) / sizeof(Common::Vec2f));
|
||||
uniform_block_data.dirty = true;
|
||||
bytes_used += new_data.size() * sizeof(Common::Vec2f);
|
||||
}
|
||||
};
|
||||
if (new_data != lut_data || invalidate) {
|
||||
lut_data = new_data;
|
||||
std::memcpy(buffer + bytes_used, new_data.data(),
|
||||
new_data.size() * sizeof(Common::Vec2f));
|
||||
lut_offset = static_cast<GLint>((offset + bytes_used) / sizeof(Common::Vec2f));
|
||||
uniform_block_data.dirty = true;
|
||||
bytes_used += new_data.size() * sizeof(Common::Vec2f);
|
||||
}
|
||||
};
|
||||
|
||||
// Sync the proctex noise lut
|
||||
if (uniform_block_data.proctex_noise_lut_dirty || invalidate) {
|
||||
SyncProcTexValueLUT(Pica::g_state.proctex.noise_table, proctex_noise_lut_data,
|
||||
SyncProcTexValueLUT(proctex.noise_table, proctex_noise_lut_data,
|
||||
uniform_block_data.data.proctex_noise_lut_offset);
|
||||
uniform_block_data.proctex_noise_lut_dirty = false;
|
||||
}
|
||||
|
||||
// Sync the proctex color map
|
||||
if (uniform_block_data.proctex_color_map_dirty || invalidate) {
|
||||
SyncProcTexValueLUT(Pica::g_state.proctex.color_map_table, proctex_color_map_data,
|
||||
SyncProcTexValueLUT(proctex.color_map_table, proctex_color_map_data,
|
||||
uniform_block_data.data.proctex_color_map_offset);
|
||||
uniform_block_data.proctex_color_map_dirty = false;
|
||||
}
|
||||
|
||||
// Sync the proctex alpha map
|
||||
if (uniform_block_data.proctex_alpha_map_dirty || invalidate) {
|
||||
SyncProcTexValueLUT(Pica::g_state.proctex.alpha_map_table, proctex_alpha_map_data,
|
||||
SyncProcTexValueLUT(proctex.alpha_map_table, proctex_alpha_map_data,
|
||||
uniform_block_data.data.proctex_alpha_map_offset);
|
||||
uniform_block_data.proctex_alpha_map_dirty = false;
|
||||
}
|
||||
@ -1300,8 +1282,7 @@ void RasterizerOpenGL::SyncAndUploadLUTs() {
|
||||
if (uniform_block_data.proctex_lut_dirty || invalidate) {
|
||||
std::array<Common::Vec4f, 256> new_data;
|
||||
|
||||
std::transform(Pica::g_state.proctex.color_table.begin(),
|
||||
Pica::g_state.proctex.color_table.end(), new_data.begin(),
|
||||
std::transform(proctex.color_table.begin(), proctex.color_table.end(), new_data.begin(),
|
||||
[](const auto& entry) {
|
||||
auto rgba = entry.ToVector() / 255.0f;
|
||||
return Common::Vec4f{rgba.r(), rgba.g(), rgba.b(), rgba.a()};
|
||||
@ -1323,9 +1304,8 @@ void RasterizerOpenGL::SyncAndUploadLUTs() {
|
||||
if (uniform_block_data.proctex_diff_lut_dirty || invalidate) {
|
||||
std::array<Common::Vec4f, 256> new_data;
|
||||
|
||||
std::transform(Pica::g_state.proctex.color_diff_table.begin(),
|
||||
Pica::g_state.proctex.color_diff_table.end(), new_data.begin(),
|
||||
[](const auto& entry) {
|
||||
std::transform(proctex.color_diff_table.begin(), proctex.color_diff_table.end(),
|
||||
new_data.begin(), [](const auto& entry) {
|
||||
auto rgba = entry.ToVector() / 255.0f;
|
||||
return Common::Vec4f{rgba.r(), rgba.g(), rgba.b(), rgba.a()};
|
||||
});
|
||||
@ -1354,20 +1334,18 @@ void RasterizerOpenGL::UploadUniforms(bool accelerate_draw) {
|
||||
bool sync_vs = accelerate_draw;
|
||||
bool sync_fs = uniform_block_data.dirty;
|
||||
|
||||
if (!sync_vs && !sync_fs)
|
||||
if (!sync_vs && !sync_fs) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::size_t uniform_size = uniform_size_aligned_vs + uniform_size_aligned_fs;
|
||||
std::size_t used_bytes = 0;
|
||||
u8* uniforms;
|
||||
GLintptr offset;
|
||||
bool invalidate;
|
||||
std::tie(uniforms, offset, invalidate) =
|
||||
const auto [uniforms, offset, invalidate] =
|
||||
uniform_buffer.Map(uniform_size, uniform_buffer_alignment);
|
||||
|
||||
if (sync_vs) {
|
||||
Pica::Shader::VSUniformData vs_uniforms;
|
||||
vs_uniforms.uniforms.SetFromRegs(Pica::g_state.regs.vs, Pica::g_state.vs);
|
||||
vs_uniforms.uniforms.SetFromRegs(regs.vs, Pica::g_state.vs);
|
||||
std::memcpy(uniforms + used_bytes, &vs_uniforms, sizeof(vs_uniforms));
|
||||
glBindBufferRange(GL_UNIFORM_BUFFER, static_cast<GLuint>(Pica::Shader::UniformBindings::VS),
|
||||
uniform_buffer.Handle(), offset + used_bytes, sizeof(vs_uniforms));
|
||||
|
@ -11,10 +11,6 @@
|
||||
#include "video_core/renderer_opengl/gl_stream_buffer.h"
|
||||
#include "video_core/renderer_opengl/gl_texture_runtime.h"
|
||||
|
||||
namespace Memory {
|
||||
class MemorySystem;
|
||||
}
|
||||
|
||||
namespace Frontend {
|
||||
class EmuWindow;
|
||||
}
|
||||
@ -138,7 +134,6 @@ private:
|
||||
bool SetupGeometryShader();
|
||||
|
||||
private:
|
||||
Memory::MemorySystem& memory;
|
||||
Driver& driver;
|
||||
OpenGLState state;
|
||||
TextureRuntime runtime;
|
||||
|
@ -66,7 +66,7 @@ RasterizerVulkan::RasterizerVulkan(Memory::MemorySystem& memory_, Frontend::EmuW
|
||||
const Instance& instance, Scheduler& scheduler,
|
||||
DescriptorManager& desc_manager, TextureRuntime& runtime,
|
||||
RenderpassCache& renderpass_cache)
|
||||
: memory{memory_}, instance{instance}, scheduler{scheduler}, runtime{runtime},
|
||||
: RasterizerAccelerated{memory_}, instance{instance}, scheduler{scheduler}, runtime{runtime},
|
||||
renderpass_cache{renderpass_cache}, desc_manager{desc_manager}, res_cache{memory, runtime},
|
||||
pipeline_cache{instance, scheduler, renderpass_cache, desc_manager},
|
||||
null_surface{NULL_PARAMS, vk::Format::eR8G8B8A8Unorm, NULL_USAGE,
|
||||
@ -187,7 +187,6 @@ void RasterizerVulkan::SetupVertexArray(u32 vs_input_size, u32 vs_input_index_mi
|
||||
* as something analogous to Vulkan bindings. The user can store attributes in separate loaders
|
||||
* or interleave them in the same loader.
|
||||
**/
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
const auto& vertex_attributes = regs.pipeline.vertex_attributes;
|
||||
PAddr base_address = vertex_attributes.GetPhysicalBaseAddress(); // GPUREG_ATTR_BUF_BASE
|
||||
|
||||
@ -280,7 +279,6 @@ void RasterizerVulkan::SetupVertexArray(u32 vs_input_size, u32 vs_input_index_mi
|
||||
}
|
||||
|
||||
void RasterizerVulkan::SetupFixedAttribs() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
const auto& vertex_attributes = regs.pipeline.vertex_attributes;
|
||||
VertexLayout& layout = pipeline_info.vertex_layout;
|
||||
|
||||
@ -343,13 +341,12 @@ void RasterizerVulkan::SetupFixedAttribs() {
|
||||
|
||||
bool RasterizerVulkan::SetupVertexShader() {
|
||||
MICROPROFILE_SCOPE(Vulkan_VS);
|
||||
return pipeline_cache.UseProgrammableVertexShader(Pica::g_state.regs, Pica::g_state.vs,
|
||||
return pipeline_cache.UseProgrammableVertexShader(regs, Pica::g_state.vs,
|
||||
pipeline_info.vertex_layout);
|
||||
}
|
||||
|
||||
bool RasterizerVulkan::SetupGeometryShader() {
|
||||
MICROPROFILE_SCOPE(Vulkan_GS);
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
|
||||
if (regs.pipeline.use_gs != Pica::PipelineRegs::UseGS::No) {
|
||||
LOG_ERROR(Render_Vulkan, "Accelerate draw doesn't support geometry shader");
|
||||
@ -360,7 +357,6 @@ bool RasterizerVulkan::SetupGeometryShader() {
|
||||
}
|
||||
|
||||
bool RasterizerVulkan::AccelerateDrawBatch(bool is_indexed) {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
if (regs.pipeline.use_gs != Pica::PipelineRegs::UseGS::No) {
|
||||
if (regs.pipeline.gs_config.mode != Pica::PipelineRegs::GSMode::Point) {
|
||||
return false;
|
||||
@ -374,8 +370,6 @@ bool RasterizerVulkan::AccelerateDrawBatch(bool is_indexed) {
|
||||
}
|
||||
|
||||
bool RasterizerVulkan::AccelerateDrawBatchInternal(bool is_indexed) {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
|
||||
const auto [vs_input_index_min, vs_input_index_max, vs_input_size] =
|
||||
AnalyzeVertexArray(is_indexed, instance.GetMinVertexStrideAlignment());
|
||||
|
||||
@ -422,8 +416,6 @@ bool RasterizerVulkan::AccelerateDrawBatchInternal(bool is_indexed) {
|
||||
}
|
||||
|
||||
void RasterizerVulkan::SetupIndexArray() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
|
||||
const bool index_u8 = regs.pipeline.index_array.format == 0;
|
||||
const bool native_u8 = index_u8 && instance.IsIndexTypeUint8Supported();
|
||||
const vk::IndexType index_type = native_u8 ? vk::IndexType::eUint8EXT : vk::IndexType::eUint16;
|
||||
@ -461,7 +453,6 @@ void RasterizerVulkan::DrawTriangles() {
|
||||
|
||||
bool RasterizerVulkan::Draw(bool accelerate, bool is_indexed) {
|
||||
MICROPROFILE_SCOPE(Vulkan_Drawing);
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
|
||||
const bool shadow_rendering = regs.framebuffer.IsShadowRendering();
|
||||
const bool has_stencil = regs.framebuffer.HasStencil();
|
||||
@ -1089,7 +1080,7 @@ vk::Sampler RasterizerVulkan::CreateSampler(const SamplerInfo& info) {
|
||||
}
|
||||
|
||||
void RasterizerVulkan::SyncClipEnabled() {
|
||||
bool clip_enabled = Pica::g_state.regs.rasterizer.clip_enable != 0;
|
||||
bool clip_enabled = regs.rasterizer.clip_enable != 0;
|
||||
if (clip_enabled != uniform_block_data.data.enable_clip1) {
|
||||
uniform_block_data.data.enable_clip1 = clip_enabled;
|
||||
uniform_block_data.dirty = true;
|
||||
@ -1097,18 +1088,14 @@ void RasterizerVulkan::SyncClipEnabled() {
|
||||
}
|
||||
|
||||
void RasterizerVulkan::SyncCullMode() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
pipeline_info.rasterization.cull_mode.Assign(regs.rasterizer.cull_mode);
|
||||
}
|
||||
|
||||
void RasterizerVulkan::SyncBlendEnabled() {
|
||||
pipeline_info.blending.blend_enable =
|
||||
Pica::g_state.regs.framebuffer.output_merger.alphablend_enable;
|
||||
pipeline_info.blending.blend_enable = regs.framebuffer.output_merger.alphablend_enable;
|
||||
}
|
||||
|
||||
void RasterizerVulkan::SyncBlendFuncs() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
|
||||
pipeline_info.blending.color_blend_eq.Assign(
|
||||
regs.framebuffer.output_merger.alpha_blending.blend_equation_rgb);
|
||||
pipeline_info.blending.alpha_blend_eq.Assign(
|
||||
@ -1124,7 +1111,6 @@ void RasterizerVulkan::SyncBlendFuncs() {
|
||||
}
|
||||
|
||||
void RasterizerVulkan::SyncBlendColor() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
pipeline_info.dynamic.blend_color = regs.framebuffer.output_merger.blend_const.raw;
|
||||
}
|
||||
|
||||
@ -1134,7 +1120,6 @@ void RasterizerVulkan::SyncLogicOp() {
|
||||
shader_dirty = true;
|
||||
}
|
||||
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
pipeline_info.blending.logic_op = regs.framebuffer.output_merger.logic_op;
|
||||
|
||||
const bool is_logic_op_emulated =
|
||||
@ -1149,7 +1134,6 @@ void RasterizerVulkan::SyncLogicOp() {
|
||||
}
|
||||
|
||||
void RasterizerVulkan::SyncColorWriteMask() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
const u32 color_mask = regs.framebuffer.framebuffer.allow_color_write != 0
|
||||
? (regs.framebuffer.output_merger.depth_color_mask >> 8) & 0xF
|
||||
: 0;
|
||||
@ -1168,7 +1152,6 @@ void RasterizerVulkan::SyncColorWriteMask() {
|
||||
}
|
||||
|
||||
void RasterizerVulkan::SyncStencilWriteMask() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
pipeline_info.dynamic.stencil_write_mask =
|
||||
(regs.framebuffer.framebuffer.allow_depth_stencil_write != 0)
|
||||
? static_cast<u32>(regs.framebuffer.output_merger.stencil_test.write_mask)
|
||||
@ -1176,16 +1159,12 @@ void RasterizerVulkan::SyncStencilWriteMask() {
|
||||
}
|
||||
|
||||
void RasterizerVulkan::SyncDepthWriteMask() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
|
||||
const bool write_enable = (regs.framebuffer.framebuffer.allow_depth_stencil_write != 0 &&
|
||||
regs.framebuffer.output_merger.depth_write_enable);
|
||||
pipeline_info.depth_stencil.depth_write_enable.Assign(write_enable);
|
||||
}
|
||||
|
||||
void RasterizerVulkan::SyncStencilTest() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
|
||||
const auto& stencil_test = regs.framebuffer.output_merger.stencil_test;
|
||||
const bool test_enable = stencil_test.enable && regs.framebuffer.framebuffer.depth_format ==
|
||||
Pica::FramebufferRegs::DepthFormat::D24S8;
|
||||
@ -1200,8 +1179,6 @@ void RasterizerVulkan::SyncStencilTest() {
|
||||
}
|
||||
|
||||
void RasterizerVulkan::SyncDepthTest() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
|
||||
const bool test_enabled = regs.framebuffer.output_merger.depth_test_enable == 1 ||
|
||||
regs.framebuffer.output_merger.depth_write_enable == 1;
|
||||
const auto compare_op = regs.framebuffer.output_merger.depth_test_enable == 1
|
||||
@ -1275,6 +1252,7 @@ void RasterizerVulkan::SyncAndUploadLUTsLF() {
|
||||
}
|
||||
|
||||
void RasterizerVulkan::SyncAndUploadLUTs() {
|
||||
const auto& proctex = Pica::g_state.proctex;
|
||||
constexpr std::size_t max_size =
|
||||
sizeof(Common::Vec2f) * 128 * 3 + // proctex: noise + color + alpha
|
||||
sizeof(Common::Vec4f) * 256 + // proctex
|
||||
@ -1292,7 +1270,7 @@ void RasterizerVulkan::SyncAndUploadLUTs() {
|
||||
|
||||
// helper function for SyncProcTexNoiseLUT/ColorMap/AlphaMap
|
||||
auto SyncProcTexValueLUT =
|
||||
[this, &buffer = buffer, &offset = offset, &invalidate = invalidate,
|
||||
[this, buffer = buffer, offset = offset, invalidate = invalidate,
|
||||
&bytes_used](const std::array<Pica::State::ProcTex::ValueEntry, 128>& lut,
|
||||
std::array<Common::Vec2f, 128>& lut_data, int& lut_offset) {
|
||||
std::array<Common::Vec2f, 128> new_data;
|
||||
@ -1312,21 +1290,21 @@ void RasterizerVulkan::SyncAndUploadLUTs() {
|
||||
|
||||
// Sync the proctex noise lut
|
||||
if (uniform_block_data.proctex_noise_lut_dirty || invalidate) {
|
||||
SyncProcTexValueLUT(Pica::g_state.proctex.noise_table, proctex_noise_lut_data,
|
||||
SyncProcTexValueLUT(proctex.noise_table, proctex_noise_lut_data,
|
||||
uniform_block_data.data.proctex_noise_lut_offset);
|
||||
uniform_block_data.proctex_noise_lut_dirty = false;
|
||||
}
|
||||
|
||||
// Sync the proctex color map
|
||||
if (uniform_block_data.proctex_color_map_dirty || invalidate) {
|
||||
SyncProcTexValueLUT(Pica::g_state.proctex.color_map_table, proctex_color_map_data,
|
||||
SyncProcTexValueLUT(proctex.color_map_table, proctex_color_map_data,
|
||||
uniform_block_data.data.proctex_color_map_offset);
|
||||
uniform_block_data.proctex_color_map_dirty = false;
|
||||
}
|
||||
|
||||
// Sync the proctex alpha map
|
||||
if (uniform_block_data.proctex_alpha_map_dirty || invalidate) {
|
||||
SyncProcTexValueLUT(Pica::g_state.proctex.alpha_map_table, proctex_alpha_map_data,
|
||||
SyncProcTexValueLUT(proctex.alpha_map_table, proctex_alpha_map_data,
|
||||
uniform_block_data.data.proctex_alpha_map_offset);
|
||||
uniform_block_data.proctex_alpha_map_dirty = false;
|
||||
}
|
||||
@ -1335,8 +1313,7 @@ void RasterizerVulkan::SyncAndUploadLUTs() {
|
||||
if (uniform_block_data.proctex_lut_dirty || invalidate) {
|
||||
std::array<Common::Vec4f, 256> new_data;
|
||||
|
||||
std::transform(Pica::g_state.proctex.color_table.begin(),
|
||||
Pica::g_state.proctex.color_table.end(), new_data.begin(),
|
||||
std::transform(proctex.color_table.begin(), proctex.color_table.end(), new_data.begin(),
|
||||
[](const auto& entry) {
|
||||
auto rgba = entry.ToVector() / 255.0f;
|
||||
return Common::Vec4f{rgba.r(), rgba.g(), rgba.b(), rgba.a()};
|
||||
@ -1358,9 +1335,8 @@ void RasterizerVulkan::SyncAndUploadLUTs() {
|
||||
if (uniform_block_data.proctex_diff_lut_dirty || invalidate) {
|
||||
std::array<Common::Vec4f, 256> new_data;
|
||||
|
||||
std::transform(Pica::g_state.proctex.color_diff_table.begin(),
|
||||
Pica::g_state.proctex.color_diff_table.end(), new_data.begin(),
|
||||
[](const auto& entry) {
|
||||
std::transform(proctex.color_diff_table.begin(), proctex.color_diff_table.end(),
|
||||
new_data.begin(), [](const auto& entry) {
|
||||
auto rgba = entry.ToVector() / 255.0f;
|
||||
return Common::Vec4f{rgba.r(), rgba.g(), rgba.b(), rgba.a()};
|
||||
});
|
||||
@ -1394,7 +1370,7 @@ void RasterizerVulkan::UploadUniforms(bool accelerate_draw) {
|
||||
u32 used_bytes = 0;
|
||||
if (sync_vs) {
|
||||
Pica::Shader::VSUniformData vs_uniforms;
|
||||
vs_uniforms.uniforms.SetFromRegs(Pica::g_state.regs.vs, Pica::g_state.vs);
|
||||
vs_uniforms.uniforms.SetFromRegs(regs.vs, Pica::g_state.vs);
|
||||
std::memcpy(uniforms + used_bytes, &vs_uniforms, sizeof(vs_uniforms));
|
||||
|
||||
pipeline_cache.BindBuffer(0, stream_buffer.Handle(), offset + used_bytes,
|
||||
|
@ -15,10 +15,6 @@ namespace Frontend {
|
||||
class EmuWindow;
|
||||
}
|
||||
|
||||
namespace Memory {
|
||||
class MemorySystem;
|
||||
}
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
struct ScreenInfo;
|
||||
@ -157,7 +153,6 @@ private:
|
||||
vk::Sampler CreateSampler(const SamplerInfo& info);
|
||||
|
||||
private:
|
||||
Memory::MemorySystem& memory;
|
||||
const Instance& instance;
|
||||
Scheduler& scheduler;
|
||||
TextureRuntime& runtime;
|
||||
|
Reference in New Issue
Block a user