Skip to content

Commit

Permalink
pica: Replace register notifies with state sync
Browse files Browse the repository at this point in the history
* It's cheaper to do it at draw time instead
  • Loading branch information
raphaelthegreat committed Jul 20, 2024
1 parent 518f723 commit 4a0ee9d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/video_core/debug_utils/debug_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,10 @@ void StartPicaTracing() {
}

void OnPicaRegWrite(u16 cmd_id, u16 mask, u32 value) {
std::lock_guard lock(pica_trace_mutex);

if (!g_is_pica_tracing)
return;

std::lock_guard lock(pica_trace_mutex);
pica_trace->writes.push_back(PicaTrace::Write{cmd_id, mask, value});
}

Expand Down
3 changes: 2 additions & 1 deletion src/video_core/pica/pica_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ void PicaCore::WriteInternalReg(u32 id, u32 value, u32 mask) {

lighting.luts[lut_config.type][lut_config.index].raw = value;
lut_config.index.Assign(lut_config.index + 1);
rasterizer->MarkLightLutDirty();
break;
}

Expand Down Expand Up @@ -413,7 +414,7 @@ void PicaCore::WriteInternalReg(u32 id, u32 value, u32 mask) {
}

// Notify the rasterizer an internal register was updated.
rasterizer->NotifyPicaRegisterChanged(id);
//rasterizer->NotifyPicaRegisterChanged(id);
}

void PicaCore::SubmitImmediate(u32 value) {
Expand Down
1 change: 1 addition & 0 deletions src/video_core/rasterizer_accelerated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ void RasterizerAccelerated::SyncEntireState() {
SyncLightPosition(light_index);
SyncLightDistanceAttenuationBias(light_index);
SyncLightDistanceAttenuationScale(light_index);
SyncLightSpotDirection(light_index);
}

SyncFogColor();
Expand Down
6 changes: 6 additions & 0 deletions src/video_core/rasterizer_accelerated.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ class RasterizerAccelerated : public RasterizerInterface {
void AddTriangle(const Pica::OutputVertex& v0, const Pica::OutputVertex& v1,
const Pica::OutputVertex& v2) override;

void MarkLightLutDirty() override {
const auto& lut_config = regs.lighting.lut_config;
fs_uniform_block_data.lighting_lut_dirty[lut_config.type] = true;
fs_uniform_block_data.lighting_lut_dirty_any = true;
}

void NotifyPicaRegisterChanged(u32 id) override;

void SyncEntireState() override;
Expand Down
2 changes: 2 additions & 0 deletions src/video_core/rasterizer_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,7 @@ class RasterizerInterface {
[[maybe_unused]] const DiskResourceLoadCallback& callback) {}

virtual void SyncEntireState() {}

virtual void MarkLightLutDirty() {}
};
} // namespace VideoCore
3 changes: 3 additions & 0 deletions src/video_core/renderer_opengl/gl_rasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ void RasterizerOpenGL::DrawTriangles() {
bool RasterizerOpenGL::Draw(bool accelerate, bool is_indexed) {
MICROPROFILE_SCOPE(OpenGL_Drawing);

shader_dirty = true;
SyncEntireState();

const bool shadow_rendering = regs.framebuffer.IsShadowRendering();
const bool has_stencil = regs.framebuffer.HasStencil();

Expand Down
3 changes: 3 additions & 0 deletions src/video_core/renderer_vulkan/vk_rasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ void RasterizerVulkan::DrawTriangles() {
bool RasterizerVulkan::Draw(bool accelerate, bool is_indexed) {
MICROPROFILE_SCOPE(Vulkan_Drawing);

shader_dirty = true;
SyncEntireState();

const bool shadow_rendering = regs.framebuffer.IsShadowRendering();
const bool has_stencil = regs.framebuffer.HasStencil();

Expand Down

0 comments on commit 4a0ee9d

Please sign in to comment.