18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-24 16:39:13 +01:00

Vulkan: parity with GL (P1–P7), shared GPU culling records (N6c), threaded command recording and render thread (M1, M4)

This commit is contained in:
2026-10-25 03:06:01 +01:00
parent 49f9df7d98
commit c48c58776a
146 changed files with 20748 additions and 4606 deletions

View File

@@ -19,34 +19,14 @@ http://mozilla.org/MPL/2.0/.
#include "gl/shader.h"
#include "gl/query.h"
#include "gl/readback.h"
#include "rendering/common/shadowfit.h"
// the cascades of the sun shadows fitted to the depth of the main view (sample distribution shadow maps, gfx.shadow.sdsm).
// at the end of the colour pass of the main view two compute passes go over its resolved depth: the nearest and the farthest
// distance of the pixels which aren't the sky (shadow_fit_depth.comp), then the distances split between the cascades and,
// for each cascade, the box of the pixels it takes in the space of the light (shadow_fit_bounds.comp). the result comes back
// to the cpu a frame or two later without waiting (gl::readback), with the camera and the light it was measured with, and
// the renderer makes the cascades of the frame cover the boxes (opengl46_renderer::Shadow_Fit()) instead of the whole slices
// of the view between the fixed distances of shadowtune
class opengl46_shadow_fit
// the cascades of the sun shadows fitted to the depth of the main view (gfx.shadow.sdsm): the passes and the buffers of
// gfx::shadow_fit, which tells what they do. the result comes back to the cpu a frame or two later without waiting
// (gl::readback), and opengl46_renderer::Shadow_Fit() fits the cascades of the frame to it
class opengl46_shadow_fit : public gfx::shadow_fit
{
public:
// the view and the light a measurement was made with
struct view
{
glm::dvec3 camera; // position of the camera
glm::mat4 projection; // projection of the view
glm::mat3 rotation; // world to view space, rotation only
glm::mat3 light; // world to the space of the light, rotation only
float range{0.f}; // the farthest distance the cascades may reach
};
// a measurement which came back
struct result
{
gl::shadow_fit_data data;
view source;
unsigned int frame{0}; // frame of the renderer it was made in
};
opengl46_shadow_fit() = default;
~opengl46_shadow_fit();
opengl46_shadow_fit(const opengl46_shadow_fit &) = delete;
@@ -63,30 +43,15 @@ class opengl46_shadow_fit
// the time of the passes, for the debug panel
std::string info_times();
// the ends of the bounds, as the passes store them (shadow_fit_order() in shadow_fit_bounds.comp)
static float unorder(std::uint32_t const Value);
private:
// the texture the depth is resolved to when there is no resolved depth to measure
void allocate(int const Width, int const Height);
void release();
// a measurement on its way back, kept by its number
struct pending
{
std::uint32_t measurement{0}; // 0: none
view source;
unsigned int frame{0};
};
static constexpr std::size_t PENDING = 8; // more than the copies gl::readback keeps in flight
std::unique_ptr<gl::program> m_depthprogram;
std::unique_ptr<gl::program> m_boundsprogram;
std::unique_ptr<gl::ssbo> m_buffer;
std::unique_ptr<gl::readback> m_readback;
std::array<pending, PENDING> m_pending;
std::uint32_t m_measurement{0}; // number of the last measurement
std::optional<result> m_latest;
GLuint m_depth{0};
GLuint m_depthfb{0};
glm::ivec2 m_depthsize{0};