mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-05 16:55:32 +01:00
Merge remote-tracking branch 'origin/staging' into feat/test-mode-no-assets
This commit is contained in:
+2
-1
@@ -78,7 +78,7 @@ void gl::glsl_common_setup()
|
||||
"#define ENVMAP_GGX_LEVELS " + std::to_string(ENVMAP_GGX_LEVELS) + "\n" +
|
||||
"#define ENVMAP_GGX_ROUGHNESS_MIN " + std::to_string(ENVMAP_GGX_ROUGHNESS_MIN) + "\n" +
|
||||
"#define ENVMAP_GGX_GROUP_SIZE " + std::to_string(ENVMAP_GGX_GROUP_SIZE) + "\n" +
|
||||
"#define SKY_SSBO_BINDING " + std::to_string(SKY_SSBO_BINDING) + "\n" +
|
||||
"#define SKY_UBO_BINDING " + std::to_string(SKY_UBO_BINDING) + "\n" +
|
||||
"#define EXPOSURE_SSBO_BINDING " + std::to_string(EXPOSURE_SSBO_BINDING) + "\n" +
|
||||
"#define EXPOSURE_HISTOGRAM_BINS " + std::to_string(EXPOSURE_HISTOGRAM_BINS) + "\n" +
|
||||
"#define EXPOSURE_HISTOGRAM_GROUP_SIZE " + std::to_string(EXPOSURE_HISTOGRAM_GROUP_SIZE) + "\n" +
|
||||
@@ -115,6 +115,7 @@ void gl::glsl_common_setup()
|
||||
"#define CAB_PROBE_MASK_TEX " + std::to_string(CAB_PROBE_MASK_TEX) + "\n" +
|
||||
"#define SKY_OCCLUSION_HEIGHT_TEX " + std::to_string(SKY_OCCLUSION_HEIGHT_TEX) + "\n" +
|
||||
"#define SKY_OCCLUSION_TEX " + std::to_string(SKY_OCCLUSION_TEX) + "\n" +
|
||||
"#define CAB_PROBE_UBO_BINDING " + std::to_string(CAB_PROBE_UBO_BINDING) + "\n" +
|
||||
"#define CAB_PROBE_SSBO_BINDING " + std::to_string(CAB_PROBE_SSBO_BINDING) + "\n" +
|
||||
"#define CAB_PROBE_SH_SIZE " + std::to_string(CAB_PROBE_SH_SIZE) + "\n" +
|
||||
"#define CAB_PROBE_SH_GROUP_SIZE " + std::to_string(CAB_PROBE_SH_GROUP_SIZE) + "\n" +
|
||||
|
||||
@@ -24,6 +24,11 @@ void gl::ssbo::bind_base() const
|
||||
glBindBuffersBase(GL_SHADER_STORAGE_BUFFER, m_index, 1, *this);
|
||||
}
|
||||
|
||||
void gl::ssbo::bind_uniform(GLuint const Index) const
|
||||
{
|
||||
glBindBuffersBase(GL_UNIFORM_BUFFER, Index, 1, *this);
|
||||
}
|
||||
|
||||
void gl::ssbo::resize(GLsizeiptr size)
|
||||
{
|
||||
if (size == m_size)
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace gl
|
||||
~ssbo();
|
||||
|
||||
void bind_base() const;
|
||||
// the same buffer as the uniform block of Index, for data a compute pass writes and the shading reads uniformly
|
||||
// (std140 and std430 lay it out alike, e.g. vec4 arrays). glBindBuffersBase, like bind_base()
|
||||
void bind_uniform(GLuint Index) const;
|
||||
void resize(GLsizeiptr size);
|
||||
GLsizeiptr size() const
|
||||
{
|
||||
|
||||
@@ -357,7 +357,7 @@ namespace gl
|
||||
// 1 if the shading takes the lights of a fragment from the list of its cluster (lights_count is not used then), 0 if not.
|
||||
// set per pass: the cluster grid exists only for the color pass of a perspective view
|
||||
uint32_t lights_clustered;
|
||||
// scale of the directional part of the sky ambient light (sky_ssbo): the factor the ambient light of the object
|
||||
// scale of the directional part of the sky ambient light (sky_ubo): the factor the ambient light of the object
|
||||
// is scaled with (tunnels), 0 where the ambient light is not the sky's (model previews)
|
||||
float sky_ambient_factor;
|
||||
// 1 if the shading reads rough reflections from the prefiltered environment map, 0 if from the mipmaps of the plain one
|
||||
@@ -466,10 +466,13 @@ namespace gl
|
||||
static_assert(offsetof(cluster_counters, index_count) == 0, "bad layout of cluster_counters");
|
||||
static_assert(offsetof(cluster_counters, overflow_count) == 4, "bad layout of cluster_counters");
|
||||
|
||||
// binding points of the sky, exposure and atmosphere buffers: layout(binding = ...) in glsl_common
|
||||
const GLuint SKY_SSBO_BINDING = 5;
|
||||
// binding points of the sky, exposure and atmosphere buffers: layout(binding = ...) in glsl_common. the sky is a uniform
|
||||
// block: 9 vec4 every fragment reads the same of, which keeps a storage buffer point free (see MAX_SSBO_BINDINGS). the
|
||||
// result of the atmosphere is written by one compute pass only, which binds it right before its dispatch, so it shares
|
||||
// a point with the other compute passes
|
||||
const GLuint SKY_UBO_BINDING = 3;
|
||||
const GLuint EXPOSURE_SSBO_BINDING = 6;
|
||||
const GLuint ATMOSPHERE_RESULT_SSBO_BINDING = 7;
|
||||
const GLuint ATMOSPHERE_RESULT_SSBO_BINDING = 9;
|
||||
const GLuint ATMOSPHERE_UBO_BINDING = 4;
|
||||
|
||||
// binding point of the per-instance modelview matrices of instanced draws (glsl: instance_ssbo, mat4 per instance).
|
||||
@@ -479,7 +482,7 @@ namespace gl
|
||||
// number of coefficients of the spherical harmonics of order 2 (bands 0..2)
|
||||
const size_t SKY_SH_COEFFICIENTS = 9;
|
||||
|
||||
// layout std430: directional part of the sky ambient light (GLSL: sky_ssbo). the coefficients of the real spherical
|
||||
// layout std140 and std430 alike: directional part of the sky ambient light (GLSL: sky_ubo). the coefficients of the real spherical
|
||||
// harmonics of the light a surface facing a world space direction gets, in units of light_data.ambient, without the
|
||||
// constant band (that one is light_data.ambient itself); rgb used, w is padding
|
||||
struct sky_data
|
||||
@@ -487,15 +490,18 @@ namespace gl
|
||||
glm::vec4 ambient_sh[SKY_SH_COEFFICIENTS];
|
||||
};
|
||||
|
||||
// layout std430: the light of the lamps the occupied cab reflects, which lights the cab again (GLSL: cab_probe_ssbo, written by
|
||||
// cabprobe_sh.comp from the probe of the cab): the coefficients of the real spherical harmonics of the light a surface facing a
|
||||
// layout std140 and std430 alike: the light of the lamps the occupied cab reflects, which lights the cab again (GLSL:
|
||||
// cab_probe_ubo, written by cabprobe_sh.comp from the probe of the cab as cab_probe_result_ssbo): the coefficients of the real spherical harmonics of the light a surface facing a
|
||||
// direction of the space of the probe gets, bands 0..2, in units of light_data.ambient; rgb used, w is padding
|
||||
struct cab_probe_data
|
||||
{
|
||||
glm::vec4 bounce_sh[SKY_SH_COEFFICIENTS];
|
||||
};
|
||||
// binding point of the opengl renderer, bound with the colour passes
|
||||
const GLuint CAB_PROBE_SSBO_BINDING = 17;
|
||||
// binding points of the opengl renderer: the shading reads the buffer as a uniform block, bound with the colour passes;
|
||||
// cabprobe_sh.comp writes it as a storage buffer, bound right before its dispatch, so it shares that point with the other
|
||||
// compute passes
|
||||
const GLuint CAB_PROBE_UBO_BINDING = 7;
|
||||
const GLuint CAB_PROBE_SSBO_BINDING = 9;
|
||||
// the face of the level of the probe the spherical harmonics are taken from, at most, and the work group of cabprobe_sh.comp
|
||||
const size_t CAB_PROBE_SH_SIZE = 16;
|
||||
// the face of the level of the probe CAB_PROBE_MASK_TEX is a copy of, at most
|
||||
@@ -743,10 +749,10 @@ namespace gl
|
||||
// the binding points of the opengl renderer: the storage of the water (read by the glasses, written by the passes), the block
|
||||
// of the step of the simulation (water_ubs) and the texture unit of the mask of the wipers the map is baked from. the storage
|
||||
// point is used by nothing else, bound with the colour passes
|
||||
const GLuint WATER_SSBO_BINDING = 16;
|
||||
const GLuint WATER_SSBO_BINDING = 5;
|
||||
// the drops and the rivulets of the cells of the glasses with rain (mat_rain_windscreen, rain_cells.comp, rain_cells.glsl): worked
|
||||
// out once a frame for every cell, so a glass only reads them. RAIN_CELLS_COUNT uvec4, as rain_cells.glsl lays them out
|
||||
const GLuint RAIN_CELLS_SSBO_BINDING = 18;
|
||||
const GLuint RAIN_CELLS_SSBO_BINDING = 7;
|
||||
const size_t RAIN_DROP_CELLS = 512;
|
||||
const size_t RAIN_RIV_CELLS = 128;
|
||||
const size_t RAIN_RIV_LAYERS = 5;
|
||||
@@ -927,5 +933,20 @@ namespace gl
|
||||
static_assert(offsetof(shadow_fit_data, bounds) == 48, "bad layout of shadow_fit_data");
|
||||
static_assert(sizeof(shadow_fit_data) == 48 + 32 * MAX_CASCADES, "bad size of shadow_fit_data");
|
||||
|
||||
// the storage buffer binding points the renderer may use: GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS of the drivers of integrated
|
||||
// Intel graphics, which is 16. a shader with a point past it doesn't compile there, and the material falls back to pink. what
|
||||
// the shading reads uniformly and is small goes into a uniform block instead (sky_ubo, cab_probe_ubo); a point a compute pass
|
||||
// binds right before its dispatch is shared by such passes
|
||||
const GLuint MAX_SSBO_BINDINGS = 16;
|
||||
static_assert(std::max({LIGHT_SSBO_BINDING, CLUSTER_AABB_SSBO_BINDING, CLUSTER_RANGE_SSBO_BINDING, CLUSTER_INDEX_SSBO_BINDING,
|
||||
CLUSTER_COUNTER_SSBO_BINDING, EXPOSURE_SSBO_BINDING, ATMOSPHERE_RESULT_SSBO_BINDING, INSTANCE_SSBO_BINDING,
|
||||
CAB_PROBE_SSBO_BINDING, WEATHER_SCRATCH_SSBO_BINDING, INSTANCE_RECORD_SSBO_BINDING, INSTANCE_JOB_SSBO_BINDING,
|
||||
INSTANCE_GROUP_SSBO_BINDING, INSTANCE_LOD_SSBO_BINDING, INSTANCE_COUNTER_SSBO_BINDING, INSTANCE_OUTPUT_SSBO_BINDING,
|
||||
INSTANCE_COMMAND_SSBO_BINDING, MODEL_DRAW_SSBO_BINDING, SHADOW_FIT_SSBO_BINDING, PARTICLE_SSBO_BINDING,
|
||||
PARTICLE_SOURCE_SSBO_BINDING, PARTICLE_OWNER_SSBO_BINDING, PARTICLE_OUTPUT_SSBO_BINDING, PARTICLE_COMMAND_SSBO_BINDING,
|
||||
TIMBER_LOCAL_SSBO_BINDING, TIMBER_RANGE_SSBO_BINDING, TIMBER_OUTPUT_SSBO_BINDING, TIMBER_ORIGIN_SSBO_BINDING,
|
||||
WATER_SSBO_BINDING, RAIN_CELLS_SSBO_BINDING}) < MAX_SSBO_BINDINGS,
|
||||
"a storage buffer binding point past what integrated Intel graphics offer");
|
||||
|
||||
#pragma pack(pop)
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ void opengl46_cab_probe::bind()
|
||||
glBindTextureUnit(gl::CAB_PROBE_ALBEDO_TEX, (m_albedo != 0) ? m_albedo : m_empty);
|
||||
glBindTextureUnit(gl::CAB_PROBE_MASK_TEX, (m_mask != 0) ? m_mask : m_empty);
|
||||
if (m_sh)
|
||||
m_sh->bind_base();
|
||||
m_sh->bind_uniform(gl::CAB_PROBE_UBO_BINDING);
|
||||
}
|
||||
|
||||
bool opengl46_cab_probe::gpu_allocate(int const Size)
|
||||
@@ -174,7 +174,8 @@ void opengl46_cab_probe::gpu_end()
|
||||
glProgramUniform2i(*m_sh_program, SH_LEVEL_LOCATION, sh_level(), sh_size());
|
||||
m_sh->bind_base();
|
||||
m_sh_program->dispatch(1);
|
||||
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
|
||||
// the shading reads it as a uniform block
|
||||
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT | GL_UNIFORM_BARRIER_BIT);
|
||||
opengl_texture::reset_unit_cache();
|
||||
m_timer.end();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ class opengl46_cab_probe : public gfx::cab_probe
|
||||
// doesn't compile) there is no probe: logged, and gfx.cabprobe switched off
|
||||
void init();
|
||||
// puts the maps (or the stand-ins) on their texture units, gl::CAB_PROBE_TEX, gl::CAB_PROBE_ALBEDO_TEX and the mask on
|
||||
// gl::CAB_PROBE_MASK_TEX, and the spherical harmonics on gl::CAB_PROBE_SSBO_BINDING. once per context and frame
|
||||
// gl::CAB_PROBE_MASK_TEX, and the spherical harmonics on the uniform block of
|
||||
// gl::CAB_PROBE_UBO_BINDING. once per context and frame
|
||||
void bind();
|
||||
// program of the probe, of the alpha tested materials when Alpha
|
||||
gl::program &program(bool const Alpha)
|
||||
|
||||
@@ -7502,6 +7502,15 @@ bool opengl46_renderer::Init_caps()
|
||||
WriteLog("shadows map size capped at " + std::to_string(m_shadowbuffersize) + "p");
|
||||
}
|
||||
|
||||
// the storage buffer binding points the shaders use (gl::MAX_SSBO_BINDINGS); with fewer, the materials don't compile
|
||||
{
|
||||
GLint ssbobindings{0};
|
||||
::glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &ssbobindings);
|
||||
WriteLog(std::format("shader storage buffer binding points: {}", ssbobindings));
|
||||
if (ssbobindings < static_cast<GLint>(gl::MAX_SSBO_BINDINGS))
|
||||
ErrorLog(std::format("the shaders need {} shader storage buffer binding points, the driver offers {}", gl::MAX_SSBO_BINDINGS, ssbobindings));
|
||||
}
|
||||
|
||||
clamp_multisampling();
|
||||
if (Global.iMultisampling)
|
||||
{
|
||||
|
||||
@@ -77,8 +77,8 @@ void opengl46_sky::init()
|
||||
Global.gfx_envmap_ggx = false;
|
||||
}
|
||||
|
||||
m_sky_ssbo = std::make_unique<gl::ssbo>(sizeof(gl::sky_data), gl::SKY_SSBO_BINDING);
|
||||
m_sky_ssbo->update(m_sky_data);
|
||||
m_sky_ubo = std::make_unique<gl::ubo>(sizeof(gl::sky_data), gl::SKY_UBO_BINDING);
|
||||
m_sky_ubo->update(m_sky_data);
|
||||
m_atmosphere_ubo = std::make_unique<gl::ubo>(sizeof(gl::atmosphere_ubs), gl::ATMOSPHERE_UBO_BINDING);
|
||||
m_atmosphere_result_ssbo = std::make_unique<gl::ssbo>(sizeof(gl::atmosphere_result), gl::ATMOSPHERE_RESULT_SSBO_BINDING);
|
||||
|
||||
@@ -92,9 +92,9 @@ void opengl46_sky::init()
|
||||
|
||||
void opengl46_sky::bind()
|
||||
{
|
||||
m_sky_ssbo->bind_base();
|
||||
m_sky_ubo->bind_uniform();
|
||||
m_atmosphere_ubo->bind_uniform();
|
||||
m_atmosphere_result_ssbo->bind_base();
|
||||
// the result of the atmosphere is bound by its pass only (update_atmosphere()): its point is shared by the compute passes
|
||||
}
|
||||
|
||||
void opengl46_sky::update_atmosphere(glm::vec3 const &Sundirection)
|
||||
@@ -159,7 +159,7 @@ void opengl46_sky::update(opengl46_light &Sunlight, glm::vec3 &Fogcolor, CSkyDom
|
||||
if (!m_sky_data_uploaded || std::memcmp(&skydata, &m_sky_data, sizeof(skydata)) != 0)
|
||||
{
|
||||
m_sky_data = skydata;
|
||||
m_sky_ssbo->update(m_sky_data);
|
||||
m_sky_ubo->update(m_sky_data);
|
||||
m_sky_data_uploaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
class CSkyDome;
|
||||
|
||||
// light of the sky for the opengl 4.6 renderer:
|
||||
// - the directional part of the ambient light, as spherical harmonics in sky_ssbo, worked out from the colours of the sky
|
||||
// - the directional part of the ambient light, as spherical harmonics in sky_ubo, worked out from the colours of the sky
|
||||
// dome or from the physical atmosphere. the shading adds it to the uniform ambient light (light_common.glsl), so the
|
||||
// average of the ambient light stays what the rest of the renderer sets
|
||||
// - the physical atmosphere (Hillaire 2020, atmosphere_*.comp): look-up tables made in compute passes, the sky drawn from
|
||||
@@ -104,7 +104,7 @@ class opengl46_sky
|
||||
static GLuint create_table(GLsizei Width, GLsizei Height);
|
||||
|
||||
// buffers the shaders read
|
||||
std::unique_ptr<gl::ssbo> m_sky_ssbo;
|
||||
std::unique_ptr<gl::ubo> m_sky_ubo;
|
||||
std::unique_ptr<gl::ubo> m_atmosphere_ubo;
|
||||
std::unique_ptr<gl::ssbo> m_atmosphere_result_ssbo;
|
||||
gl::sky_data m_sky_data{};
|
||||
|
||||
@@ -71,7 +71,7 @@ float cloud_phase(float cosangle, float scale)
|
||||
}
|
||||
|
||||
// the light of the sky a face looking straight up (Up 1) or down (-1) gets: the uniform ambient light and the directional part of
|
||||
// the sky light (sky_ssbo, light_common.glsl: sky_ambient_directional) along the vertical. with the physical atmosphere it is bluer
|
||||
// the sky light (sky_ubo, light_common.glsl: sky_ambient_directional) along the vertical. with the physical atmosphere it is bluer
|
||||
// and brighter from above than from the sides, so the shaded sides of the clouds take the colour of the sky above them
|
||||
vec3 cloud_sky_light(float up)
|
||||
{
|
||||
|
||||
@@ -61,8 +61,8 @@
|
||||
#define WATER_TRAIL 1024
|
||||
#define WATER_MAP 256
|
||||
#define WATER_GROUP_SIZE 64
|
||||
#define WATER_SSBO_BINDING 16
|
||||
#define RAIN_CELLS_SSBO_BINDING 18
|
||||
#define WATER_SSBO_BINDING 5
|
||||
#define RAIN_CELLS_SSBO_BINDING 7
|
||||
#define WATER_UBO_BINDING 6
|
||||
#define WATER_MASK_TEX 25
|
||||
#define WATER_LAYER_TEXELS 2097152
|
||||
@@ -87,12 +87,12 @@
|
||||
#define ENVMAP_GGX_LEVELS 7
|
||||
#define ENVMAP_GGX_ROUGHNESS_MIN 0.200000
|
||||
#define ENVMAP_GGX_GROUP_SIZE 8
|
||||
#define SKY_SSBO_BINDING 5
|
||||
#define SKY_UBO_BINDING 3
|
||||
#define EXPOSURE_SSBO_BINDING 6
|
||||
#define EXPOSURE_HISTOGRAM_BINS 256
|
||||
#define EXPOSURE_HISTOGRAM_GROUP_SIZE 16
|
||||
#define ATMOSPHERE_UBO_BINDING 4
|
||||
#define ATMOSPHERE_RESULT_SSBO_BINDING 7
|
||||
#define ATMOSPHERE_RESULT_SSBO_BINDING 9
|
||||
#define ATMOSPHERE_TRANSMITTANCE_WIDTH 256
|
||||
#define ATMOSPHERE_TRANSMITTANCE_HEIGHT 64
|
||||
#define ATMOSPHERE_MULTISCATTERING_SIZE 32
|
||||
@@ -123,7 +123,8 @@
|
||||
#define SKY_OCCLUSION_HEIGHT_TEX 29
|
||||
#define SKY_OCCLUSION_TEX 30
|
||||
#define CAB_PROBE_MASK_TEX 31
|
||||
#define CAB_PROBE_SSBO_BINDING 17
|
||||
#define CAB_PROBE_UBO_BINDING 7
|
||||
#define CAB_PROBE_SSBO_BINDING 9
|
||||
#define CAB_PROBE_SH_SIZE 16
|
||||
#define CAB_PROBE_SH_GROUP_SIZE 64
|
||||
#define WEATHER_UBO_BINDING 5
|
||||
@@ -197,7 +198,7 @@ layout(std430, binding = LIGHT_SSBO_BINDING) readonly buffer light_ssbo
|
||||
uint lights_count;
|
||||
// 1 if the shading takes the lights from the list of the cluster of a fragment, see cluster_ubo
|
||||
uint lights_clustered;
|
||||
// scale of the directional part of the sky ambient light, see sky_ssbo
|
||||
// scale of the directional part of the sky ambient light, see sky_ubo
|
||||
float sky_ambient_factor;
|
||||
// 1 if rough reflections come from the prefiltered environment map
|
||||
uint env_ggx;
|
||||
@@ -207,7 +208,7 @@ layout(std430, binding = LIGHT_SSBO_BINDING) readonly buffer light_ssbo
|
||||
|
||||
// directional part of the sky ambient light: real spherical harmonics (bands 1 and 2, band 0 is ambient) of the light
|
||||
// a surface facing a world space direction gets, in units of ambient. see gl::sky_data
|
||||
layout(std430, binding = SKY_SSBO_BINDING) readonly buffer sky_ssbo
|
||||
layout(std140, binding = SKY_UBO_BINDING) uniform sky_ubo
|
||||
{
|
||||
vec4 sky_ambient_sh[9];
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@ layout(binding = SCENE_AO_TEX) uniform sampler2D scene_ao;
|
||||
// itself with again (gl::cab_probe_data)
|
||||
layout(binding = CAB_PROBE_TEX) uniform samplerCube cab_probe_light;
|
||||
layout(binding = CAB_PROBE_ALBEDO_TEX) uniform samplerCube cab_probe_albedo;
|
||||
layout(std430, binding = CAB_PROBE_SSBO_BINDING) readonly buffer cab_probe_ssbo
|
||||
layout(std140, binding = CAB_PROBE_UBO_BINDING) uniform cab_probe_ubo
|
||||
{
|
||||
vec4 cab_probe_sh[9];
|
||||
};
|
||||
@@ -725,7 +725,7 @@ vec3 material_diffuse()
|
||||
return (value > 0.0 ? diffusecolor * (param[1].x / value) : vec3(0.0));
|
||||
}
|
||||
|
||||
// directional part of the sky ambient light (sky_ssbo, bands 1 and 2 of the spherical harmonics) for a world space direction
|
||||
// directional part of the sky ambient light (sky_ubo, bands 1 and 2 of the spherical harmonics) for a world space direction
|
||||
vec3 sky_ambient_directional(vec3 n)
|
||||
{
|
||||
return sky_ambient_sh[1].rgb * (0.488603 * n.y)
|
||||
|
||||
Reference in New Issue
Block a user