mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-02 16:19:13 +01:00
Remove OpenGL ES / ANGLE render path
This commit is contained in:
@@ -1209,27 +1209,6 @@ int eu07_application::init_glfw()
|
|||||||
m_glfwversion = glfw_major * 10000 + glfw_minor * 100 + glfw_minor;
|
m_glfwversion = glfw_major * 10000 + glfw_minor * 100 + glfw_minor;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GLFW_ANGLE_PLATFORM_TYPE
|
|
||||||
if (m_glfwversion >= 30400)
|
|
||||||
{
|
|
||||||
int platform = GLFW_ANGLE_PLATFORM_TYPE_NONE;
|
|
||||||
if (Global.gfx_angleplatform == "opengl")
|
|
||||||
platform = GLFW_ANGLE_PLATFORM_TYPE_OPENGL;
|
|
||||||
else if (Global.gfx_angleplatform == "opengles")
|
|
||||||
platform = GLFW_ANGLE_PLATFORM_TYPE_OPENGLES;
|
|
||||||
else if (Global.gfx_angleplatform == "d3d9")
|
|
||||||
platform = GLFW_ANGLE_PLATFORM_TYPE_D3D9;
|
|
||||||
else if (Global.gfx_angleplatform == "d3d11")
|
|
||||||
platform = GLFW_ANGLE_PLATFORM_TYPE_D3D11;
|
|
||||||
else if (Global.gfx_angleplatform == "vulkan")
|
|
||||||
platform = GLFW_ANGLE_PLATFORM_TYPE_VULKAN;
|
|
||||||
else if (Global.gfx_angleplatform == "metal")
|
|
||||||
platform = GLFW_ANGLE_PLATFORM_TYPE_METAL;
|
|
||||||
|
|
||||||
glfwInitHint(GLFW_ANGLE_PLATFORM_TYPE, platform);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (glfwInit() == GLFW_FALSE)
|
if (glfwInit() == GLFW_FALSE)
|
||||||
{
|
{
|
||||||
ErrorLog("Bad init: failed to initialize glfw");
|
ErrorLog("Bad init: failed to initialize glfw");
|
||||||
@@ -1266,23 +1245,10 @@ int eu07_application::init_glfw()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// activate core profile for opengl 3.3 renderer
|
// activate core profile for opengl 3.3 renderer
|
||||||
if (!Global.gfx_usegles)
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
{
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#ifdef GLFW_CONTEXT_CREATION_API
|
|
||||||
if (m_glfwversion >= 30200)
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
|
|
||||||
#endif
|
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Global.gfx_gldebug)
|
if (Global.gfx_gldebug)
|
||||||
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
|
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
|
||||||
@@ -1347,21 +1313,10 @@ void eu07_application::init_callbacks()
|
|||||||
|
|
||||||
int eu07_application::init_ogl()
|
int eu07_application::init_ogl()
|
||||||
{
|
{
|
||||||
if (!Global.gfx_usegles)
|
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
|
||||||
{
|
{
|
||||||
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
|
ErrorLog("Bad init: failed to initialize glad");
|
||||||
{
|
return -1;
|
||||||
ErrorLog("Bad init: failed to initialize glad");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!gladLoadGLES2Loader((GLADloadproc)glfwGetProcAddress))
|
|
||||||
{
|
|
||||||
ErrorLog("Bad init: failed to initialize glad");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ struct _global
|
|||||||
bool gfx_skippipeline;
|
bool gfx_skippipeline;
|
||||||
bool gfx_extraeffects;
|
bool gfx_extraeffects;
|
||||||
bool gfx_shadergamma;
|
bool gfx_shadergamma;
|
||||||
bool gfx_usegles;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern _global Global;
|
extern _global Global;
|
||||||
|
|||||||
@@ -70,13 +70,6 @@ bool check_shader_confs(std::string filename)
|
|||||||
bool suc = true;
|
bool suc = true;
|
||||||
|
|
||||||
std::cout << "desktop GL: " << std::flush;
|
std::cout << "desktop GL: " << std::flush;
|
||||||
Global.gfx_usegles = false;
|
|
||||||
if (!check_shader_allopts(filename))
|
|
||||||
suc = false;
|
|
||||||
|
|
||||||
std::cout << "; GLES: " << std::flush;
|
|
||||||
GLAD_GL_ES_VERSION_3_1 = 1;
|
|
||||||
Global.gfx_usegles = true;
|
|
||||||
if (!check_shader_allopts(filename))
|
if (!check_shader_allopts(filename))
|
||||||
suc = false;
|
suc = false;
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,7 @@ std::optional<int64_t> gl::query::result()
|
|||||||
glGetQueryObjectuiv(*this, GL_QUERY_RESULT_AVAILABLE, &ready);
|
glGetQueryObjectuiv(*this, GL_QUERY_RESULT_AVAILABLE, &ready);
|
||||||
int64_t value = 0;
|
int64_t value = 0;
|
||||||
if (ready) {
|
if (ready) {
|
||||||
if (!Global.gfx_usegles)
|
glGetQueryObjecti64v(*this, GL_QUERY_RESULT, &value);
|
||||||
glGetQueryObjecti64v(*this, GL_QUERY_RESULT, &value);
|
|
||||||
else
|
|
||||||
glGetQueryObjectuiv(*this, GL_QUERY_RESULT, reinterpret_cast<GLuint*>(&value));
|
|
||||||
|
|
||||||
return std::optional<int64_t>(value);
|
return std::optional<int64_t>(value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,45 +127,21 @@ std::pair<GLuint, std::string> gl::shader::process_source(const std::string &fil
|
|||||||
else
|
else
|
||||||
throw shader_exception("unknown shader " + filename);
|
throw shader_exception("unknown shader " + filename);
|
||||||
|
|
||||||
if (!Global.gfx_usegles)
|
str += "#version 330 core\n";
|
||||||
{
|
// textureGather() on sampler2DArrayShadow is core in GLSL 4.0. On 3.30
|
||||||
str += "#version 330 core\n";
|
// desktop it requires GL_ARB_gpu_shader5 -- the older
|
||||||
// textureGather() on sampler2DArrayShadow is core in GLSL 4.0. On 3.30
|
// GL_ARB_texture_gather (2010) only adds the non-shadow and the plain
|
||||||
// desktop it requires GL_ARB_gpu_shader5 -- the older
|
// sampler2DShadow overloads, NOT the sampler2DArrayShadow one we need
|
||||||
// GL_ARB_texture_gather (2010) only adds the non-shadow and the plain
|
// for cascaded shadow PCF. Some drivers advertise texture_gather but
|
||||||
// sampler2DShadow overloads, NOT the sampler2DArrayShadow one we need
|
// reject the shadow-array overload because the spec for it lives in
|
||||||
// for cascaded shadow PCF. Some drivers advertise texture_gather but
|
// gpu_shader5; so emit only when gpu_shader5 is advertised. When the
|
||||||
// reject the shadow-array overload because the spec for it lives in
|
// extension is missing, calc_shadow() in light_common.glsl falls back
|
||||||
// gpu_shader5; so emit only when gpu_shader5 is advertised. When the
|
// to the original 16-tap hardware-PCF loop via #ifndef.
|
||||||
// extension is missing, calc_shadow() in light_common.glsl falls back
|
// (Project's glad config doesn't generate GLAD_GL_ARB_gpu_shader5,
|
||||||
// to the original 16-tap hardware-PCF loop via #ifndef.
|
// so we query the live extension list -- see has_gl_extension above.)
|
||||||
// (Project's glad config doesn't generate GLAD_GL_ARB_gpu_shader5,
|
static bool const have_gpu_shader5 = has_gl_extension("GL_ARB_gpu_shader5");
|
||||||
// so we query the live extension list -- see has_gl_extension above.)
|
if (have_gpu_shader5)
|
||||||
static bool const have_gpu_shader5 = has_gl_extension("GL_ARB_gpu_shader5");
|
str += "#extension GL_ARB_gpu_shader5 : enable\n";
|
||||||
if (have_gpu_shader5)
|
|
||||||
str += "#extension GL_ARB_gpu_shader5 : enable\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (GLAD_GL_ES_VERSION_3_1) {
|
|
||||||
str += "#version 310 es\n";
|
|
||||||
// GLES 3.1 lacks textureGather on shadow samplers in core; the
|
|
||||||
// EXT_gpu_shader5 extension adds it. Only emit the directive when
|
|
||||||
// the driver advertises support (see desktop comment above).
|
|
||||||
// (Glad config doesn't generate GLAD_GL_EXT_gpu_shader5 -- query
|
|
||||||
// the live extension string the same way.)
|
|
||||||
if (static bool const have_gpu_shader5 = has_gl_extension("GL_EXT_gpu_shader5"); have_gpu_shader5)
|
|
||||||
str += "#extension GL_EXT_gpu_shader5 : enable\n";
|
|
||||||
if (type == GL_GEOMETRY_SHADER)
|
|
||||||
str += "#extension GL_EXT_geometry_shader : require\n";
|
|
||||||
} else {
|
|
||||||
str += "#version 300 es\n";
|
|
||||||
}
|
|
||||||
str += "precision highp float;\n";
|
|
||||||
str += "precision highp int;\n";
|
|
||||||
str += "precision highp sampler2DShadow;\n";
|
|
||||||
str += "precision highp sampler2DArrayShadow;\n";
|
|
||||||
}
|
|
||||||
// expose the shader stage to glsl_common so vertex-only built-ins
|
// expose the shader stage to glsl_common so vertex-only built-ins
|
||||||
// (gl_InstanceID, effective_modelview, etc.) can be guarded out of
|
// (gl_InstanceID, effective_modelview, etc.) can be guarded out of
|
||||||
// fragment/geometry compilations.
|
// fragment/geometry compilations.
|
||||||
|
|||||||
@@ -533,7 +533,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
|
|
||||||
// Backup GL state
|
// Backup GL state
|
||||||
GLboolean last_enable_srgb = GL_FALSE;
|
GLboolean last_enable_srgb = GL_FALSE;
|
||||||
if (!Global.gfx_usegles && !Global.gfx_shadergamma)
|
if (!Global.gfx_shadergamma)
|
||||||
{
|
{
|
||||||
last_enable_srgb = glIsEnabled(GL_FRAMEBUFFER_SRGB);
|
last_enable_srgb = glIsEnabled(GL_FRAMEBUFFER_SRGB);
|
||||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||||
@@ -702,7 +702,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
|
|
||||||
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
|
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
|
||||||
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
||||||
if (!Global.gfx_usegles && !Global.gfx_shadergamma)
|
if (!Global.gfx_shadergamma)
|
||||||
{
|
{
|
||||||
if (last_enable_srgb) glEnable(GL_FRAMEBUFFER_SRGB); else glDisable(GL_FRAMEBUFFER_SRGB);
|
if (last_enable_srgb) glEnable(GL_FRAMEBUFFER_SRGB); else glDisable(GL_FRAMEBUFFER_SRGB);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,122 +242,6 @@ texture_manager::texture_manager() {
|
|||||||
m_textures.emplace_back( new opengl_texture(), std::chrono::steady_clock::time_point() );
|
m_textures.emplace_back( new opengl_texture(), std::chrono::steady_clock::time_point() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert image to format suitable for given internalformat
|
|
||||||
// required for GLES, on desktop GL it will be done by driver
|
|
||||||
void opengl_texture::gles_match_internalformat(GLuint internalformat)
|
|
||||||
{
|
|
||||||
// ignore compressed formats (and hope that GLES driver will support it)
|
|
||||||
if (precompressed_formats.find(internalformat) != precompressed_formats.end())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// don't care about sRGB here
|
|
||||||
if (internalformat == GL_SRGB8)
|
|
||||||
internalformat = GL_RGB8;
|
|
||||||
if (internalformat == GL_SRGB8_ALPHA8)
|
|
||||||
internalformat = GL_RGBA8;
|
|
||||||
|
|
||||||
// we don't want BGR(A), reverse it
|
|
||||||
if (data_format == GL_BGR)
|
|
||||||
{
|
|
||||||
std::vector<unsigned char> reverse;
|
|
||||||
reverse.resize(data.size());
|
|
||||||
|
|
||||||
for (int y = 0; y < data_height; y++)
|
|
||||||
for (int x = 0; x < data_width; x++)
|
|
||||||
{
|
|
||||||
int offset = (y * data_width + x) * 3;
|
|
||||||
reverse[offset + 0] = data[offset + 2];
|
|
||||||
reverse[offset + 1] = data[offset + 1];
|
|
||||||
reverse[offset + 2] = data[offset + 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
data_format = GL_RGB;
|
|
||||||
data = reverse;
|
|
||||||
}
|
|
||||||
else if (data_format == GL_BGRA)
|
|
||||||
{
|
|
||||||
std::vector<unsigned char> reverse;
|
|
||||||
reverse.resize(data.size());
|
|
||||||
|
|
||||||
for (int y = 0; y < data_height; y++)
|
|
||||||
for (int x = 0; x < data_width; x++)
|
|
||||||
{
|
|
||||||
int offset = (y * data_width + x) * 4;
|
|
||||||
reverse[offset + 0] = data[offset + 2];
|
|
||||||
reverse[offset + 1] = data[offset + 1];
|
|
||||||
reverse[offset + 2] = data[offset + 0];
|
|
||||||
reverse[offset + 3] = data[offset + 3];
|
|
||||||
}
|
|
||||||
|
|
||||||
data_format = GL_RGBA;
|
|
||||||
data = reverse;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if format matches, we're done
|
|
||||||
if (data_format == GL_RGBA && internalformat == GL_RGBA8)
|
|
||||||
return;
|
|
||||||
if (data_format == GL_RGB && internalformat == GL_RGB8)
|
|
||||||
return;
|
|
||||||
if (data_format == GL_RG && internalformat == GL_RG8)
|
|
||||||
return;
|
|
||||||
if (data_format == GL_RED && internalformat == GL_R8)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// do conversion
|
|
||||||
|
|
||||||
int in_c = 0;
|
|
||||||
if (data_format == GL_RGBA)
|
|
||||||
in_c = 4;
|
|
||||||
else if (data_format == GL_RGB)
|
|
||||||
in_c = 3;
|
|
||||||
else if (data_format == GL_RG)
|
|
||||||
in_c = 2;
|
|
||||||
else if (data_format == GL_RED)
|
|
||||||
in_c = 1;
|
|
||||||
|
|
||||||
int out_c = 0;
|
|
||||||
if (internalformat == GL_RGBA8)
|
|
||||||
out_c = 4;
|
|
||||||
else if (internalformat == GL_RGB8)
|
|
||||||
out_c = 3;
|
|
||||||
else if (internalformat == GL_RG8)
|
|
||||||
out_c = 2;
|
|
||||||
else if (internalformat == GL_R8)
|
|
||||||
out_c = 1;
|
|
||||||
|
|
||||||
if (!in_c || !out_c)
|
|
||||||
return; // conversion not supported
|
|
||||||
|
|
||||||
std::vector<unsigned char> out;
|
|
||||||
out.resize(data_width * data_height * out_c);
|
|
||||||
|
|
||||||
for (int y = 0; y < data_height; y++)
|
|
||||||
for (int x = 0; x < data_width; x++)
|
|
||||||
{
|
|
||||||
int pixel = y * data_width + x;
|
|
||||||
int in_off = pixel * in_c;
|
|
||||||
int out_off = pixel * out_c;
|
|
||||||
for (int i = 0; i < out_c; i++)
|
|
||||||
{
|
|
||||||
if (i < in_c)
|
|
||||||
out[out_off + i] = data[in_off + i];
|
|
||||||
else
|
|
||||||
out[out_off + i] = 0xFF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (out_c == 4)
|
|
||||||
data_format = GL_RGBA;
|
|
||||||
else if (out_c == 3)
|
|
||||||
data_format = GL_RGB;
|
|
||||||
else if (out_c == 2)
|
|
||||||
data_format = GL_RG;
|
|
||||||
else if (out_c == 1)
|
|
||||||
data_format = GL_RED;
|
|
||||||
|
|
||||||
data = out;
|
|
||||||
}
|
|
||||||
|
|
||||||
// loads texture data from specified file
|
// loads texture data from specified file
|
||||||
// TODO: wrap it in a workitem class, for the job system deferred loading
|
// TODO: wrap it in a workitem class, for the job system deferred loading
|
||||||
void
|
void
|
||||||
@@ -1136,27 +1020,14 @@ opengl_texture::create( bool const Static ) {
|
|||||||
glTexParameteri( target, GL_TEXTURE_WRAP_S, wrap_mode_s );
|
glTexParameteri( target, GL_TEXTURE_WRAP_S, wrap_mode_s );
|
||||||
glTexParameteri( target, GL_TEXTURE_WRAP_T, wrap_mode_t );
|
glTexParameteri( target, GL_TEXTURE_WRAP_T, wrap_mode_t );
|
||||||
|
|
||||||
if (Global.gfx_usegles)
|
if( target == GL_TEXTURE_2D )
|
||||||
{
|
glTexImage2D( target, 0, data_format, data_width, data_height, 0, data_components, GL_UNSIGNED_SHORT, nullptr );
|
||||||
if( target == GL_TEXTURE_2D )
|
else if( target == GL_TEXTURE_2D_MULTISAMPLE )
|
||||||
glTexStorage2D(target, std::countr_zero(static_cast<unsigned int>(std::max(data_width, data_height))) + 1, data_format, data_width, data_height);
|
glTexImage2DMultisample( target, samples, data_format, data_width, data_height, GL_FALSE );
|
||||||
else if( target == GL_TEXTURE_2D_MULTISAMPLE )
|
else if( target == GL_TEXTURE_2D_ARRAY )
|
||||||
glTexStorage2DMultisample( target, samples, data_format, data_width, data_height, GL_FALSE );
|
glTexImage3D( target, 0, data_format, data_width, data_height, layers, 0, data_components, GL_UNSIGNED_SHORT, nullptr );
|
||||||
else if( target == GL_TEXTURE_2D_ARRAY )
|
else if( target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY )
|
||||||
glTexStorage3D(target, std::countr_zero(static_cast<unsigned int>(std::max(data_width, data_height))) + 1, data_format, data_width, data_height, layers);
|
glTexImage3DMultisample( target, samples, data_format, data_width, data_height, layers, GL_FALSE );
|
||||||
else if( target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY )
|
|
||||||
glTexStorage3DMultisample( target, samples, data_format, data_width, data_height, layers, GL_FALSE );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if( target == GL_TEXTURE_2D )
|
|
||||||
glTexImage2D( target, 0, data_format, data_width, data_height, 0, data_components, GL_UNSIGNED_SHORT, nullptr );
|
|
||||||
else if( target == GL_TEXTURE_2D_MULTISAMPLE )
|
|
||||||
glTexImage2DMultisample( target, samples, data_format, data_width, data_height, GL_FALSE );
|
|
||||||
else if( target == GL_TEXTURE_2D_ARRAY )
|
|
||||||
glTexImage3D( target, 0, data_format, data_width, data_height, layers, 0, data_components, GL_UNSIGNED_SHORT, nullptr );
|
|
||||||
else if( target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY )
|
|
||||||
glTexImage3DMultisample( target, samples, data_format, data_width, data_height, layers, GL_FALSE );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1180,15 +1051,6 @@ opengl_texture::create( bool const Static ) {
|
|||||||
|
|
||||||
GLint internal_format = mapping[components][components_hint];
|
GLint internal_format = mapping[components][components_hint];
|
||||||
|
|
||||||
if (Global.gfx_usegles)
|
|
||||||
{
|
|
||||||
// GLES cannot generate mipmaps on SRGB8
|
|
||||||
if (internal_format == GL_SRGB8)
|
|
||||||
internal_format = GL_SRGB8_ALPHA8;
|
|
||||||
|
|
||||||
gles_match_internalformat(internal_format);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto blocksize_it = precompressed_formats.find(internal_format);
|
auto blocksize_it = precompressed_formats.find(internal_format);
|
||||||
|
|
||||||
if ( data_mapcount == 1 && !glGenerateMipmap ) {
|
if ( data_mapcount == 1 && !glGenerateMipmap ) {
|
||||||
@@ -1334,9 +1196,6 @@ opengl_texture::alloc_rendertarget( GLint format, GLint components, int width, i
|
|||||||
wrap_mode_s = wrap;
|
wrap_mode_s = wrap;
|
||||||
wrap_mode_t = wrap;
|
wrap_mode_t = wrap;
|
||||||
samples = s;
|
samples = s;
|
||||||
if( Global.gfx_usegles && !glTexStorage2DMultisample ) {
|
|
||||||
samples = 1;
|
|
||||||
}
|
|
||||||
layers = l;
|
layers = l;
|
||||||
if( layers > 1 ) {
|
if( layers > 1 ) {
|
||||||
target = samples > 1 ? GL_TEXTURE_2D_MULTISAMPLE_ARRAY : GL_TEXTURE_2D_ARRAY;
|
target = samples > 1 ? GL_TEXTURE_2D_MULTISAMPLE_ARRAY : GL_TEXTURE_2D_ARRAY;
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ public:
|
|||||||
void set_filtering() const;
|
void set_filtering() const;
|
||||||
void downsize( GLuint const Format );
|
void downsize( GLuint const Format );
|
||||||
void flip_vertical();
|
void flip_vertical();
|
||||||
void gles_match_internalformat(GLuint format);
|
|
||||||
|
|
||||||
// takes over the data read by a worker thread, waiting for it if needed
|
// takes over the data read by a worker thread, waiting for it if needed
|
||||||
void complete_data();
|
void complete_data();
|
||||||
|
|||||||
@@ -307,7 +307,6 @@ int generate_nodebank_previews(int Argc, char *Argv[])
|
|||||||
// the full renderer, drawing offscreen
|
// the full renderer, drawing offscreen
|
||||||
Global.GfxRenderer = "default";
|
Global.GfxRenderer = "default";
|
||||||
Global.NvRenderer = false;
|
Global.NvRenderer = false;
|
||||||
Global.gfx_usegles = false;
|
|
||||||
Global.gfx_skippipeline = false;
|
Global.gfx_skippipeline = false;
|
||||||
Global.gfx_postfx_motionblur_enabled = false;
|
Global.gfx_postfx_motionblur_enabled = false;
|
||||||
Global.gfx_postfx_chromaticaberration_enabled = false;
|
Global.gfx_postfx_chromaticaberration_enabled = false;
|
||||||
|
|||||||
@@ -156,13 +156,6 @@ opengl33_vaogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stre
|
|||||||
chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast<void const *>( chunkrecord.index_offset * sizeof( gfx::basic_index ) ),
|
chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast<void const *>( chunkrecord.index_offset * sizeof( gfx::basic_index ) ),
|
||||||
chunkrecord.vertex_offset );
|
chunkrecord.vertex_offset );
|
||||||
}
|
}
|
||||||
else if (glDrawElementsBaseVertexOES) {
|
|
||||||
m_vao->bind();
|
|
||||||
::glDrawElementsBaseVertexOES(
|
|
||||||
chunk.type,
|
|
||||||
chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast<void const *>( chunkrecord.index_offset * sizeof( gfx::basic_index ) ),
|
|
||||||
chunkrecord.vertex_offset );
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
setup_attrib(chunkrecord.vertex_offset);
|
setup_attrib(chunkrecord.vertex_offset);
|
||||||
m_vao->bind();
|
m_vao->bind();
|
||||||
@@ -225,15 +218,6 @@ opengl33_vaogeometrybank::draw_instanced_( gfx::geometry_handle const &Geometry,
|
|||||||
inst_count,
|
inst_count,
|
||||||
chunkrecord.vertex_offset );
|
chunkrecord.vertex_offset );
|
||||||
}
|
}
|
||||||
else if( glDrawElementsInstancedBaseVertexOES ) {
|
|
||||||
m_vao->bind();
|
|
||||||
::glDrawElementsInstancedBaseVertexOES(
|
|
||||||
chunk.type,
|
|
||||||
chunkrecord.index_count, GL_UNSIGNED_INT,
|
|
||||||
reinterpret_cast<void const *>( chunkrecord.index_offset * sizeof( gfx::basic_index ) ),
|
|
||||||
inst_count,
|
|
||||||
chunkrecord.vertex_offset );
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
setup_attrib( chunkrecord.vertex_offset );
|
setup_attrib( chunkrecord.vertex_offset );
|
||||||
m_vao->bind();
|
m_vao->bind();
|
||||||
|
|||||||
@@ -169,8 +169,6 @@ bool opengl33_renderer::Init(GLFWwindow *Window)
|
|||||||
m_celestial_shader = make_shader("celestial.vert", "celestial.frag");
|
m_celestial_shader = make_shader("celestial.vert", "celestial.frag");
|
||||||
m_hiddenarea_shader = make_shader("hiddenarea.vert", "hiddenarea.frag");
|
m_hiddenarea_shader = make_shader("hiddenarea.vert", "hiddenarea.frag");
|
||||||
m_copy_shader = make_shader("quad.vert", "copy.frag");
|
m_copy_shader = make_shader("quad.vert", "copy.frag");
|
||||||
if (Global.gfx_usegles)
|
|
||||||
m_depth_pointer_shader = make_shader("quad.vert", "gles_depthpointer.frag");
|
|
||||||
m_invalid_material = Fetch_Material("invalid");
|
m_invalid_material = Fetch_Material("invalid");
|
||||||
}
|
}
|
||||||
catch (gl::shader_exception const &e)
|
catch (gl::shader_exception const &e)
|
||||||
@@ -203,7 +201,7 @@ bool opengl33_renderer::Init(GLFWwindow *Window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int samples = 1 << Global.iMultisampling;
|
int samples = 1 << Global.iMultisampling;
|
||||||
if (!Global.gfx_usegles && samples > 1)
|
if (samples > 1)
|
||||||
glEnable(GL_MULTISAMPLE);
|
glEnable(GL_MULTISAMPLE);
|
||||||
|
|
||||||
m_pfx_motionblur = std::make_unique<gl::postfx>("motionblur");
|
m_pfx_motionblur = std::make_unique<gl::postfx>("motionblur");
|
||||||
@@ -357,7 +355,7 @@ bool opengl33_renderer::Init(GLFWwindow *Window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_depth_pointer_pbo = std::make_unique<gl::pbo>();
|
m_depth_pointer_pbo = std::make_unique<gl::pbo>();
|
||||||
if (!Global.gfx_usegles && Global.iMultisampling)
|
if (Global.iMultisampling)
|
||||||
{
|
{
|
||||||
m_depth_pointer_rb = std::make_unique<gl::renderbuffer>();
|
m_depth_pointer_rb = std::make_unique<gl::renderbuffer>();
|
||||||
m_depth_pointer_rb->alloc(depth_pointer_format, 1, 1);
|
m_depth_pointer_rb->alloc(depth_pointer_format, 1, 1);
|
||||||
@@ -371,36 +369,9 @@ bool opengl33_renderer::Init(GLFWwindow *Window)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Global.gfx_usegles)
|
|
||||||
{
|
|
||||||
m_depth_pointer_tex = std::make_unique<opengl_texture>();
|
|
||||||
|
|
||||||
m_depth_pointer_tex->alloc_rendertarget(depth_pointer_format, GL_DEPTH_COMPONENT, Global.gfx_framebuffer_width, Global.gfx_framebuffer_height);
|
m_timequery.emplace(gl::query::TIME_ELAPSED);
|
||||||
|
m_timequery->begin();
|
||||||
m_depth_pointer_rb = std::make_unique<gl::renderbuffer>();
|
|
||||||
m_depth_pointer_rb->alloc(GL_R16UI, Global.gfx_framebuffer_width, Global.gfx_framebuffer_height);
|
|
||||||
|
|
||||||
m_depth_pointer_fb = std::make_unique<gl::framebuffer>();
|
|
||||||
m_depth_pointer_fb->attach(*m_depth_pointer_tex, GL_DEPTH_ATTACHMENT);
|
|
||||||
|
|
||||||
m_depth_pointer_fb2 = std::make_unique<gl::framebuffer>();
|
|
||||||
m_depth_pointer_fb2->attach(*m_depth_pointer_rb, GL_COLOR_ATTACHMENT0);
|
|
||||||
|
|
||||||
if( !m_depth_pointer_fb->is_complete() ) {
|
|
||||||
ErrorLog( "depth pointer framebuffer setup failed" );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !m_depth_pointer_fb2->is_complete() ) {
|
|
||||||
ErrorLog( "depth pointer framebuffer2 setup failed" );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Global.gfx_usegles) {
|
|
||||||
m_timequery.emplace(gl::query::TIME_ELAPSED);
|
|
||||||
m_timequery->begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteLog("picking objects created");
|
WriteLog("picking objects created");
|
||||||
|
|
||||||
@@ -463,10 +434,7 @@ bool opengl33_renderer::init_viewport(viewport_config &vp)
|
|||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
if (!Global.gfx_usegles)
|
glClearDepth(0.0f);
|
||||||
glClearDepth(0.0f);
|
|
||||||
else
|
|
||||||
glClearDepthf(0.0f);
|
|
||||||
|
|
||||||
glDepthFunc(GL_GEQUAL);
|
glDepthFunc(GL_GEQUAL);
|
||||||
|
|
||||||
@@ -475,8 +443,7 @@ bool opengl33_renderer::init_viewport(viewport_config &vp)
|
|||||||
else if (GLAD_GL_EXT_clip_control)
|
else if (GLAD_GL_EXT_clip_control)
|
||||||
glClipControlEXT(GL_LOWER_LEFT_EXT, GL_ZERO_TO_ONE_EXT);
|
glClipControlEXT(GL_LOWER_LEFT_EXT, GL_ZERO_TO_ONE_EXT);
|
||||||
|
|
||||||
if (!Global.gfx_usegles)
|
glEnable(GL_PROGRAM_POINT_SIZE);
|
||||||
glEnable(GL_PROGRAM_POINT_SIZE);
|
|
||||||
|
|
||||||
if (!gl::vao::use_vao)
|
if (!gl::vao::use_vao)
|
||||||
{
|
{
|
||||||
@@ -597,13 +564,10 @@ bool opengl33_renderer::Render()
|
|||||||
{
|
{
|
||||||
Timer::subsystem.gfx_total.start();
|
Timer::subsystem.gfx_total.start();
|
||||||
|
|
||||||
if (!Global.gfx_usegles)
|
std::optional<int64_t> result = m_timequery->result();
|
||||||
{
|
if (result) {
|
||||||
std::optional<int64_t> result = m_timequery->result();
|
m_gllasttime = *result;
|
||||||
if (result) {
|
m_timequery->begin();
|
||||||
m_gllasttime = *result;
|
|
||||||
m_timequery->begin();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch simulation data
|
// fetch simulation data
|
||||||
@@ -645,15 +609,12 @@ bool opengl33_renderer::Render()
|
|||||||
"mainloop total: " + to_string(Timer::subsystem.mainloop_total.average(), 2) + "ms\n";
|
"mainloop total: " + to_string(Timer::subsystem.mainloop_total.average(), 2) + "ms\n";
|
||||||
|
|
||||||
*/
|
*/
|
||||||
if (!Global.gfx_usegles)
|
m_timequery->end();
|
||||||
{
|
|
||||||
m_timequery->end();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (m_gllasttime)
|
if (m_gllasttime)
|
||||||
m_debugtimestext += "gpu: " + to_string((double)(m_gllasttime / 1000ULL) / 1000.0, 3) + "ms";
|
m_debugtimestext += "gpu: " + to_string((double)(m_gllasttime / 1000ULL) / 1000.0, 3) + "ms";
|
||||||
*/
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
++m_framestamp;
|
++m_framestamp;
|
||||||
Timer::subsystem.gfx_total.stop();
|
Timer::subsystem.gfx_total.stop();
|
||||||
@@ -691,10 +652,8 @@ void opengl33_renderer::SwapBuffers()
|
|||||||
" reflections: " + to_string( Timer::subsystem.gfx_reflections.average(), 2 ) + " ms\n";
|
" reflections: " + to_string( Timer::subsystem.gfx_reflections.average(), 2 ) + " ms\n";
|
||||||
}
|
}
|
||||||
m_debugtimestext += " swap: " + to_string( Timer::subsystem.gfx_swap.average(), 2 ) + " ms\n";
|
m_debugtimestext += " swap: " + to_string( Timer::subsystem.gfx_swap.average(), 2 ) + " ms\n";
|
||||||
if( !Global.gfx_usegles ) {
|
if (m_gllasttime)
|
||||||
if (m_gllasttime)
|
m_debugtimestext += "gpu frame total: " + to_string((double)(m_gllasttime / 1000ULL) / 1000.0, 3) + " ms\n";
|
||||||
m_debugtimestext += "gpu frame total: " + to_string((double)(m_gllasttime / 1000ULL) / 1000.0, 3) + " ms\n";
|
|
||||||
}
|
|
||||||
m_debugtimestext += "uilayer: " + to_string( Timer::subsystem.gfx_gui.average(), 2 ) + " ms\n";
|
m_debugtimestext += "uilayer: " + to_string( Timer::subsystem.gfx_gui.average(), 2 ) + " ms\n";
|
||||||
if( DebugModeFlag )
|
if( DebugModeFlag )
|
||||||
m_debugtimestext += m_textures.info();
|
m_debugtimestext += m_textures.info();
|
||||||
@@ -846,13 +805,10 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
|
|||||||
if (m_widelines_supported)
|
if (m_widelines_supported)
|
||||||
glLineWidth(1.0f);
|
glLineWidth(1.0f);
|
||||||
|
|
||||||
if (!Global.gfx_usegles)
|
if (Global.bWireFrame)
|
||||||
{
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
if (Global.bWireFrame)
|
else
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
else
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_shadow_unbind_map();
|
setup_shadow_unbind_map();
|
||||||
setup_env_map(nullptr);
|
setup_env_map(nullptr);
|
||||||
@@ -904,7 +860,7 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!Global.gfx_usegles && !Global.gfx_shadergamma)
|
if (!Global.gfx_shadergamma)
|
||||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glViewport(0, 0, target_size.x, target_size.y);
|
glViewport(0, 0, target_size.x, target_size.y);
|
||||||
@@ -1030,8 +986,7 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
|
|||||||
setup_shadow_unbind_map();
|
setup_shadow_unbind_map();
|
||||||
setup_env_map(nullptr);
|
setup_env_map(nullptr);
|
||||||
|
|
||||||
if (!Global.gfx_usegles)
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
||||||
|
|
||||||
if (!Global.gfx_skippipeline)
|
if (!Global.gfx_skippipeline)
|
||||||
{
|
{
|
||||||
@@ -1077,7 +1032,7 @@ if (!Global.gfx_skippipeline)
|
|||||||
m_pfx_ssao_apply->apply({ vp.main_tex.get(), vp.ssao_blur_tex.get() }, vp.main2_fb.get());
|
m_pfx_ssao_apply->apply({ vp.main_tex.get(), vp.ssao_blur_tex.get() }, vp.main2_fb.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Global.gfx_usegles && !Global.gfx_shadergamma)
|
if (!Global.gfx_shadergamma)
|
||||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||||
|
|
||||||
gl::framebuffer *target = nullptr;
|
gl::framebuffer *target = nullptr;
|
||||||
@@ -1122,7 +1077,7 @@ if (!Global.gfx_skippipeline)
|
|||||||
opengl_texture::reset_unit_cache();
|
opengl_texture::reset_unit_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Global.gfx_usegles && !Global.gfx_shadergamma)
|
if (!Global.gfx_shadergamma)
|
||||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||||
|
|
||||||
glDebug("uilayer render");
|
glDebug("uilayer render");
|
||||||
@@ -5184,16 +5139,9 @@ void opengl33_renderer::Render_Alpha(TSubModel *Submodel)
|
|||||||
|
|
||||||
// main draw call
|
// main draw call
|
||||||
if (Submodel->occlusion_query) {
|
if (Submodel->occlusion_query) {
|
||||||
if (!Global.gfx_usegles) {
|
glBeginConditionalRender(*Submodel->occlusion_query, GL_QUERY_WAIT);
|
||||||
glBeginConditionalRender(*Submodel->occlusion_query, GL_QUERY_WAIT);
|
draw(m_billboardgeometry);
|
||||||
draw(m_billboardgeometry);
|
glEndConditionalRender();
|
||||||
glEndConditionalRender();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
auto result = Submodel->occlusion_query->result();
|
|
||||||
if (result && *result)
|
|
||||||
draw(m_billboardgeometry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
draw(m_billboardgeometry);
|
draw(m_billboardgeometry);
|
||||||
@@ -5424,65 +5372,27 @@ glm::dvec3 opengl33_renderer::Update_Mouse_Position()
|
|||||||
|
|
||||||
float pointdepth = std::numeric_limits<float>::max();
|
float pointdepth = std::numeric_limits<float>::max();
|
||||||
|
|
||||||
if (!Global.gfx_usegles)
|
m_depth_pointer_pbo->read_data(1, 1, &pointdepth, 4);
|
||||||
|
|
||||||
|
if (!Global.iMultisampling)
|
||||||
{
|
{
|
||||||
m_depth_pointer_pbo->read_data(1, 1, &pointdepth, 4);
|
m_depth_pointer_pbo->request_read(bufferpos.x, bufferpos.y, 1, 1, 4, GL_DEPTH_COMPONENT, GL_FLOAT);
|
||||||
|
}
|
||||||
|
else if (Global.gfx_skippipeline)
|
||||||
|
{
|
||||||
|
gl::framebuffer::blit(nullptr, m_depth_pointer_fb.get(), bufferpos.x, bufferpos.y, 1, 1, GL_DEPTH_BUFFER_BIT, 0);
|
||||||
|
|
||||||
if (!Global.iMultisampling)
|
m_depth_pointer_fb->bind();
|
||||||
{
|
m_depth_pointer_pbo->request_read(0, 0, 1, 1, 4, GL_DEPTH_COMPONENT, GL_FLOAT);
|
||||||
m_depth_pointer_pbo->request_read(bufferpos.x, bufferpos.y, 1, 1, 4, GL_DEPTH_COMPONENT, GL_FLOAT);
|
m_depth_pointer_fb->unbind();
|
||||||
}
|
|
||||||
else if (Global.gfx_skippipeline)
|
|
||||||
{
|
|
||||||
gl::framebuffer::blit(nullptr, m_depth_pointer_fb.get(), bufferpos.x, bufferpos.y, 1, 1, GL_DEPTH_BUFFER_BIT, 0);
|
|
||||||
|
|
||||||
m_depth_pointer_fb->bind();
|
|
||||||
m_depth_pointer_pbo->request_read(0, 0, 1, 1, 4, GL_DEPTH_COMPONENT, GL_FLOAT);
|
|
||||||
m_depth_pointer_fb->unbind();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gl::framebuffer::blit(m_viewports.front()->msaa_fb.get(), m_depth_pointer_fb.get(), bufferpos.x, bufferpos.y, 1, 1, GL_DEPTH_BUFFER_BIT, 0);
|
|
||||||
|
|
||||||
m_depth_pointer_fb->bind();
|
|
||||||
m_depth_pointer_pbo->request_read(0, 0, 1, 1, 4, GL_DEPTH_COMPONENT, GL_FLOAT);
|
|
||||||
m_viewports.front()->msaa_fb->bind();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned int data[4];
|
gl::framebuffer::blit(m_viewports.front()->msaa_fb.get(), m_depth_pointer_fb.get(), bufferpos.x, bufferpos.y, 1, 1, GL_DEPTH_BUFFER_BIT, 0);
|
||||||
if (m_depth_pointer_pbo->read_data(1, 1, data, 16))
|
|
||||||
pointdepth = (double)data[0] / 65535.0;
|
|
||||||
|
|
||||||
if (Global.gfx_skippipeline)
|
m_depth_pointer_fb->bind();
|
||||||
{
|
m_depth_pointer_pbo->request_read(0, 0, 1, 1, 4, GL_DEPTH_COMPONENT, GL_FLOAT);
|
||||||
gl::framebuffer::blit(nullptr, m_depth_pointer_fb.get(), 0, 0, Global.gfx_framebuffer_width, Global.gfx_framebuffer_height, GL_DEPTH_BUFFER_BIT, 0);
|
m_viewports.front()->msaa_fb->bind();
|
||||||
|
|
||||||
m_empty_vao->bind();
|
|
||||||
m_depth_pointer_tex->bind(0);
|
|
||||||
m_depth_pointer_shader->bind();
|
|
||||||
m_depth_pointer_fb2->bind();
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
m_depth_pointer_pbo->request_read(bufferpos.x, bufferpos.y, 1, 1, 16, GL_RGBA_INTEGER, GL_UNSIGNED_INT);
|
|
||||||
m_depth_pointer_shader->unbind();
|
|
||||||
m_empty_vao->unbind();
|
|
||||||
m_depth_pointer_fb2->unbind();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gl::framebuffer::blit(m_viewports.front()->msaa_fb.get(), m_depth_pointer_fb.get(), 0, 0, Global.gfx_framebuffer_width, Global.gfx_framebuffer_height, GL_DEPTH_BUFFER_BIT, 0);
|
|
||||||
|
|
||||||
m_empty_vao->bind();
|
|
||||||
m_depth_pointer_tex->bind(0);
|
|
||||||
m_depth_pointer_shader->bind();
|
|
||||||
m_depth_pointer_fb2->bind();
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
m_depth_pointer_pbo->request_read(bufferpos.x, bufferpos.y, 1, 1, 16, GL_RGBA_INTEGER, GL_UNSIGNED_INT);
|
|
||||||
m_depth_pointer_shader->unbind();
|
|
||||||
m_empty_vao->unbind();
|
|
||||||
m_viewports.front()->msaa_fb->bind();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pointdepth != std::numeric_limits<float>::max())
|
if (pointdepth != std::numeric_limits<float>::max())
|
||||||
@@ -5760,8 +5670,7 @@ void opengl33_renderer::Preview_Color(TAnimModel *Instance, float const Squaredi
|
|||||||
glClearStencil(0);
|
glClearStencil(0);
|
||||||
glStencilMask(0xFF);
|
glStencilMask(0xFF);
|
||||||
m_preview.hdr_fb->clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
m_preview.hdr_fb->clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
if (!Global.gfx_usegles)
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
// every fragment which made it past the alpha test marks the pixel as covered, translucent ones included
|
// every fragment which made it past the alpha test marks the pixel as covered, translucent ones included
|
||||||
glEnable(GL_STENCIL_TEST);
|
glEnable(GL_STENCIL_TEST);
|
||||||
@@ -5944,10 +5853,10 @@ bool opengl33_renderer::Render_Preview(TAnimModel *Instance, int const Size, int
|
|||||||
// the image itself
|
// the image itself
|
||||||
Preview_Color(Instance, squaredistance, targetsize, eye, view, cropped(), shadows);
|
Preview_Color(Instance, squaredistance, targetsize, eye, view, cropped(), shadows);
|
||||||
glViewport(0, 0, targetsize, targetsize);
|
glViewport(0, 0, targetsize, targetsize);
|
||||||
if (!Global.gfx_usegles && !Global.gfx_shadergamma)
|
if (!Global.gfx_shadergamma)
|
||||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||||
m_pfx_tonemapping->apply(*m_preview.hdr_tex, m_preview.ldr_fb.get());
|
m_pfx_tonemapping->apply(*m_preview.hdr_tex, m_preview.ldr_fb.get());
|
||||||
if (!Global.gfx_usegles && !Global.gfx_shadergamma)
|
if (!Global.gfx_shadergamma)
|
||||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||||
opengl_texture::reset_unit_cache();
|
opengl_texture::reset_unit_cache();
|
||||||
// the post processing binds its own vertex array, which the geometry banks don't know about
|
// the post processing binds its own vertex array, which the geometry banks don't know about
|
||||||
@@ -6209,53 +6118,31 @@ bool opengl33_renderer::Init_caps()
|
|||||||
}
|
}
|
||||||
WriteLog("--------");
|
WriteLog("--------");
|
||||||
|
|
||||||
if (!Global.gfx_usegles)
|
crashreport_add_info("gl_family", "desktop");
|
||||||
|
|
||||||
|
if (!GLAD_GL_VERSION_3_3)
|
||||||
{
|
{
|
||||||
crashreport_add_info("gl_family", "desktop");
|
ErrorLog("requires OpenGL >= 3.3!");
|
||||||
|
return false;
|
||||||
if (!GLAD_GL_VERSION_3_3)
|
|
||||||
{
|
|
||||||
ErrorLog("requires OpenGL >= 3.3!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!GLAD_GL_EXT_texture_sRGB)
|
|
||||||
ErrorLog("EXT_texture_sRGB not supported!");
|
|
||||||
|
|
||||||
if (!GLAD_GL_EXT_texture_compression_s3tc)
|
|
||||||
ErrorLog("EXT_texture_compression_s3tc not supported!");
|
|
||||||
|
|
||||||
if (GLAD_GL_ARB_texture_filter_anisotropic)
|
|
||||||
WriteLog("ARB_texture_filter_anisotropic supported!");
|
|
||||||
|
|
||||||
if (GLAD_GL_ARB_multi_bind)
|
|
||||||
WriteLog("ARB_multi_bind supported!");
|
|
||||||
|
|
||||||
if (GLAD_GL_ARB_direct_state_access)
|
|
||||||
WriteLog("ARB_direct_state_access supported!");
|
|
||||||
|
|
||||||
if (GLAD_GL_ARB_clip_control)
|
|
||||||
WriteLog("ARB_clip_control supported!");
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
crashreport_add_info("gl_family", "gles");
|
|
||||||
|
|
||||||
if (!GLAD_GL_ES_VERSION_3_0)
|
if (!GLAD_GL_EXT_texture_sRGB)
|
||||||
{
|
ErrorLog("EXT_texture_sRGB not supported!");
|
||||||
ErrorLog("requires OpenGL ES >= 3.0!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GLAD_GL_EXT_texture_filter_anisotropic)
|
if (!GLAD_GL_EXT_texture_compression_s3tc)
|
||||||
WriteLog("EXT_texture_filter_anisotropic supported!");
|
ErrorLog("EXT_texture_compression_s3tc not supported!");
|
||||||
|
|
||||||
if (GLAD_GL_EXT_clip_control)
|
if (GLAD_GL_ARB_texture_filter_anisotropic)
|
||||||
WriteLog("EXT_clip_control supported!");
|
WriteLog("ARB_texture_filter_anisotropic supported!");
|
||||||
|
|
||||||
if (GLAD_GL_EXT_geometry_shader)
|
if (GLAD_GL_ARB_multi_bind)
|
||||||
WriteLog("EXT_geometry_shader supported!");
|
WriteLog("ARB_multi_bind supported!");
|
||||||
}
|
|
||||||
|
if (GLAD_GL_ARB_direct_state_access)
|
||||||
|
WriteLog("ARB_direct_state_access supported!");
|
||||||
|
|
||||||
|
if (GLAD_GL_ARB_clip_control)
|
||||||
|
WriteLog("ARB_clip_control supported!");
|
||||||
|
|
||||||
glGetError();
|
glGetError();
|
||||||
glLineWidth(2.0f);
|
glLineWidth(2.0f);
|
||||||
@@ -6318,10 +6205,7 @@ bool opengl33_renderer::renderer_register = gfx_renderer_factory::get_instance()
|
|||||||
bool opengl33_renderer::opengl33_imgui_renderer::Init()
|
bool opengl33_renderer::opengl33_imgui_renderer::Init()
|
||||||
{
|
{
|
||||||
crashreport_add_info("imgui_ver", "gl3");
|
crashreport_add_info("imgui_ver", "gl3");
|
||||||
if (Global.gfx_usegles)
|
return ImGui_ImplOpenGL3_Init("#version 330 core");
|
||||||
return ImGui_ImplOpenGL3_Init("#version 300 es\nprecision highp float;");
|
|
||||||
else
|
|
||||||
return ImGui_ImplOpenGL3_Init("#version 330 core");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void opengl33_renderer::opengl33_imgui_renderer::Shutdown()
|
void opengl33_renderer::opengl33_imgui_renderer::Shutdown()
|
||||||
|
|||||||
@@ -536,10 +536,7 @@ class opengl33_renderer : public gfx_renderer {
|
|||||||
|
|
||||||
std::unique_ptr<gl::pbo> m_depth_pointer_pbo;
|
std::unique_ptr<gl::pbo> m_depth_pointer_pbo;
|
||||||
std::unique_ptr<gl::framebuffer> m_depth_pointer_fb;
|
std::unique_ptr<gl::framebuffer> m_depth_pointer_fb;
|
||||||
std::unique_ptr<gl::framebuffer> m_depth_pointer_fb2;
|
|
||||||
std::unique_ptr<gl::renderbuffer> m_depth_pointer_rb;
|
std::unique_ptr<gl::renderbuffer> m_depth_pointer_rb;
|
||||||
std::unique_ptr<opengl_texture> m_depth_pointer_tex;
|
|
||||||
std::unique_ptr<gl::program> m_depth_pointer_shader;
|
|
||||||
|
|
||||||
material_handle m_invalid_material;
|
material_handle m_invalid_material;
|
||||||
|
|
||||||
|
|||||||
@@ -368,13 +368,10 @@ bool opengl33_terrain_materials::copy_layer(layer &Layer)
|
|||||||
::glClearBufferfv(GL_COLOR, 0, defaults[i].data());
|
::glClearBufferfv(GL_COLOR, 0, defaults[i].data());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (false == Global.gfx_usegles)
|
if (array.srgb)
|
||||||
{
|
::glEnable(GL_FRAMEBUFFER_SRGB);
|
||||||
if (array.srgb)
|
else
|
||||||
::glEnable(GL_FRAMEBUFFER_SRGB);
|
::glDisable(GL_FRAMEBUFFER_SRGB);
|
||||||
else
|
|
||||||
::glDisable(GL_FRAMEBUFFER_SRGB);
|
|
||||||
}
|
|
||||||
m_copy->apply(*sources[i], m_framebuffer.get());
|
m_copy->apply(*sources[i], m_framebuffer.get());
|
||||||
}
|
}
|
||||||
Layer.copied = true;
|
Layer.copied = true;
|
||||||
@@ -390,7 +387,7 @@ void opengl33_terrain_materials::update()
|
|||||||
auto const scissor{::glIsEnabled(GL_SCISSOR_TEST)};
|
auto const scissor{::glIsEnabled(GL_SCISSOR_TEST)};
|
||||||
auto const cull{::glIsEnabled(GL_CULL_FACE)};
|
auto const cull{::glIsEnabled(GL_CULL_FACE)};
|
||||||
auto const depth{::glIsEnabled(GL_DEPTH_TEST)};
|
auto const depth{::glIsEnabled(GL_DEPTH_TEST)};
|
||||||
auto const srgb{(false == Global.gfx_usegles) && ::glIsEnabled(GL_FRAMEBUFFER_SRGB)};
|
auto const srgb{::glIsEnabled(GL_FRAMEBUFFER_SRGB)};
|
||||||
::glDisable(GL_BLEND);
|
::glDisable(GL_BLEND);
|
||||||
::glDisable(GL_SCISSOR_TEST);
|
::glDisable(GL_SCISSOR_TEST);
|
||||||
::glDisable(GL_CULL_FACE);
|
::glDisable(GL_CULL_FACE);
|
||||||
@@ -427,13 +424,10 @@ void opengl33_terrain_materials::update()
|
|||||||
::glEnable(GL_DEPTH_TEST);
|
::glEnable(GL_DEPTH_TEST);
|
||||||
else
|
else
|
||||||
::glDisable(GL_DEPTH_TEST);
|
::glDisable(GL_DEPTH_TEST);
|
||||||
if (false == Global.gfx_usegles)
|
if (srgb)
|
||||||
{
|
::glEnable(GL_FRAMEBUFFER_SRGB);
|
||||||
if (srgb)
|
else
|
||||||
::glEnable(GL_FRAMEBUFFER_SRGB);
|
::glDisable(GL_FRAMEBUFFER_SRGB);
|
||||||
else
|
|
||||||
::glDisable(GL_FRAMEBUFFER_SRGB);
|
|
||||||
}
|
|
||||||
::glDepthMask(GL_TRUE);
|
::glDepthMask(GL_TRUE);
|
||||||
opengl_texture::reset_unit_cache();
|
opengl_texture::reset_unit_cache();
|
||||||
gfx::opengl33_vaogeometrybank::reset();
|
gfx::opengl33_vaogeometrybank::reset();
|
||||||
|
|||||||
@@ -13,21 +13,8 @@ void screenshot_manager::screenshot_save_thread( char *img, int w, int h )
|
|||||||
png.width = w;
|
png.width = w;
|
||||||
png.height = h;
|
png.height = h;
|
||||||
|
|
||||||
int stride;
|
png.format = PNG_FORMAT_RGB;
|
||||||
if (Global.gfx_usegles)
|
int stride = -w * 3;
|
||||||
{
|
|
||||||
png.format = PNG_FORMAT_RGBA;
|
|
||||||
stride = -w * 4;
|
|
||||||
|
|
||||||
for (int y = 0; y < h; y++)
|
|
||||||
for (int x = 0; x < w; x++)
|
|
||||||
img[(y * w + x) * 4 + 3] = 0xFF;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
png.format = PNG_FORMAT_RGB;
|
|
||||||
stride = -w * 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::array<char, 64> datetime{};
|
std::array<char, 64> datetime{};
|
||||||
std::tm const tm_info = local_tm(std::time(nullptr));
|
std::tm const tm_info = local_tm(std::time(nullptr));
|
||||||
@@ -56,7 +43,7 @@ void screenshot_manager::screenshot_save_thread( char *img, int w, int h )
|
|||||||
void screenshot_manager::make_screenshot()
|
void screenshot_manager::make_screenshot()
|
||||||
{
|
{
|
||||||
auto img = new char[Global.fb_size.x * Global.fb_size.y * 4];
|
auto img = new char[Global.fb_size.x * Global.fb_size.y * 4];
|
||||||
glReadPixels(0, 0, Global.fb_size.x, Global.fb_size.y, Global.gfx_usegles ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)img);
|
glReadPixels(0, 0, Global.fb_size.x, Global.fb_size.y, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)img);
|
||||||
//m7t: use pbo
|
//m7t: use pbo
|
||||||
|
|
||||||
std::thread t(screenshot_save_thread, img, Global.fb_size.x, Global.fb_size.y);
|
std::thread t(screenshot_save_thread, img, Global.fb_size.x, Global.fb_size.y);
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ void render_task::run()
|
|||||||
const auto screenWidth = static_cast<int>(PyLong_AsLong(outputWidth));
|
const auto screenWidth = static_cast<int>(PyLong_AsLong(outputWidth));
|
||||||
const auto screenHeight = static_cast<int>(PyLong_AsLong(outputHeight));
|
const auto screenHeight = static_cast<int>(PyLong_AsLong(outputHeight));
|
||||||
|
|
||||||
const bool useRgb = false && !Global.gfx_usegles;
|
const bool useRgb = false;
|
||||||
|
|
||||||
const int glFormat = useRgb ? GL_SRGB8 : GL_SRGB8_ALPHA8;
|
const int glFormat = useRgb ? GL_SRGB8 : GL_SRGB8_ALPHA8;
|
||||||
const int glComponents = useRgb ? GL_RGB : GL_RGBA;
|
const int glComponents = useRgb ? GL_RGB : GL_RGBA;
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ void python_screen_viewer::threadfunc()
|
|||||||
glBindTexture(GL_TEXTURE_2D, tex);
|
glBindTexture(GL_TEXTURE_2D, tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Global.gfx_usegles && !Global.gfx_shadergamma)
|
if (!Global.gfx_shadergamma)
|
||||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||||
|
|
||||||
gl::program::unbind();
|
gl::program::unbind();
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
in vec2 f_coords;
|
|
||||||
|
|
||||||
#texture (tex1, 0, R)
|
|
||||||
uniform sampler2D tex1;
|
|
||||||
|
|
||||||
layout(location = 0) out uvec4 out_color;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
out_color = uvec4(uint(texture(tex1, f_coords).r * 65535.0), 0, 0, 0xFFFF);
|
|
||||||
}
|
|
||||||
@@ -377,14 +377,16 @@ bool global_settings::ConfigParseGraphics(cParser& Parser, const std::string& to
|
|||||||
if (token == "compresstex")
|
if (token == "compresstex")
|
||||||
{
|
{
|
||||||
Parser.getTokens(1);
|
Parser.getTokens(1);
|
||||||
if (!gfx_usegles)
|
Parser >> compress_tex;
|
||||||
Parser >> compress_tex;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token == "gfx.angleplatform")
|
if (token == "gfx.angleplatform")
|
||||||
{
|
{
|
||||||
ParseOne(Parser, gfx_angleplatform, 1);
|
// the OpenGL ES / ANGLE path was removed; read and ignore so old eu07.ini files still load
|
||||||
|
std::string angleplatform;
|
||||||
|
ParseOne(Parser, angleplatform, 1);
|
||||||
|
WriteLog("eu07.ini: \"gfx.angleplatform\" is no longer supported and was ignored");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1489,8 +1491,11 @@ global_settings::ConfigParse_gfx( cParser &Parser, std::string_view const Token
|
|||||||
}
|
}
|
||||||
else if (Token == "gfx.usegles")
|
else if (Token == "gfx.usegles")
|
||||||
{
|
{
|
||||||
|
// the OpenGL ES / ANGLE path was removed; read and ignore so old eu07.ini files still load
|
||||||
|
bool usegles{false};
|
||||||
Parser.getTokens(1);
|
Parser.getTokens(1);
|
||||||
Parser >> gfx_usegles;
|
Parser >> usegles;
|
||||||
|
WriteLog("eu07.ini: \"gfx.usegles\" is no longer supported and was ignored");
|
||||||
}
|
}
|
||||||
else if (Token == "gfx.shadergamma")
|
else if (Token == "gfx.shadergamma")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -292,8 +292,6 @@ struct global_settings {
|
|||||||
bool gfx_skippipeline = false;
|
bool gfx_skippipeline = false;
|
||||||
bool gfx_extraeffects = true;
|
bool gfx_extraeffects = true;
|
||||||
bool gfx_shadergamma = false;
|
bool gfx_shadergamma = false;
|
||||||
bool gfx_usegles = false;
|
|
||||||
std::string gfx_angleplatform;
|
|
||||||
bool gfx_gldebug = false;
|
bool gfx_gldebug = false;
|
||||||
bool vr = false;
|
bool vr = false;
|
||||||
std::string vr_backend;
|
std::string vr_backend;
|
||||||
|
|||||||
@@ -30,12 +30,10 @@ ui::map_panel::map_panel() : ui_panel(STR_C("Map"), false)
|
|||||||
gl::shader frag("map.frag");
|
gl::shader frag("map.frag");
|
||||||
|
|
||||||
m_track_shader = std::unique_ptr<gl::program>(new gl::program({vert, frag}));
|
m_track_shader = std::unique_ptr<gl::program>(new gl::program({vert, frag}));
|
||||||
if (!Global.gfx_usegles || GLAD_GL_EXT_geometry_shader) {
|
gl::shader poi_frag("map_poi.frag");
|
||||||
gl::shader poi_frag("map_poi.frag");
|
gl::shader poi_geom("map_poi.geom");
|
||||||
gl::shader poi_geom("map_poi.geom");
|
m_poi_shader = std::unique_ptr<gl::program>(new gl::program({vert, poi_frag, poi_geom}));
|
||||||
m_poi_shader = std::unique_ptr<gl::program>(new gl::program({vert, poi_frag, poi_geom}));
|
m_icon_atlas = GfxRenderer->Fetch_Texture("map_icons");
|
||||||
m_icon_atlas = GfxRenderer->Fetch_Texture("map_icons");
|
|
||||||
}
|
|
||||||
|
|
||||||
m_tex = std::make_unique<opengl_texture>();
|
m_tex = std::make_unique<opengl_texture>();
|
||||||
m_tex->alloc_rendertarget(GL_RGB8, GL_RGB, fb_size, fb_size);
|
m_tex->alloc_rendertarget(GL_RGB8, GL_RGB, fb_size, fb_size);
|
||||||
@@ -174,11 +172,9 @@ void ui::map_panel::render_map_texture(glm::mat4 transform, glm::vec2 surface_si
|
|||||||
scene_ubo->update(scene_ubs);
|
scene_ubo->update(scene_ubs);
|
||||||
gl33->Draw_Geometry(m_colored_paths.highlighted.begin(), m_colored_paths.highlighted.end());
|
gl33->Draw_Geometry(m_colored_paths.highlighted.begin(), m_colored_paths.highlighted.end());
|
||||||
|
|
||||||
if (!Global.gfx_usegles || GLAD_GL_EXT_geometry_shader) {
|
gl33->Bind_Texture(0, m_icon_atlas);
|
||||||
gl33->Bind_Texture(0, m_icon_atlas);
|
m_poi_shader->bind();
|
||||||
m_poi_shader->bind();
|
scene_ubs.cascade_end = glm::vec4(1.0f / (surface_size / 200.0f), 1.0f, 0.0f);
|
||||||
scene_ubs.cascade_end = glm::vec4(1.0f / (surface_size / 200.0f), 1.0f, 0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map::Objects.poi_dirty) {
|
if (map::Objects.poi_dirty) {
|
||||||
map::Objects.poi_dirty = false;
|
map::Objects.poi_dirty = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user