Use OpenGL 3.3 core profile instead of compatibility profile

- Rename OpenGL to GLES3 in the source code per community feedback.
  - The renderer is still exposed as "OpenGL 3" to the user.
- Hide renderer selection dropdown until OpenGL support is more mature.
  - The renderer can still be changed in the Project Settings or using
    the `--rendering-driver opengl` command line argument.
- Remove commented out exporter code.
- Remove some OpenGL/DisplayServer-related debugging prints.
This commit is contained in:
Clay John 2021-10-26 08:18:39 -07:00 committed by Hugo Locurcio
parent ce97ddbcb1
commit 8a10bb7d0d
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
83 changed files with 2155 additions and 8187 deletions

View file

@ -15,7 +15,7 @@ from collections import OrderedDict
# Local
import methods
import glsl_builders
import opengl_builders
import gles3_builders
from platform_methods import run_in_subprocess
# Scan possible build platforms
@ -711,8 +711,8 @@ if selected_platform in platform_list:
if not env["platform"] == "server":
env.Append(
BUILDERS={
"OpenGL_GLSL": env.Builder(
action=run_in_subprocess(opengl_builders.build_opengl_headers),
"GLES3_GLSL": env.Builder(
action=run_in_subprocess(gles3_builders.build_gles3_headers),
suffix="glsl.gen.h",
src_suffix=".glsl",
)

View file

@ -604,7 +604,7 @@ void OS::_bind_methods() {
ADD_PROPERTY_DEFAULT("low_processor_usage_mode_sleep_usec", 6900);
BIND_ENUM_CONSTANT(VIDEO_DRIVER_VULKAN);
BIND_ENUM_CONSTANT(VIDEO_DRIVER_OPENGL);
BIND_ENUM_CONSTANT(VIDEO_DRIVER_OPENGL_3);
BIND_ENUM_CONSTANT(DAY_SUNDAY);
BIND_ENUM_CONSTANT(DAY_MONDAY);

View file

@ -120,7 +120,7 @@ protected:
public:
enum VideoDriver {
VIDEO_DRIVER_VULKAN,
VIDEO_DRIVER_OPENGL,
VIDEO_DRIVER_OPENGL_3,
};
enum Weekday {

View file

@ -456,10 +456,10 @@
</members>
<constants>
<constant name="VIDEO_DRIVER_VULKAN" value="0" enum="VideoDriver">
The Vulkan rendering backend.
The Vulkan rendering backend. It requires Vulkan 1.0 support and automatically uses features from Vulkan 1.1 and 1.2 if available.
</constant>
<constant name="VIDEO_DRIVER_OPENGL" value="1" enum="VideoDriver">
The OpenGL rendering backend. It uses OpenGL ES 3.0 on mobile devices, OpenGL 3.3 on desktop platforms and WebGL 2.0 on the web.
<constant name="VIDEO_DRIVER_OPENGL_3" value="1" enum="VideoDriver">
The OpenGL 3 rendering backend. It uses OpenGL 3.3 Core Profile on desktop platforms, OpenGL ES 3.0 on mobile devices, and WebGL 2.0 on HTML5.
</constant>
<constant name="DAY_SUNDAY" value="0" enum="Weekday">
Sunday.

View file

@ -1475,6 +1475,18 @@
The number of fixed iterations per second. This controls how often physics simulation and [method Node._physics_process] methods are run.
[b]Note:[/b] This property is only read when the project starts. To change the physics FPS at runtime, set [member Engine.physics_ticks_per_second] instead.
</member>
<member name="rendering/2d/opengl/batching_send_null" type="int" setter="" getter="" default="0">
</member>
<member name="rendering/2d/opengl/batching_stream" type="int" setter="" getter="" default="0">
</member>
<member name="rendering/2d/opengl/legacy_orphan_buffers" type="int" setter="" getter="" default="0">
</member>
<member name="rendering/2d/opengl/legacy_stream" type="int" setter="" getter="" default="0">
</member>
<member name="rendering/2d/options/ninepatch_mode" type="int" setter="" getter="" default="1">
</member>
<member name="rendering/2d/options/use_software_skinning" type="bool" setter="" getter="" default="true">
</member>
<member name="rendering/2d/sdf/oversize" type="int" setter="" getter="" default="1">
</member>
<member name="rendering/2d/sdf/scale" type="int" setter="" getter="" default="1">
@ -1504,6 +1516,32 @@
</member>
<member name="rendering/anti_aliasing/screen_space_roughness_limiter/limit" type="float" setter="" getter="" default="0.18">
</member>
<member name="rendering/batching/debug/diagnose_frame" type="bool" setter="" getter="" default="false">
</member>
<member name="rendering/batching/debug/flash_batching" type="bool" setter="" getter="" default="false">
</member>
<member name="rendering/batching/lights/max_join_items" type="int" setter="" getter="" default="32">
</member>
<member name="rendering/batching/lights/scissor_area_threshold" type="float" setter="" getter="" default="1.0">
</member>
<member name="rendering/batching/options/single_rect_fallback" type="bool" setter="" getter="" default="false">
</member>
<member name="rendering/batching/options/use_batching" type="bool" setter="" getter="" default="false">
</member>
<member name="rendering/batching/options/use_batching_in_editor" type="bool" setter="" getter="" default="false">
</member>
<member name="rendering/batching/parameters/batch_buffer_size" type="int" setter="" getter="" default="16384">
</member>
<member name="rendering/batching/parameters/colored_vertex_format_threshold" type="float" setter="" getter="" default="0.25">
</member>
<member name="rendering/batching/parameters/item_reordering_lookahead" type="int" setter="" getter="" default="4">
</member>
<member name="rendering/batching/parameters/max_join_item_commands" type="int" setter="" getter="" default="16">
</member>
<member name="rendering/batching/precision/uv_contract" type="bool" setter="" getter="" default="false">
</member>
<member name="rendering/batching/precision/uv_contract_amount" type="int" setter="" getter="" default="100">
</member>
<member name="rendering/camera/depth_of_field/depth_of_field_bokeh_quality" type="int" setter="" getter="" default="1">
Sets the quality of the depth of field effect. Higher quality takes more samples, which is slower but looks smoother.
</member>
@ -1585,6 +1623,10 @@
<member name="rendering/environment/volumetric_fog/volume_size" type="int" setter="" getter="" default="64">
Base size used to determine size of froxel buffer in the camera X-axis and Y-axis. The final size is scaled by the aspect ratio of the screen, so actual values may differ from what is set. Set a larger size for more detailed fog, set a smaller size for better performance.
</member>
<member name="rendering/gles2/compatibility/disable_half_float" type="bool" setter="" getter="" default="false">
</member>
<member name="rendering/gles2/compatibility/enable_high_float.Android" type="bool" setter="" getter="" default="false">
</member>
<member name="rendering/global_illumination/gi/use_half_resolution" type="bool" setter="" getter="" default="false">
</member>
<member name="rendering/global_illumination/sdfgi/frames_to_converge" type="int" setter="" getter="" default="4">

View file

@ -25,7 +25,7 @@ SConscript("winmidi/SCsub")
# Graphics drivers
if env["vulkan"]:
SConscript("vulkan/SCsub")
SConscript("opengl/SCsub")
SConscript("gles3/SCsub")
SConscript("gl_context/SCsub")
else:
SConscript("dummy/SCsub")

View file

@ -35,7 +35,7 @@
* Fast single-threaded growable array for POD types.
* For use in render drivers, not for general use.
* TO BE REPLACED by local_vector.
*/
*/
#include "core/os/memory.h"
#include <string.h>
@ -47,13 +47,13 @@
// which can be cast to whatever vertex format FVF required, and is initially
// created with enough memory to hold the biggest FVF.
// This allows multiple FVFs to use the same array.
class RasterizerUnitArrayOpenGL {
class RasterizerUnitArrayGLES3 {
public:
RasterizerUnitArrayOpenGL() {
RasterizerUnitArrayGLES3() {
_list = nullptr;
free();
}
~RasterizerUnitArrayOpenGL() { free(); }
~RasterizerUnitArrayGLES3() { free(); }
uint8_t *get_unit(unsigned int ui) { return &_list[ui * _unit_size_bytes]; }
const uint8_t *get_unit(unsigned int ui) const { return &_list[ui * _unit_size_bytes]; }

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* rasterizer_canvas_base_opengl.cpp */
/* rasterizer_canvas_base_gles3.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,12 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "rasterizer_canvas_base_opengl.h"
#ifdef OPENGL_BACKEND_ENABLED
#include "rasterizer_canvas_base_gles3.h"
#ifdef GLES3_BACKEND_ENABLED
#include "core/os/os.h"
#include "drivers/opengl/rasterizer_asserts.h"
#include "rasterizer_scene_opengl.h"
#include "drivers/gles3/rasterizer_asserts.h"
#include "rasterizer_scene_gles3.h"
#include "core/config/project_settings.h"
#include "servers/rendering/rendering_server_default.h"
@ -42,56 +42,75 @@
#define glClearDepth glClearDepthf
#endif
RID RasterizerCanvasBaseOpenGL::light_internal_create() {
static _FORCE_INLINE_ void store_transform3d(const Transform3D &p_mtx, float *p_array) {
p_array[0] = p_mtx.basis.elements[0][0];
p_array[1] = p_mtx.basis.elements[1][0];
p_array[2] = p_mtx.basis.elements[2][0];
p_array[3] = 0;
p_array[4] = p_mtx.basis.elements[0][1];
p_array[5] = p_mtx.basis.elements[1][1];
p_array[6] = p_mtx.basis.elements[2][1];
p_array[7] = 0;
p_array[8] = p_mtx.basis.elements[0][2];
p_array[9] = p_mtx.basis.elements[1][2];
p_array[10] = p_mtx.basis.elements[2][2];
p_array[11] = 0;
p_array[12] = p_mtx.origin.x;
p_array[13] = p_mtx.origin.y;
p_array[14] = p_mtx.origin.z;
p_array[15] = 1;
}
RID RasterizerCanvasBaseGLES3::light_internal_create() {
return RID();
}
void RasterizerCanvasBaseOpenGL::light_internal_update(RID p_rid, Light *p_light) {
void RasterizerCanvasBaseGLES3::light_internal_update(RID p_rid, Light *p_light) {
}
void RasterizerCanvasBaseOpenGL::light_internal_free(RID p_rid) {
void RasterizerCanvasBaseGLES3::light_internal_free(RID p_rid) {
}
RID RasterizerCanvasBaseOpenGL::light_create() {
RID RasterizerCanvasBaseGLES3::light_create() {
return RID();
}
void RasterizerCanvasBaseOpenGL::light_set_texture(RID p_rid, RID p_texture) {
void RasterizerCanvasBaseGLES3::light_set_texture(RID p_rid, RID p_texture) {
}
void RasterizerCanvasBaseOpenGL::light_set_use_shadow(RID p_rid, bool p_enable) {
void RasterizerCanvasBaseGLES3::light_set_use_shadow(RID p_rid, bool p_enable) {
}
void RasterizerCanvasBaseOpenGL::light_update_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders) {
void RasterizerCanvasBaseGLES3::light_update_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders) {
}
void RasterizerCanvasBaseOpenGL::light_update_directional_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_cull_distance, const Rect2 &p_clip_rect, LightOccluderInstance *p_occluders) {
void RasterizerCanvasBaseGLES3::light_update_directional_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_cull_distance, const Rect2 &p_clip_rect, LightOccluderInstance *p_occluders) {
}
void RasterizerCanvasBaseOpenGL::render_sdf(RID p_render_target, LightOccluderInstance *p_occluders) {
void RasterizerCanvasBaseGLES3::render_sdf(RID p_render_target, LightOccluderInstance *p_occluders) {
}
RID RasterizerCanvasBaseOpenGL::occluder_polygon_create() {
RID RasterizerCanvasBaseGLES3::occluder_polygon_create() {
return RID();
}
void RasterizerCanvasBaseOpenGL::occluder_polygon_set_shape(RID p_occluder, const Vector<Vector2> &p_points, bool p_closed) {
void RasterizerCanvasBaseGLES3::occluder_polygon_set_shape(RID p_occluder, const Vector<Vector2> &p_points, bool p_closed) {
}
void RasterizerCanvasBaseOpenGL::occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) {
void RasterizerCanvasBaseGLES3::occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) {
}
void RasterizerCanvasBaseOpenGL::set_shadow_texture_size(int p_size) {
void RasterizerCanvasBaseGLES3::set_shadow_texture_size(int p_size) {
}
bool RasterizerCanvasBaseOpenGL::free(RID p_rid) {
bool RasterizerCanvasBaseGLES3::free(RID p_rid) {
return true;
}
void RasterizerCanvasBaseOpenGL::update() {
void RasterizerCanvasBaseGLES3::update() {
}
void RasterizerCanvasBaseOpenGL::canvas_begin() {
void RasterizerCanvasBaseGLES3::canvas_begin() {
state.using_transparent_rt = false;
// always start with light_angle unset
@ -99,9 +118,9 @@ void RasterizerCanvasBaseOpenGL::canvas_begin() {
state.using_large_vertex = false;
state.using_modulate = false;
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_LIGHT_ANGLE, false);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_MODULATE, false);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_LARGE_VERTEX, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_ATTRIB_LIGHT_ANGLE, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_ATTRIB_MODULATE, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_ATTRIB_LARGE_VERTEX, false);
state.canvas_shader.bind();
int viewport_x, viewport_y, viewport_width, viewport_height;
@ -204,15 +223,14 @@ void RasterizerCanvasBaseOpenGL::canvas_begin() {
_set_uniforms();
_bind_quad_buffer();
glBindBufferBase(GL_UNIFORM_BUFFER, 0, state.canvas_item_ubo);
glBindVertexArray(data.canvas_quad_array);
}
void RasterizerCanvasBaseOpenGL::canvas_end() {
void RasterizerCanvasBaseGLES3::canvas_end() {
glBindBuffer(GL_ARRAY_BUFFER, 0);
for (int i = 0; i < RS::ARRAY_MAX; i++) {
glDisableVertexAttribArray(i);
}
if (storage->frame.current_rt && storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) {
//reset viewport to full window size
// int viewport_width = OS::get_singleton()->get_window_size().width;
@ -229,38 +247,38 @@ void RasterizerCanvasBaseOpenGL::canvas_end() {
state.using_transparent_rt = false;
}
void RasterizerCanvasBaseOpenGL::draw_generic_textured_rect(const Rect2 &p_rect, const Rect2 &p_src) {
state.canvas_shader.set_uniform(CanvasShaderOpenGL::DST_RECT, Color(p_rect.position.x, p_rect.position.y, p_rect.size.x, p_rect.size.y));
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SRC_RECT, Color(p_src.position.x, p_src.position.y, p_src.size.x, p_src.size.y));
void RasterizerCanvasBaseGLES3::draw_generic_textured_rect(const Rect2 &p_rect, const Rect2 &p_src) {
state.canvas_shader.set_uniform(CanvasShaderGLES3::DST_RECT, Color(p_rect.position.x, p_rect.position.y, p_rect.size.x, p_rect.size.y));
state.canvas_shader.set_uniform(CanvasShaderGLES3::SRC_RECT, Color(p_src.position.x, p_src.position.y, p_src.size.x, p_src.size.y));
_bind_quad_buffer();
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
void RasterizerCanvasBaseOpenGL::_set_texture_rect_mode(bool p_texture_rect, bool p_light_angle, bool p_modulate, bool p_large_vertex) {
void RasterizerCanvasBaseGLES3::_set_texture_rect_mode(bool p_texture_rect, bool p_light_angle, bool p_modulate, bool p_large_vertex) {
// always set this directly (this could be state checked)
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_TEXTURE_RECT, p_texture_rect);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_TEXTURE_RECT, p_texture_rect);
if (state.using_light_angle != p_light_angle) {
state.using_light_angle = p_light_angle;
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_LIGHT_ANGLE, p_light_angle);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_ATTRIB_LIGHT_ANGLE, p_light_angle);
}
if (state.using_modulate != p_modulate) {
state.using_modulate = p_modulate;
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_MODULATE, p_modulate);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_ATTRIB_MODULATE, p_modulate);
}
if (state.using_large_vertex != p_large_vertex) {
state.using_large_vertex = p_large_vertex;
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_LARGE_VERTEX, p_large_vertex);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_ATTRIB_LARGE_VERTEX, p_large_vertex);
}
}
RasterizerStorageOpenGL::Texture *RasterizerCanvasBaseOpenGL::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) {
RasterizerStorageOpenGL::Texture *tex_return = NULL;
RasterizerStorageGLES3::Texture *RasterizerCanvasBaseGLES3::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) {
RasterizerStorageGLES3::Texture *tex_return = NULL;
if (p_texture.is_valid()) {
RasterizerStorageOpenGL::Texture *texture = storage->texture_owner.get_or_null(p_texture);
RasterizerStorageGLES3::Texture *texture = storage->texture_owner.get_or_null(p_texture);
if (!texture) {
state.current_tex = RID();
@ -302,16 +320,16 @@ RasterizerStorageOpenGL::Texture *RasterizerCanvasBaseOpenGL::_bind_canvas_textu
if (p_normal_map == state.current_normal) {
//do none
state.canvas_shader.set_uniform(CanvasShaderOpenGL::USE_DEFAULT_NORMAL, state.current_normal.is_valid());
state.canvas_shader.set_uniform(CanvasShaderGLES3::USE_DEFAULT_NORMAL, state.current_normal.is_valid());
} else if (p_normal_map.is_valid()) {
RasterizerStorageOpenGL::Texture *normal_map = storage->texture_owner.get_or_null(p_normal_map);
RasterizerStorageGLES3::Texture *normal_map = storage->texture_owner.get_or_null(p_normal_map);
if (!normal_map) {
state.current_normal = RID();
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2);
glBindTexture(GL_TEXTURE_2D, storage->resources.normal_tex);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::USE_DEFAULT_NORMAL, false);
state.canvas_shader.set_uniform(CanvasShaderGLES3::USE_DEFAULT_NORMAL, false);
} else {
if (normal_map->redraw_if_visible) { //check before proxy, because this is usually used with proxies
@ -323,21 +341,21 @@ RasterizerStorageOpenGL::Texture *RasterizerCanvasBaseOpenGL::_bind_canvas_textu
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2);
glBindTexture(GL_TEXTURE_2D, normal_map->tex_id);
state.current_normal = p_normal_map;
state.canvas_shader.set_uniform(CanvasShaderOpenGL::USE_DEFAULT_NORMAL, true);
state.canvas_shader.set_uniform(CanvasShaderGLES3::USE_DEFAULT_NORMAL, true);
}
} else {
state.current_normal = RID();
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2);
glBindTexture(GL_TEXTURE_2D, storage->resources.normal_tex);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::USE_DEFAULT_NORMAL, false);
state.canvas_shader.set_uniform(CanvasShaderGLES3::USE_DEFAULT_NORMAL, false);
}
return tex_return;
}
/*
void RasterizerCanvasBaseOpenGL::draw_window_margins(int *black_margin, RID *black_image) {
void RasterizerCanvasBaseGLES3::draw_window_margins(int *black_margin, RID *black_image) {
return;
// FTODO
@ -409,74 +427,72 @@ void RasterizerCanvasBaseOpenGL::draw_window_margins(int *black_margin, RID *bla
}
*/
void RasterizerCanvasBaseOpenGL::_bind_quad_buffer() {
glBindBuffer(GL_ARRAY_BUFFER, data.canvas_quad_vertices);
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 0, NULL);
void RasterizerCanvasBaseGLES3::_bind_quad_buffer() {
glBindVertexArray(data.canvas_quad_array);
}
void RasterizerCanvasBaseOpenGL::_set_uniforms() {
state.canvas_shader.set_uniform(CanvasShaderOpenGL::PROJECTION_MATRIX, state.uniforms.projection_matrix);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::EXTRA_MATRIX, state.uniforms.extra_matrix);
void RasterizerCanvasBaseGLES3::_set_uniforms() {
state.canvas_shader.set_uniform(CanvasShaderGLES3::PROJECTION_MATRIX, state.uniforms.projection_matrix);
state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX, state.uniforms.extra_matrix);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::FINAL_MODULATE, state.uniforms.final_modulate);
state.canvas_shader.set_uniform(CanvasShaderGLES3::FINAL_MODULATE, state.uniforms.final_modulate);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::TIME, storage->frame.time[0]);
state.canvas_shader.set_uniform(CanvasShaderGLES3::TIME, storage->frame.time[0]);
if (storage->frame.current_rt) {
Vector2 screen_pixel_size;
screen_pixel_size.x = 1.0 / storage->frame.current_rt->width;
screen_pixel_size.y = 1.0 / storage->frame.current_rt->height;
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SCREEN_PIXEL_SIZE, screen_pixel_size);
state.canvas_shader.set_uniform(CanvasShaderGLES3::SCREEN_PIXEL_SIZE, screen_pixel_size);
}
if (state.using_skeleton) {
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SKELETON_TRANSFORM, state.skeleton_transform);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SKELETON_TRANSFORM_INVERSE, state.skeleton_transform_inverse);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SKELETON_TEXTURE_SIZE, state.skeleton_texture_size);
state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TRANSFORM, state.skeleton_transform);
state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TRANSFORM_INVERSE, state.skeleton_transform_inverse);
state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TEXTURE_SIZE, state.skeleton_texture_size);
}
if (state.using_light) {
Light *light = state.using_light;
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_MATRIX, light->light_shader_xform);
state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_MATRIX, light->light_shader_xform);
Transform2D basis_inverse = light->light_shader_xform.affine_inverse().orthonormalized();
basis_inverse.elements[2] = Vector2();
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_MATRIX_INVERSE, basis_inverse);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_LOCAL_MATRIX, light->xform_cache.affine_inverse());
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_COLOR, light->color * light->energy);
// state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_POS, light->light_shader_pos);
state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_MATRIX_INVERSE, basis_inverse);
state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_LOCAL_MATRIX, light->xform_cache.affine_inverse());
state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_COLOR, light->color * light->energy);
// state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_POS, light->light_shader_pos);
// FTODO
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_POS, light->light_shader_xform.elements[2]);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_HEIGHT, light->height);
state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_POS, light->light_shader_xform.elements[2]);
state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_HEIGHT, light->height);
// FTODO
//state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_OUTSIDE_ALPHA, light->mode == RS::CANVAS_LIGHT_MODE_MASK ? 1.0 : 0.0);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_OUTSIDE_ALPHA, 0.0f);
//state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_OUTSIDE_ALPHA, light->mode == RS::CANVAS_LIGHT_MODE_MASK ? 1.0 : 0.0);
state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_OUTSIDE_ALPHA, 0.0f);
if (state.using_shadow) {
// FTODO
#if 0
RasterizerStorageOpenGL::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(light->shadow_buffer);
RasterizerStorageGLES3::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(light->shadow_buffer);
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 5);
glBindTexture(GL_TEXTURE_2D, cls->distance);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOW_MATRIX, light->shadow_matrix_cache);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_SHADOW_COLOR, light->shadow_color);
state.canvas_shader.set_uniform(CanvasShaderGLES3::SHADOW_MATRIX, light->shadow_matrix_cache);
state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_SHADOW_COLOR, light->shadow_color);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOWPIXEL_SIZE, (1.0 / light->shadow_buffer_size) * (1.0 + light->shadow_smooth));
state.canvas_shader.set_uniform(CanvasShaderGLES3::SHADOWPIXEL_SIZE, (1.0 / light->shadow_buffer_size) * (1.0 + light->shadow_smooth));
if (light->radius_cache == 0) {
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOW_GRADIENT, 0.0);
state.canvas_shader.set_uniform(CanvasShaderGLES3::SHADOW_GRADIENT, 0.0);
} else {
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOW_GRADIENT, light->shadow_gradient_length / (light->radius_cache * 1.1));
state.canvas_shader.set_uniform(CanvasShaderGLES3::SHADOW_GRADIENT, light->shadow_gradient_length / (light->radius_cache * 1.1));
}
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOW_DISTANCE_MULT, light->radius_cache * 1.1);
state.canvas_shader.set_uniform(CanvasShaderGLES3::SHADOW_DISTANCE_MULT, light->radius_cache * 1.1);
#endif
}
}
}
void RasterizerCanvasBaseOpenGL::reset_canvas() {
void RasterizerCanvasBaseGLES3::reset_canvas() {
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
glDisable(GL_SCISSOR_TEST);
@ -502,10 +518,10 @@ void RasterizerCanvasBaseOpenGL::reset_canvas() {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void RasterizerCanvasBaseOpenGL::canvas_debug_viewport_shadows(Light *p_lights_with_shadow) {
void RasterizerCanvasBaseGLES3::canvas_debug_viewport_shadows(Light *p_lights_with_shadow) {
}
void RasterizerCanvasBaseOpenGL::_copy_texscreen(const Rect2 &p_rect) {
void RasterizerCanvasBaseGLES3::_copy_texscreen(const Rect2 &p_rect) {
state.canvas_texscreen_used = true;
_copy_screen(p_rect);
@ -517,7 +533,8 @@ void RasterizerCanvasBaseOpenGL::_copy_texscreen(const Rect2 &p_rect) {
_set_uniforms();
}
void RasterizerCanvasBaseOpenGL::_draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights, const int *p_bones) {
void RasterizerCanvasBaseGLES3::_draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights, const int *p_bones) {
glBindVertexArray(data.polygon_buffer_pointer_array);
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
uint32_t buffer_ofs = 0;
@ -593,12 +610,13 @@ void RasterizerCanvasBaseOpenGL::_draw_polygon(const int *p_indices, int p_index
glDrawElements(GL_TRIANGLES, p_index_count, GL_UNSIGNED_SHORT, 0);
storage->info.render._2d_draw_call_count++;
}
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void RasterizerCanvasBaseOpenGL::_draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
void RasterizerCanvasBaseGLES3::_draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
glBindVertexArray(data.polygon_buffer_pointer_array);
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
uint32_t buffer_ofs = 0;
@ -638,10 +656,12 @@ void RasterizerCanvasBaseOpenGL::_draw_generic(GLuint p_primitive, int p_vertex_
glDrawArrays(p_primitive, 0, p_vertex_count);
storage->info.render._2d_draw_call_count++;
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void RasterizerCanvasBaseOpenGL::_draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
void RasterizerCanvasBaseGLES3::_draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
glBindVertexArray(data.polygon_buffer_pointer_array);
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
uint32_t buffer_ofs = 0;
@ -706,12 +726,12 @@ void RasterizerCanvasBaseOpenGL::_draw_generic_indices(GLuint p_primitive, const
glDrawElements(p_primitive, p_index_count, GL_UNSIGNED_SHORT, 0);
storage->info.render._2d_draw_call_count++;
}
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void RasterizerCanvasBaseOpenGL::_legacy_draw_poly_triangles(Item::CommandPolygon *p_poly, RasterizerStorageOpenGL::Material *p_material) {
void RasterizerCanvasBaseGLES3::_legacy_draw_poly_triangles(Item::CommandPolygon *p_poly, RasterizerStorageGLES3::Material *p_material) {
// return;
const PolyData &pd = _polydata[p_poly->polygon.polygon_id];
@ -724,12 +744,12 @@ void RasterizerCanvasBaseOpenGL::_legacy_draw_poly_triangles(Item::CommandPolygo
}
// FTODO
//RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(polygon->texture, polygon->normal_map);
RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(p_poly->texture, RID());
//RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(polygon->texture, polygon->normal_map);
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(p_poly->texture, RID());
if (texture) {
Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size);
state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size);
}
_draw_polygon(pd.indices.ptr(), pd.indices.size(), pd.points.size(), pd.points.ptr(), pd.uvs.ptr(), pd.colors.ptr(), pd.colors.size() == 1, nullptr, nullptr);
@ -750,7 +770,7 @@ void RasterizerCanvasBaseOpenGL::_legacy_draw_poly_triangles(Item::CommandPolygo
#endif
}
void RasterizerCanvasBaseOpenGL::_legacy_draw_primitive(Item::CommandPrimitive *p_pr, RasterizerStorageOpenGL::Material *p_material) {
void RasterizerCanvasBaseGLES3::_legacy_draw_primitive(Item::CommandPrimitive *p_pr, RasterizerStorageGLES3::Material *p_material) {
// return;
if (p_pr->point_count != 4)
@ -768,12 +788,12 @@ void RasterizerCanvasBaseOpenGL::_legacy_draw_primitive(Item::CommandPrimitive *
glDisableVertexAttribArray(RS::ARRAY_COLOR);
glVertexAttrib4fv(RS::ARRAY_COLOR, p_pr->colors[0].components);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
_draw_gui_primitive(p_pr->point_count, p_pr->points, NULL, NULL);
}
void RasterizerCanvasBaseOpenGL::_legacy_draw_line(Item::CommandPrimitive *p_pr, RasterizerStorageOpenGL::Material *p_material) {
void RasterizerCanvasBaseGLES3::_legacy_draw_line(Item::CommandPrimitive *p_pr, RasterizerStorageGLES3::Material *p_material) {
_set_texture_rect_mode(false);
if (state.canvas_shader.bind()) {
@ -786,7 +806,7 @@ void RasterizerCanvasBaseOpenGL::_legacy_draw_line(Item::CommandPrimitive *p_pr,
glDisableVertexAttribArray(RS::ARRAY_COLOR);
glVertexAttrib4fv(RS::ARRAY_COLOR, p_pr->colors[0].components);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
#ifdef GLES_OVER_GL
// if (line->antialiased)
@ -800,25 +820,29 @@ void RasterizerCanvasBaseOpenGL::_legacy_draw_line(Item::CommandPrimitive *p_pr,
#endif
}
void RasterizerCanvasBaseOpenGL::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs, const float *p_light_angles) {
void RasterizerCanvasBaseGLES3::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs, const float *p_light_angles) {
static const GLenum prim[5] = { GL_POINTS, GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN };
int version = 0;
int color_offset = 0;
int uv_offset = 0;
int light_angle_offset = 0;
int stride = 2;
if (p_colors) {
version |= 1;
color_offset = stride;
stride += 4;
}
if (p_uvs) {
version |= 2;
uv_offset = stride;
stride += 2;
}
if (p_light_angles) { //light_angles
version |= 4;
light_angle_offset = stride;
stride += 1;
}
@ -856,35 +880,15 @@ void RasterizerCanvasBaseOpenGL::_draw_gui_primitive(int p_points, const Vector2
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
storage->buffer_orphan_and_upload(data.polygon_buffer_size, 0, p_points * stride * 4 * sizeof(float), buffer_data, GL_ARRAY_BUFFER, _buffer_upload_usage_flag, true);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), NULL);
if (p_colors) {
glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(color_offset * sizeof(float)));
glEnableVertexAttribArray(RS::ARRAY_COLOR);
}
if (p_uvs) {
glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(uv_offset * sizeof(float)));
glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
}
if (p_light_angles) {
glVertexAttribPointer(RS::ARRAY_TANGENT, 1, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(light_angle_offset * sizeof(float)));
glEnableVertexAttribArray(RS::ARRAY_TANGENT);
}
glBindVertexArray(data.polygon_buffer_quad_arrays[version]);
glDrawArrays(prim[p_points], 0, p_points);
storage->info.render._2d_draw_call_count++;
if (p_light_angles) {
// may not be needed
glDisableVertexAttribArray(RS::ARRAY_TANGENT);
}
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void RasterizerCanvasBaseOpenGL::_copy_screen(const Rect2 &p_rect) {
void RasterizerCanvasBaseGLES3::_copy_screen(const Rect2 &p_rect) {
if (storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) {
ERR_PRINT_ONCE("Cannot use screen texture copying in render target set to render direct to screen.");
return;
@ -899,17 +903,17 @@ void RasterizerCanvasBaseOpenGL::_copy_screen(const Rect2 &p_rect) {
Color copy_section(p_rect.position.x / wh.x, p_rect.position.y / wh.y, p_rect.size.x / wh.x, p_rect.size.y / wh.y);
if (p_rect != Rect2()) {
storage->shaders.copy.set_conditional(CopyShaderOpenGL::USE_COPY_SECTION, true);
storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_COPY_SECTION, true);
}
storage->shaders.copy.set_conditional(CopyShaderOpenGL::USE_NO_ALPHA, !state.using_transparent_rt);
storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_NO_ALPHA, !state.using_transparent_rt);
storage->bind_framebuffer(storage->frame.current_rt->copy_screen_effect.fbo);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color);
storage->shaders.copy.bind();
storage->shaders.copy.set_uniform(CopyShaderOpenGL::COPY_SECTION, copy_section);
storage->shaders.copy.set_uniform(CopyShaderGLES3::COPY_SECTION, copy_section);
const Vector2 vertpos[4] = {
Vector2(-1, -1),
@ -932,16 +936,16 @@ void RasterizerCanvasBaseOpenGL::_copy_screen(const Rect2 &p_rect) {
_draw_polygon(indexpos, 6, 4, vertpos, uvpos, NULL, false);
storage->shaders.copy.set_conditional(CopyShaderOpenGL::USE_COPY_SECTION, false);
storage->shaders.copy.set_conditional(CopyShaderOpenGL::USE_NO_ALPHA, false);
storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_COPY_SECTION, false);
storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_NO_ALPHA, false);
storage->bind_framebuffer(storage->frame.current_rt->fbo);
glEnable(GL_BLEND);
}
void RasterizerCanvasBaseOpenGL::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {
void RasterizerCanvasBaseGLES3::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {
#if 0
RasterizerStorageOpenGL::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(p_buffer);
RasterizerStorageGLES3::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(p_buffer);
ERR_FAIL_COND(!cls);
glDisable(GL_BLEND);
@ -954,7 +958,7 @@ void RasterizerCanvasBaseOpenGL::canvas_light_shadow_buffer_update(RID p_buffer,
glBindFramebuffer(GL_FRAMEBUFFER, cls->fbo);
state.canvas_shadow_shader.set_conditional(CanvasShadowShaderOpenGL::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows);
state.canvas_shadow_shader.set_conditional(CanvasShadowShaderGLES3::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows);
state.canvas_shadow_shader.bind();
glViewport(0, 0, cls->size, cls->height);
@ -996,9 +1000,9 @@ void RasterizerCanvasBaseOpenGL::canvas_light_shadow_buffer_update(RID p_buffer,
Vector3 cam_target = Basis(Vector3(0, 0, Math_PI * 2 * (i / 4.0))).xform(Vector3(0, 1, 0));
projection = projection * CameraMatrix(Transform3D().looking_at(cam_target, Vector3(0, 0, -1)).affine_inverse());
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderOpenGL::PROJECTION_MATRIX, projection);
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderOpenGL::LIGHT_MATRIX, light);
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderOpenGL::DISTANCE_NORM, 1.0 / p_far);
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES3::PROJECTION_MATRIX, projection);
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES3::LIGHT_MATRIX, light);
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES3::DISTANCE_NORM, 1.0 / p_far);
if (i == 0)
*p_xform_cache = projection;
@ -1008,13 +1012,13 @@ void RasterizerCanvasBaseOpenGL::canvas_light_shadow_buffer_update(RID p_buffer,
LightOccluderInstance *instance = p_occluders;
while (instance) {
RasterizerStorageOpenGL::CanvasOccluder *cc = storage->canvas_occluder_owner.get_or_null(instance->polygon_buffer);
RasterizerStorageGLES3::CanvasOccluder *cc = storage->canvas_occluder_owner.get_or_null(instance->polygon_buffer);
if (!cc || cc->len == 0 || !(p_light_mask & instance->light_mask)) {
instance = instance->next;
continue;
}
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderOpenGL::WORLD_MATRIX, instance->xform_cache);
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES3::WORLD_MATRIX, instance->xform_cache);
RS::CanvasOccluderPolygonCullMode transformed_cull_cache = instance->cull_cache;
@ -1061,7 +1065,7 @@ void RasterizerCanvasBaseOpenGL::canvas_light_shadow_buffer_update(RID p_buffer,
#endif
}
void RasterizerCanvasBaseOpenGL::draw_lens_distortion_rect(const Rect2 &p_rect, float p_k1, float p_k2, const Vector2 &p_eye_center, float p_oversample) {
void RasterizerCanvasBaseGLES3::draw_lens_distortion_rect(const Rect2 &p_rect, float p_k1, float p_k2, const Vector2 &p_eye_center, float p_oversample) {
Vector2 half_size;
if (storage->frame.current_rt) {
half_size = Vector2(storage->frame.current_rt->width, storage->frame.current_rt->height);
@ -1077,13 +1081,13 @@ void RasterizerCanvasBaseOpenGL::draw_lens_distortion_rect(const Rect2 &p_rect,
// setup our lens shader
state.lens_shader.bind();
state.lens_shader.set_uniform(LensDistortedShaderOpenGL::OFFSET, offset);
state.lens_shader.set_uniform(LensDistortedShaderOpenGL::SCALE, scale);
state.lens_shader.set_uniform(LensDistortedShaderOpenGL::K1, p_k1);
state.lens_shader.set_uniform(LensDistortedShaderOpenGL::K2, p_k2);
state.lens_shader.set_uniform(LensDistortedShaderOpenGL::EYE_CENTER, p_eye_center);
state.lens_shader.set_uniform(LensDistortedShaderOpenGL::UPSCALE, p_oversample);
state.lens_shader.set_uniform(LensDistortedShaderOpenGL::ASPECT_RATIO, aspect_ratio);
state.lens_shader.set_uniform(LensDistortedShaderGLES3::OFFSET, offset);
state.lens_shader.set_uniform(LensDistortedShaderGLES3::SCALE, scale);
state.lens_shader.set_uniform(LensDistortedShaderGLES3::K1, p_k1);
state.lens_shader.set_uniform(LensDistortedShaderGLES3::K2, p_k2);
state.lens_shader.set_uniform(LensDistortedShaderGLES3::EYE_CENTER, p_eye_center);
state.lens_shader.set_uniform(LensDistortedShaderGLES3::UPSCALE, p_oversample);
state.lens_shader.set_uniform(LensDistortedShaderGLES3::ASPECT_RATIO, aspect_ratio);
// bind our quad buffer
_bind_quad_buffer();
@ -1093,13 +1097,9 @@ void RasterizerCanvasBaseOpenGL::draw_lens_distortion_rect(const Rect2 &p_rect,
// and cleanup
glBindBuffer(GL_ARRAY_BUFFER, 0);
for (int i = 0; i < RS::ARRAY_MAX; i++) {
glDisableVertexAttribArray(i);
}
}
void RasterizerCanvasBaseOpenGL::initialize() {
void RasterizerCanvasBaseGLES3::initialize() {
bool flag_stream = false;
//flag_stream = GLOBAL_GET("rendering/options/api_usage_legacy/flag_stream");
if (flag_stream)
@ -1122,29 +1122,119 @@ void RasterizerCanvasBaseOpenGL::initialize() {
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 8, qv, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenVertexArrays(1, &data.canvas_quad_array);
glBindVertexArray(data.canvas_quad_array);
glBindBuffer(GL_ARRAY_BUFFER, data.canvas_quad_vertices);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);
glEnableVertexAttribArray(0);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
}
{
//particle quad buffers
glGenBuffers(1, &data.particle_quad_vertices);
glBindBuffer(GL_ARRAY_BUFFER, data.particle_quad_vertices);
{
//quad of size 1, with pivot on the center for particles, then regular UVS. Color is general plus fetched from particle
const float qv[16] = {
-0.5, -0.5,
0.0, 0.0,
-0.5, 0.5,
0.0, 1.0,
0.5, 0.5,
1.0, 1.0,
0.5, -0.5,
1.0, 0.0
};
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 16, qv, GL_STATIC_DRAW);
}
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
glGenVertexArrays(1, &data.particle_quad_array);
glBindVertexArray(data.particle_quad_array);
glBindBuffer(GL_ARRAY_BUFFER, data.particle_quad_vertices);
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, nullptr);
glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(8));
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
}
// polygon buffer
{
uint32_t poly_size = GLOBAL_DEF("rendering/limits/buffers/canvas_polygon_buffer_size_kb", 128);
uint32_t poly_size = 128; //GLOBAL_DEF_RST("rendering/limits/buffers/canvas_polygon_buffer_size_kb", 128);
ProjectSettings::get_singleton()->set_custom_property_info("rendering/limits/buffers/canvas_polygon_buffer_size_kb", PropertyInfo(Variant::INT, "rendering/limits/buffers/canvas_polygon_buffer_size_kb", PROPERTY_HINT_RANGE, "0,256,1,or_greater"));
poly_size = MAX(poly_size, 128); // minimum 2k, may still see anomalies in editor
poly_size *= 1024;
poly_size = MAX(poly_size, 2); // minimum 2k, may still see anomalies in editor
poly_size *= 1024; //kb
glGenBuffers(1, &data.polygon_buffer);
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
glBufferData(GL_ARRAY_BUFFER, poly_size, NULL, GL_DYNAMIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, poly_size, nullptr, GL_DYNAMIC_DRAW); //allocate max size
glBindBuffer(GL_ARRAY_BUFFER, 0);
data.polygon_buffer_size = poly_size;
glBindBuffer(GL_ARRAY_BUFFER, 0);
//quad arrays
for (int i = 0; i < Data::NUM_QUAD_ARRAY_VARIATIONS; i++) {
glGenVertexArrays(1, &data.polygon_buffer_quad_arrays[i]);
glBindVertexArray(data.polygon_buffer_quad_arrays[i]);
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
uint32_t index_size = GLOBAL_DEF("rendering/limits/buffers/canvas_polygon_index_buffer_size_kb", 128);
int uv_ofs = 0;
int color_ofs = 0;
int light_angle_ofs = 0;
int stride = 2 * 4;
if (i & 1) { //color
color_ofs = stride;
stride += 4 * 4;
}
if (i & 2) { //uv
uv_ofs = stride;
stride += 2 * 4;
}
if (i & 4) { //light_angle
light_angle_ofs = stride;
stride += 1 * 4;
}
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride, nullptr);
if (i & 1) {
glEnableVertexAttribArray(RS::ARRAY_COLOR);
glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(color_ofs));
}
if (i & 2) {
glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(uv_ofs));
}
if (i & 4) {
// reusing tangent for light_angle
glEnableVertexAttribArray(RS::ARRAY_TANGENT);
glVertexAttribPointer(RS::ARRAY_TANGENT, 1, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(light_angle_ofs));
}
glBindVertexArray(0);
}
glGenVertexArrays(1, &data.polygon_buffer_pointer_array);
uint32_t index_size = 128; //GLOBAL_DEF_RST("rendering/limits/buffers/canvas_polygon_index_buffer_size_kb", 128);
ProjectSettings::get_singleton()->set_custom_property_info("rendering/limits/buffers/canvas_polygon_index_buffer_size_kb", PropertyInfo(Variant::INT, "rendering/limits/buffers/canvas_polygon_index_buffer_size_kb", PROPERTY_HINT_RANGE, "0,256,1,or_greater"));
index_size = MAX(index_size, 128);
index_size *= 1024; // kb
index_size = MAX(index_size, 2);
index_size *= 1024; //kb
glGenBuffers(1, &data.polygon_index_buffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_size, NULL, GL_DYNAMIC_DRAW);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_size, nullptr, GL_DYNAMIC_DRAW); //allocate max size
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
data.polygon_index_buffer_size = index_size;
@ -1212,25 +1302,30 @@ void RasterizerCanvasBaseOpenGL::initialize() {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
store_transform3d(Transform3D(), state.canvas_item_ubo_data.projection_matrix);
glGenBuffers(1, &state.canvas_item_ubo);
glBindBuffer(GL_UNIFORM_BUFFER, state.canvas_item_ubo);
glBufferData(GL_UNIFORM_BUFFER, sizeof(CanvasItemUBO), &state.canvas_item_ubo_data, GL_DYNAMIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
state.canvas_shadow_shader.init();
state.canvas_shader.init();
_set_texture_rect_mode(true);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows);
state.canvas_shader.bind();
state.lens_shader.init();
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/quality/2d/use_pixel_snap", false));
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/quality/2d/use_pixel_snap", false));
state.using_light = NULL;
state.using_transparent_rt = false;
state.using_skeleton = false;
}
RendererCanvasRender::PolygonID RasterizerCanvasBaseOpenGL::request_polygon(const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights) {
RendererCanvasRender::PolygonID RasterizerCanvasBaseGLES3::request_polygon(const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights) {
uint32_t id = _polydata.alloc();
PolyData &pd = _polydata[id];
pd.indices = p_indices;
@ -1239,14 +1334,21 @@ RendererCanvasRender::PolygonID RasterizerCanvasBaseOpenGL::request_polygon(cons
pd.uvs = p_uvs;
return id;
}
void RasterizerCanvasBaseOpenGL::free_polygon(PolygonID p_polygon) {
void RasterizerCanvasBaseGLES3::free_polygon(PolygonID p_polygon) {
_polydata.free(p_polygon);
}
void RasterizerCanvasBaseOpenGL::finalize() {
void RasterizerCanvasBaseGLES3::finalize() {
glDeleteBuffers(1, &data.canvas_quad_vertices);
glDeleteVertexArrays(1, &data.canvas_quad_array);
glDeleteBuffers(1, &data.canvas_quad_vertices);
glDeleteVertexArrays(1, &data.canvas_quad_array);
glDeleteVertexArrays(1, &data.polygon_buffer_pointer_array);
}
RasterizerCanvasBaseOpenGL::RasterizerCanvasBaseOpenGL() {
RasterizerCanvasBaseGLES3::RasterizerCanvasBaseGLES3() {
}
#endif // OPENGL_BACKEND_ENABLED
#endif // GLES3_BACKEND_ENABLED

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* rasterizer_canvas_base_opengl.h */
/* rasterizer_canvas_base_gles3.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -31,13 +31,13 @@
#ifndef RASTERIZER_CANVAS_BASE_OPENGL_H
#define RASTERIZER_CANVAS_BASE_OPENGL_H
#include "drivers/opengl/rasterizer_platforms.h"
#ifdef OPENGL_BACKEND_ENABLED
#include "drivers/gles3/rasterizer_platforms.h"
#ifdef GLES3_BACKEND_ENABLED
#include "drivers/opengl/rasterizer_array.h"
#include "drivers/opengl/rasterizer_storage_common.h"
#include "rasterizer_scene_opengl.h"
#include "rasterizer_storage_opengl.h"
#include "drivers/gles3/rasterizer_array.h"
#include "drivers/gles3/rasterizer_storage_common.h"
#include "rasterizer_scene_gles3.h"
#include "rasterizer_storage_gles3.h"
#include "servers/rendering/renderer_canvas_render.h"
#include "servers/rendering/renderer_compositor.h"
@ -45,7 +45,7 @@
#include "shaders/canvas_shadow.glsl.gen.h"
#include "shaders/lens_distorted.glsl.gen.h"
class RasterizerCanvasBaseOpenGL : public RendererCanvasRender {
class RasterizerCanvasBaseGLES3 : public RendererCanvasRender {
public:
enum {
INSTANCE_ATTRIB_BASE = 8,
@ -62,11 +62,26 @@ public:
float time;
};
struct CanvasItemUBO {
float projection_matrix[16];
float time;
uint8_t padding[12];
};
struct Data {
enum { NUM_QUAD_ARRAY_VARIATIONS = 8 };
GLuint canvas_quad_vertices;
GLuint canvas_quad_array;
GLuint polygon_buffer;
GLuint polygon_buffer_quad_arrays[NUM_QUAD_ARRAY_VARIATIONS];
GLuint polygon_buffer_pointer_array;
GLuint polygon_index_buffer;
GLuint particle_quad_vertices;
GLuint particle_quad_array;
uint32_t polygon_buffer_size;
uint32_t polygon_index_buffer_size;
@ -76,10 +91,12 @@ public:
struct State {
Uniforms uniforms;
CanvasItemUBO canvas_item_ubo_data;
GLuint canvas_item_ubo;
bool canvas_texscreen_used;
CanvasShaderOpenGL canvas_shader;
CanvasShadowShaderOpenGL canvas_shadow_shader;
LensDistortedShaderOpenGL lens_shader;
CanvasShaderGLES3 canvas_shader;
CanvasShadowShaderGLES3 canvas_shadow_shader;
LensDistortedShaderGLES3 lens_shader;
bool using_texture_rect;
@ -96,7 +113,7 @@ public:
RID current_tex;
RID current_normal;
RasterizerStorageOpenGL::Texture *current_tex_ptr;
RasterizerStorageGLES3::Texture *current_tex_ptr;
Transform3D vp;
Light *using_light;
@ -111,9 +128,9 @@ public:
typedef void Texture;
RasterizerSceneOpenGL *scene_render;
RasterizerSceneGLES3 *scene_render;
RasterizerStorageOpenGL *storage;
RasterizerStorageGLES3 *storage;
// allow user to choose api usage
GLenum _buffer_upload_usage_flag;
@ -128,9 +145,9 @@ public:
virtual void canvas_end();
protected:
void _legacy_draw_primitive(Item::CommandPrimitive *p_pr, RasterizerStorageOpenGL::Material *p_material);
void _legacy_draw_line(Item::CommandPrimitive *p_pr, RasterizerStorageOpenGL::Material *p_material);
void _legacy_draw_poly_triangles(Item::CommandPolygon *p_poly, RasterizerStorageOpenGL::Material *p_material);
void _legacy_draw_primitive(Item::CommandPrimitive *p_pr, RasterizerStorageGLES3::Material *p_material);
void _legacy_draw_line(Item::CommandPrimitive *p_pr, RasterizerStorageGLES3::Material *p_material);
void _legacy_draw_poly_triangles(Item::CommandPolygon *p_poly, RasterizerStorageGLES3::Material *p_material);
public:
void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs, const float *p_light_angles = nullptr);
@ -168,7 +185,7 @@ public:
void update() override;
// End copied from RasterizerCanvasDummy.
RasterizerStorageOpenGL::Texture *_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map);
RasterizerStorageGLES3::Texture *_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map);
void _set_texture_rect_mode(bool p_texture_rect, bool p_light_angle = false, bool p_modulate = false, bool p_large_vertex = false);
// NEW API
@ -188,9 +205,9 @@ public:
void initialize();
void finalize();
RasterizerCanvasBaseOpenGL();
RasterizerCanvasBaseGLES3();
};
#endif // OPENGL_BACKEND_ENABLED
#endif // GLES3_BACKEND_ENABLED
#endif // RASTERIZER_CANVAS_BASE_OPENGL_H

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* rasterizer_canvas_opengl.cpp */
/* rasterizer_canvas_gles3.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "rasterizer_canvas_opengl.h"
#include "drivers/opengl/rasterizer_platforms.h"
#ifdef OPENGL_BACKEND_ENABLED
#include "rasterizer_canvas_gles3.h"
#include "drivers/gles3/rasterizer_platforms.h"
#ifdef GLES3_BACKEND_ENABLED
#include "core/os/os.h"
#include "drivers/opengl/rasterizer_asserts.h"
#include "rasterizer_scene_opengl.h"
#include "rasterizer_storage_opengl.h"
#include "drivers/gles3/rasterizer_asserts.h"
#include "rasterizer_scene_gles3.h"
#include "rasterizer_storage_gles3.h"
#include "core/config/project_settings.h"
#include "servers/rendering/rendering_server_default.h"
@ -51,7 +51,7 @@
//};
#if 0
void RasterizerCanvasOpenGL::_batch_upload_buffers() {
void RasterizerCanvasGLES3::_batch_upload_buffers() {
// noop?
if (!bdata.vertices.size())
return;
@ -93,7 +93,7 @@ void RasterizerCanvasOpenGL::_batch_upload_buffers() {
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void RasterizerCanvasOpenGL::_batch_render_lines(const Batch &p_batch, RasterizerStorageOpenGL::Material *p_material, bool p_anti_alias) {
void RasterizerCanvasGLES3::_batch_render_lines(const Batch &p_batch, RasterizerStorageGLES3::Material *p_material, bool p_anti_alias) {
_set_texture_rect_mode(false);
if (state.canvas_shader.bind()) {
@ -139,7 +139,7 @@ void RasterizerCanvasOpenGL::_batch_render_lines(const Batch &p_batch, Rasterize
#endif
}
void RasterizerCanvasOpenGL::_batch_render_generic(const Batch &p_batch, RasterizerStorageOpenGL::Material *p_material) {
void RasterizerCanvasGLES3::_batch_render_generic(const Batch &p_batch, RasterizerStorageGLES3::Material *p_material) {
ERR_FAIL_COND(p_batch.num_commands <= 0);
const bool &use_light_angles = bdata.use_light_angles;
@ -183,7 +183,7 @@ void RasterizerCanvasOpenGL::_batch_render_generic(const Batch &p_batch, Rasteri
// force repeat is set if non power of 2 texture, and repeat is needed if hardware doesn't support npot
if (tex.tile_mode == BatchTex::TILE_FORCE_REPEAT) {
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_FORCE_REPEAT, true);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_FORCE_REPEAT, true);
}
if (state.canvas_shader.bind()) {
@ -234,7 +234,7 @@ void RasterizerCanvasOpenGL::_batch_render_generic(const Batch &p_batch, Rasteri
// This is an optimization left over from the legacy renderer.
// If we DID set tiling in the API, and reverted to clamped, then the next draw using this texture
// may use clamped mode incorrectly.
bool tex_is_already_tiled = tex.flags & RasterizerStorageOpenGL::TEXTURE_FLAG_REPEAT;
bool tex_is_already_tiled = tex.flags & RasterizerStorageGLES3::TEXTURE_FLAG_REPEAT;
if (tex.tile_mode == BatchTex::TILE_NORMAL) {
// if the texture is imported as tiled, no need to set GL state, as it will already be bound with repeat
@ -248,7 +248,7 @@ void RasterizerCanvasOpenGL::_batch_render_generic(const Batch &p_batch, Rasteri
// could use a cast but this might be unsafe in future
Vector2 tps;
tex.tex_pixel_size.to(tps);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, tps);
state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, tps);
switch (p_batch.type) {
default: {
@ -272,7 +272,7 @@ void RasterizerCanvasOpenGL::_batch_render_generic(const Batch &p_batch, Rasteri
switch (tex.tile_mode) {
case BatchTex::TILE_FORCE_REPEAT: {
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_FORCE_REPEAT, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_FORCE_REPEAT, false);
} break;
case BatchTex::TILE_NORMAL: {
// if the texture is imported as tiled, no need to revert GL state
@ -298,7 +298,7 @@ void RasterizerCanvasOpenGL::_batch_render_generic(const Batch &p_batch, Rasteri
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
#endif
void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, Item *p_current_clip, bool &r_reclip, RasterizerStorageOpenGL::Material *p_material) {
void RasterizerCanvasGLES3::render_batches(Item::Command *const *p_commands, Item *p_current_clip, bool &r_reclip, RasterizerStorageGLES3::Material *p_material) {
int num_batches = bdata.batches.size();
for (int batch_num = 0; batch_num < num_batches; batch_num++) {
@ -340,7 +340,7 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
glDisableVertexAttribArray(RS::ARRAY_COLOR);
glVertexAttrib4fv(RS::ARRAY_COLOR, line->color.components);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
if (line->width <= 1) {
Vector2 verts[2] = {
@ -401,7 +401,7 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
case Item::Command::TYPE_RECT: {
Item::CommandRect *r = static_cast<Item::CommandRect *>(command);
_bind_quad_buffer();
glDisableVertexAttribArray(RS::ARRAY_COLOR);
glVertexAttrib4fv(RS::ARRAY_COLOR, r->modulate.components);
@ -413,7 +413,7 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
// very inefficient, improve this
if (r->texture.is_valid()) {
RasterizerStorageOpenGL::Texture *texture = storage->texture_owner.get_or_null(r->texture);
RasterizerStorageGLES3::Texture *texture = storage->texture_owner.get_or_null(r->texture);
if (texture) {
if (texture->is_upside_down())
@ -424,13 +424,13 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
if (r->texture.is_valid() && r->flags & CANVAS_RECT_TILE && !storage->config.support_npot_repeat_mipmap) {
// workaround for when setting tiling does not work due to hardware limitation
RasterizerStorageOpenGL::Texture *texture = storage->texture_owner.get_or_null(r->texture);
RasterizerStorageGLES3::Texture *texture = storage->texture_owner.get_or_null(r->texture);
if (texture) {
texture = texture->get_ptr();
if (next_power_of_2(texture->alloc_width) != (unsigned int)texture->alloc_width && next_power_of_2(texture->alloc_height) != (unsigned int)texture->alloc_height) {
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_FORCE_REPEAT, true);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_FORCE_REPEAT, true);
can_tile = false;
}
}
@ -475,8 +475,8 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
}
// FTODO
//RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(r->texture, r->normal_map);
RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(r->texture, RID());
//RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(r->texture, r->normal_map);
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(r->texture, RID());
if (texture) {
Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height);
@ -510,11 +510,11 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
flip_v = !flip_v;
}
state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size);
state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size);
bool untile = false;
if (can_tile && r->flags & CANVAS_RECT_TILE && !(texture->flags & RasterizerStorageOpenGL::TEXTURE_FLAG_REPEAT)) {
if (can_tile && r->flags & CANVAS_RECT_TILE && !(texture->flags & RasterizerStorageGLES3::TEXTURE_FLAG_REPEAT)) {
texture->GLSetRepeat(RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
untile = true;
}
@ -558,13 +558,12 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
Vector2(1.0, 0.0),
};
state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, Vector2());
state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, Vector2());
_draw_gui_primitive(4, points, NULL, uvs);
}
} else {
// This branch is better for performance, but can produce flicker on Nvidia, see above comment.
_bind_quad_buffer();
_set_texture_rect_mode(true);
@ -572,10 +571,11 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
_set_uniforms();
state.canvas_shader.use_material((void *)p_material);
}
_bind_quad_buffer();
// FTODO
//RasterizerStorageOpenGL::Texture *tex = _bind_canvas_texture(r->texture, r->normal_map);
RasterizerStorageOpenGL::Texture *tex = _bind_canvas_texture(r->texture, RID());
//RasterizerStorageGLES3::Texture *tex = _bind_canvas_texture(r->texture, r->normal_map);
RasterizerStorageGLES3::Texture *tex = _bind_canvas_texture(r->texture, RID());
if (!tex) {
Rect2 dst_rect = Rect2(r->rect.position, r->rect.size);
@ -589,15 +589,15 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
dst_rect.size.height *= -1;
}
state.canvas_shader.set_uniform(CanvasShaderOpenGL::DST_RECT, Color(dst_rect.position.x, dst_rect.position.y, dst_rect.size.x, dst_rect.size.y));
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SRC_RECT, Color(0, 0, 1, 1));
state.canvas_shader.set_uniform(CanvasShaderGLES3::DST_RECT, Color(dst_rect.position.x, dst_rect.position.y, dst_rect.size.x, dst_rect.size.y));
state.canvas_shader.set_uniform(CanvasShaderGLES3::SRC_RECT, Color(0, 0, 1, 1));
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
storage->info.render._2d_draw_call_count++;
} else {
bool untile = false;
if (can_tile && r->flags & CANVAS_RECT_TILE && !(tex->flags & RasterizerStorageOpenGL::TEXTURE_FLAG_REPEAT)) {
if (can_tile && r->flags & CANVAS_RECT_TILE && !(tex->flags & RasterizerStorageGLES3::TEXTURE_FLAG_REPEAT)) {
tex->GLSetRepeat(RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
untile = true;
}
@ -628,10 +628,10 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
dst_rect.size.x *= -1; // Encoding in the dst_rect.z uniform
}
state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size);
state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::DST_RECT, Color(dst_rect.position.x, dst_rect.position.y, dst_rect.size.x, dst_rect.size.y));
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SRC_RECT, Color(src_rect.position.x, src_rect.position.y, src_rect.size.x, src_rect.size.y));
state.canvas_shader.set_uniform(CanvasShaderGLES3::DST_RECT, Color(dst_rect.position.x, dst_rect.position.y, dst_rect.size.x, dst_rect.size.y));
state.canvas_shader.set_uniform(CanvasShaderGLES3::SRC_RECT, Color(src_rect.position.x, src_rect.position.y, src_rect.size.x, src_rect.size.y));
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
storage->info.render._2d_draw_call_count++;
@ -645,7 +645,7 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_FORCE_REPEAT, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_FORCE_REPEAT, false);
} break;
case Item::Command::TYPE_NINEPATCH: {
@ -656,13 +656,14 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
_set_uniforms();
state.canvas_shader.use_material((void *)p_material);
}
_bind_quad_buffer();
glDisableVertexAttribArray(RS::ARRAY_COLOR);
glVertexAttrib4fv(RS::ARRAY_COLOR, np->color.components);
// FTODO
//RasterizerStorageOpenGL::Texture *tex = _bind_canvas_texture(np->texture, np->normal_map);
RasterizerStorageOpenGL::Texture *tex = _bind_canvas_texture(np->texture, RID());
//RasterizerStorageGLES3::Texture *tex = _bind_canvas_texture(np->texture, np->normal_map);
RasterizerStorageGLES3::Texture *tex = _bind_canvas_texture(np->texture, RID());
if (!tex) {
// FIXME: Handle textureless ninepatch gracefully
@ -676,8 +677,8 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
Size2 texpixel_size(1.0 / tex->width, 1.0 / tex->height);
// state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size);
// state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size);
Rect2 source = np->source;
if (source.size.x == 0 && source.size.y == 0) {
@ -809,13 +810,13 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.ninepatch_elements);
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
//glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), NULL);
//glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), NULL);
glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), CAST_INT_TO_UCHAR_PTR((sizeof(float) * 2)));
glDrawElements(GL_TRIANGLES, 18 * 3 - (np->draw_center ? 0 : 6), GL_UNSIGNED_BYTE, NULL);
//glDrawElements(GL_TRIANGLES, 18 * 3 - (np->draw_center ? 0 : 6), GL_UNSIGNED_SHORT, NULL);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
@ -876,17 +877,17 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
state.canvas_shader.use_material((void *)p_material);
}
RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(mesh->texture, mesh->normal_map);
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(mesh->texture, mesh->normal_map);
if (texture) {
Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size);
state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size);
}
RasterizerStorageOpenGL::Mesh *mesh_data = storage->mesh_owner.get_or_null(mesh->mesh);
RasterizerStorageGLES3::Mesh *mesh_data = storage->mesh_owner.get_or_null(mesh->mesh);
if (mesh_data) {
for (int j = 0; j < mesh_data->surfaces.size(); j++) {
RasterizerStorageOpenGL::Surface *s = mesh_data->surfaces[j];
RasterizerStorageGLES3::Surface *s = mesh_data->surfaces[j];
// materials are ignored in 2D meshes, could be added but many things (ie, lighting mode, reading from screen, etc) would break as they are not meant be set up at this point of drawing
glBindBuffer(GL_ARRAY_BUFFER, s->vertex_id);
@ -932,18 +933,18 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
case Item::Command::TYPE_MULTIMESH: {
Item::CommandMultiMesh *mmesh = static_cast<Item::CommandMultiMesh *>(command);
RasterizerStorageOpenGL::MultiMesh *multi_mesh = storage->multimesh_owner.get_or_null(mmesh->multimesh);
RasterizerStorageGLES3::MultiMesh *multi_mesh = storage->multimesh_owner.get_or_null(mmesh->multimesh);
if (!multi_mesh)
break;
RasterizerStorageOpenGL::Mesh *mesh_data = storage->mesh_owner.get_or_null(multi_mesh->mesh);
RasterizerStorageGLES3::Mesh *mesh_data = storage->mesh_owner.get_or_null(multi_mesh->mesh);
if (!mesh_data)
break;
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_INSTANCE_CUSTOM, multi_mesh->custom_data_format != RS::MULTIMESH_CUSTOM_DATA_NONE);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_INSTANCING, true);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCE_CUSTOM, multi_mesh->custom_data_format != RS::MULTIMESH_CUSTOM_DATA_NONE);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCING, true);
_set_texture_rect_mode(false);
if (state.canvas_shader.bind()) {
@ -951,11 +952,11 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
state.canvas_shader.use_material((void *)p_material);
}
RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(mmesh->texture, mmesh->normal_map);
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(mmesh->texture, mmesh->normal_map);
if (texture) {
Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size);
state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size);
}
//reset shader and force rebind
@ -976,7 +977,7 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
const float *base_buffer = multi_mesh->data.ptr();
for (int j = 0; j < mesh_data->surfaces.size(); j++) {
RasterizerStorageOpenGL::Surface *s = mesh_data->surfaces[j];
RasterizerStorageGLES3::Surface *s = mesh_data->surfaces[j];
// materials are ignored in 2D meshes, could be added but many things (ie, lighting mode, reading from screen, etc) would break as they are not meant be set up at this point of drawing
//bind buffers for mesh surface
@ -1050,8 +1051,8 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
// LIGHT ANGLE PR replaced USE_INSTANCE_CUSTOM line with below .. think it was a typo,
// but just in case, made this note.
//_set_texture_rect_mode(false);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_INSTANCE_CUSTOM, false);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_INSTANCING, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCE_CUSTOM, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCING, false);
storage->info.render._2d_draw_call_count++;
} break;
@ -1117,11 +1118,11 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
ERR_CONTINUE(primitive->points.size() < 1);
RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(primitive->texture, primitive->normal_map);
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(primitive->texture, primitive->normal_map);
if (texture) {
Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size);
state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size);
}
// we need a temporary because this must be nulled out
@ -1150,7 +1151,7 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
case Item::Command::TYPE_TRANSFORM: {
Item::CommandTransform *transform = static_cast<Item::CommandTransform *>(command);
state.uniforms.extra_matrix = transform->xform;
state.canvas_shader.set_uniform(CanvasShaderOpenGL::EXTRA_MATRIX, state.uniforms.extra_matrix);
state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX, state.uniforms.extra_matrix);
} break;
case Item::Command::TYPE_PARTICLES: {
@ -1195,25 +1196,25 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It
}
}
void RasterizerCanvasOpenGL::canvas_end() {
void RasterizerCanvasGLES3::canvas_end() {
batch_canvas_end();
RasterizerCanvasBaseOpenGL::canvas_end();
RasterizerCanvasBaseGLES3::canvas_end();
}
void RasterizerCanvasOpenGL::canvas_begin() {
void RasterizerCanvasGLES3::canvas_begin() {
batch_canvas_begin();
RasterizerCanvasBaseOpenGL::canvas_begin();
RasterizerCanvasBaseGLES3::canvas_begin();
}
void RasterizerCanvasOpenGL::canvas_render_items_begin(const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) {
void RasterizerCanvasGLES3::canvas_render_items_begin(const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) {
batch_canvas_render_items_begin(p_modulate, p_light, p_base_transform);
}
void RasterizerCanvasOpenGL::canvas_render_items_end() {
void RasterizerCanvasGLES3::canvas_render_items_end() {
batch_canvas_render_items_end();
}
void RasterizerCanvasOpenGL::canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, Light *p_directional_list, const Transform2D &p_canvas_transform, RS::CanvasItemTextureFilter p_default_filter, RS::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool &r_sdf_used) {
void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, Light *p_directional_list, const Transform2D &p_canvas_transform, RS::CanvasItemTextureFilter p_default_filter, RS::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool &r_sdf_used) {
storage->frame.current_rt = nullptr;
// first set the current render target
@ -1235,13 +1236,13 @@ void RasterizerCanvasOpenGL::canvas_render_items(RID p_to_render_target, Item *p
// canvas_end();
}
void RasterizerCanvasOpenGL::canvas_render_items_internal(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) {
void RasterizerCanvasGLES3::canvas_render_items_internal(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) {
batch_canvas_render_items(p_item_list, p_z, p_modulate, p_light, p_base_transform);
//glClearColor(Math::randf(), 0, 1, 1);
}
void RasterizerCanvasOpenGL::canvas_render_items_implementation(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) {
void RasterizerCanvasGLES3::canvas_render_items_implementation(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) {
// parameters are easier to pass around in a structure
RenderItemState ris;
ris.item_group_z = p_z;
@ -1249,7 +1250,7 @@ void RasterizerCanvasOpenGL::canvas_render_items_implementation(Item *p_item_lis
ris.item_group_light = p_light;
ris.item_group_base_transform = p_base_transform;
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_SKELETON, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_SKELETON, false);
state.current_tex = RID();
state.current_tex_ptr = NULL;
@ -1269,12 +1270,12 @@ void RasterizerCanvasOpenGL::canvas_render_items_implementation(Item *p_item_lis
glDisable(GL_SCISSOR_TEST);
}
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_SKELETON, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_SKELETON, false);
}
// Legacy non-batched implementation for regression testing.
// Should be removed after testing phase to avoid duplicate codepaths.
void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemState &r_ris) {
void RasterizerCanvasGLES3::_legacy_canvas_render_item(Item *p_ci, RenderItemState &r_ris) {
storage->info.render._2d_item_count++;
// defaults
@ -1325,7 +1326,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
}
#if 0
RasterizerStorageOpenGL::Skeleton *skeleton = NULL;
RasterizerStorageGLES3::Skeleton *skeleton = NULL;
{
//skeleton handling
@ -1343,7 +1344,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
bool use_skeleton = skeleton != NULL;
if (r_ris.prev_use_skeleton != use_skeleton) {
r_ris.rebind_shader = true;
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_SKELETON, use_skeleton);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_SKELETON, use_skeleton);
r_ris.prev_use_skeleton = use_skeleton;
}
@ -1360,10 +1361,10 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
Item *material_owner = p_ci->material_owner ? p_ci->material_owner : p_ci;
RID material = material_owner->material;
RasterizerStorageOpenGL::Material *material_ptr = storage->material_owner.get_or_null(material);
RasterizerStorageGLES3::Material *material_ptr = storage->material_owner.get_or_null(material);
if (material != r_ris.canvas_last_material || r_ris.rebind_shader) {
RasterizerStorageOpenGL::Shader *shader_ptr = NULL;
RasterizerStorageGLES3::Shader *shader_ptr = NULL;
if (material_ptr) {
shader_ptr = material_ptr->shader;
@ -1380,7 +1381,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
_copy_texscreen(Rect2());
// blend mode will have been enabled so make sure we disable it again later on
//last_blend_mode = last_blend_mode != RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_DISABLED ? last_blend_mode : -1;
//last_blend_mode = last_blend_mode != RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_DISABLED ? last_blend_mode : -1;
}
if (storage->frame.current_rt->copy_screen_effect.color) {
@ -1406,7 +1407,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
for (int i = 0; i < tc; i++) {
glActiveTexture(GL_TEXTURE0 + i);
RasterizerStorageOpenGL::Texture *t = storage->texture_owner.get_or_null(textures[i].second);
RasterizerStorageGLES3::Texture *t = storage->texture_owner.get_or_null(textures[i].second);
if (!t) {
switch (texture_hints[i]) {
@ -1458,13 +1459,13 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
r_ris.rebind_shader = false;
}
int blend_mode = r_ris.shader_cache ? r_ris.shader_cache->canvas_item.blend_mode : RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_MIX;
bool unshaded = r_ris.shader_cache && (r_ris.shader_cache->canvas_item.light_mode == RasterizerStorageOpenGL::Shader::CanvasItem::LIGHT_MODE_UNSHADED || (blend_mode != RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_MIX && blend_mode != RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_PMALPHA));
int blend_mode = r_ris.shader_cache ? r_ris.shader_cache->canvas_item.blend_mode : RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MIX;
bool unshaded = r_ris.shader_cache && (r_ris.shader_cache->canvas_item.light_mode == RasterizerStorageGLES3::Shader::CanvasItem::LIGHT_MODE_UNSHADED || (blend_mode != RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MIX && blend_mode != RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_PMALPHA));
bool reclip = false;
if (r_ris.last_blend_mode != blend_mode) {
switch (blend_mode) {
case RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_MIX: {
case RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MIX: {
glBlendEquation(GL_FUNC_ADD);
if (storage->frame.current_rt && storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_TRANSPARENT]) {
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
@ -1473,7 +1474,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
}
} break;
case RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_ADD: {
case RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_ADD: {
glBlendEquation(GL_FUNC_ADD);
if (storage->frame.current_rt && storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_TRANSPARENT]) {
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE);
@ -1482,7 +1483,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
}
} break;
case RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_SUB: {
case RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_SUB: {
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
if (storage->frame.current_rt && storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_TRANSPARENT]) {
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE);
@ -1490,7 +1491,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE);
}
} break;
case RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_MUL: {
case RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MUL: {
glBlendEquation(GL_FUNC_ADD);
if (storage->frame.current_rt && storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_TRANSPARENT]) {
glBlendFuncSeparate(GL_DST_COLOR, GL_ZERO, GL_DST_ALPHA, GL_ZERO);
@ -1498,7 +1499,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
glBlendFuncSeparate(GL_DST_COLOR, GL_ZERO, GL_ZERO, GL_ONE);
}
} break;
case RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_PMALPHA: {
case RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_PMALPHA: {
glBlendEquation(GL_FUNC_ADD);
if (storage->frame.current_rt && storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_TRANSPARENT]) {
glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
@ -1516,12 +1517,12 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
_set_uniforms();
if (unshaded || (state.uniforms.final_modulate.a > 0.001 && (!r_ris.shader_cache || r_ris.shader_cache->canvas_item.light_mode != RasterizerStorageOpenGL::Shader::CanvasItem::LIGHT_MODE_LIGHT_ONLY) && !p_ci->light_masked))
if (unshaded || (state.uniforms.final_modulate.a > 0.001 && (!r_ris.shader_cache || r_ris.shader_cache->canvas_item.light_mode != RasterizerStorageGLES3::Shader::CanvasItem::LIGHT_MODE_LIGHT_ONLY) && !p_ci->light_masked))
_legacy_canvas_item_render_commands(p_ci, NULL, reclip, material_ptr);
r_ris.rebind_shader = true; // hacked in for now.
if ((blend_mode == RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_MIX || blend_mode == RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_PMALPHA) && r_ris.item_group_light && !unshaded) {
if ((blend_mode == RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MIX || blend_mode == RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_PMALPHA) && r_ris.item_group_light && !unshaded) {
Light *light = r_ris.item_group_light;
bool light_used = false;
RS::CanvasLightBlendMode bmode = RS::CANVAS_LIGHT_BLEND_MODE_ADD;
@ -1554,7 +1555,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
}
if (!light_used) {
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_LIGHTING, true);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_LIGHTING, true);
light_used = true;
}
@ -1562,20 +1563,20 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
//bool has_shadow = light->shadow_buffer.is_valid() && p_ci->light_mask & light->item_shadow_mask;
bool has_shadow = light->use_shadow && p_ci->light_mask & light->item_shadow_mask;
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_SHADOWS, has_shadow);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_SHADOWS, has_shadow);
if (has_shadow) {
// FTODO
//state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_USE_GRADIENT, light->shadow_gradient_length > 0);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_USE_GRADIENT, false);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_NEAREST, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_NONE);
//state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF3, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF3);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF3, false);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF5, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF5);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF7, false);
//state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF7, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF7);
//state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF9, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF9);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF9, false);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF13, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF13);
//state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_USE_GRADIENT, light->shadow_gradient_length > 0);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_USE_GRADIENT, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_NEAREST, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_NONE);
//state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF3, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF3);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF3, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF5, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF5);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF7, false);
//state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF7, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF7);
//state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF9, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF9);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF9, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF13, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF13);
}
state.canvas_shader.bind();
@ -1587,7 +1588,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
state.canvas_shader.use_material((void *)material_ptr);
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 6);
RasterizerStorageOpenGL::Texture *t = storage->texture_owner.get_or_null(light->texture);
RasterizerStorageGLES3::Texture *t = storage->texture_owner.get_or_null(light->texture);
if (!t) {
glBindTexture(GL_TEXTURE_2D, storage->resources.white_tex);
} else {
@ -1606,14 +1607,14 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
}
if (light_used) {
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_LIGHTING, false);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_SHADOWS, false);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_NEAREST, false);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF3, false);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF5, false);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF7, false);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF9, false);
state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF13, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_LIGHTING, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_SHADOWS, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_NEAREST, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF3, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF5, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF7, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF9, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF13, false);
state.canvas_shader.bind();
@ -1623,9 +1624,9 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
//this is set again, so it should not be needed anyway?
state.canvas_item_modulate = unshaded ? ci->final_modulate : Color(ci->final_modulate.r * p_modulate.r, ci->final_modulate.g * p_modulate.g, ci->final_modulate.b * p_modulate.b, ci->final_modulate.a * p_modulate.a);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.final_transform);
state.canvas_shader.set_uniform(CanvasShaderOpenGL::EXTRA_MATRIX, Transform2D());
state.canvas_shader.set_uniform(CanvasShaderOpenGL::FINAL_MODULATE, state.canvas_item_modulate);
state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.final_transform);
state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX, Transform2D());
state.canvas_shader.set_uniform(CanvasShaderGLES3::FINAL_MODULATE, state.canvas_item_modulate);
glBlendEquation(GL_FUNC_ADD);
@ -1650,17 +1651,17 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt
}
}
void RasterizerCanvasOpenGL::gl_enable_scissor(int p_x, int p_y, int p_width, int p_height) const {
void RasterizerCanvasGLES3::gl_enable_scissor(int p_x, int p_y, int p_width, int p_height) const {
glEnable(GL_SCISSOR_TEST);
glScissor(p_x, p_y, p_width, p_height);
}
void RasterizerCanvasOpenGL::gl_disable_scissor() const {
void RasterizerCanvasGLES3::gl_disable_scissor() const {
glDisable(GL_SCISSOR_TEST);
}
void RasterizerCanvasOpenGL::initialize() {
RasterizerCanvasBaseOpenGL::initialize();
void RasterizerCanvasGLES3::initialize() {
RasterizerCanvasBaseGLES3::initialize();
batch_initialize();
@ -1701,8 +1702,8 @@ void RasterizerCanvasOpenGL::initialize() {
} // only if there is a vertex buffer (batching is on)
}
RasterizerCanvasOpenGL::RasterizerCanvasOpenGL() {
RasterizerCanvasGLES3::RasterizerCanvasGLES3() {
batch_constructor();
}
#endif // OPENGL_BACKEND_ENABLED
#endif // GLES3_BACKEND_ENABLED

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* rasterizer_canvas_opengl.h */
/* rasterizer_canvas_gles3.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -31,16 +31,16 @@
#ifndef RASTERIZER_CANVAS_OPENGL_H
#define RASTERIZER_CANVAS_OPENGL_H
#include "drivers/opengl/rasterizer_platforms.h"
#ifdef OPENGL_BACKEND_ENABLED
#include "drivers/gles3/rasterizer_platforms.h"
#ifdef GLES3_BACKEND_ENABLED
#include "drivers/opengl/rasterizer_canvas_batcher.h"
#include "rasterizer_canvas_base_opengl.h"
#include "drivers/gles3/rasterizer_canvas_batcher.h"
#include "rasterizer_canvas_base_gles3.h"
class RasterizerSceneOpenGL;
class RasterizerSceneGLES3;
class RasterizerCanvasOpenGL : public RasterizerCanvasBaseOpenGL, public RasterizerCanvasBatcher<RasterizerCanvasOpenGL, RasterizerStorageOpenGL> {
friend class RasterizerCanvasBatcher<RasterizerCanvasOpenGL, RasterizerStorageOpenGL>;
class RasterizerCanvasGLES3 : public RasterizerCanvasBaseGLES3, public RasterizerCanvasBatcher<RasterizerCanvasGLES3, RasterizerStorageGLES3> {
friend class RasterizerCanvasBatcher<RasterizerCanvasGLES3, RasterizerStorageGLES3>;
private:
// legacy codepath .. to remove after testing
@ -48,7 +48,7 @@ private:
// high level batch funcs
void canvas_render_items_implementation(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform);
void render_batches(Item::Command *const *p_commands, Item *p_current_clip, bool &r_reclip, RasterizerStorageOpenGL::Material *p_material);
void render_batches(Item::Command *const *p_commands, Item *p_current_clip, bool &r_reclip, RasterizerStorageGLES3::Material *p_material);
// funcs used from rasterizer_canvas_batcher template
void gl_enable_scissor(int p_x, int p_y, int p_width, int p_height) const;
@ -64,8 +64,8 @@ public:
void canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, Light *p_directional_list, const Transform2D &p_canvas_transform, RS::CanvasItemTextureFilter p_default_filter, RS::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool &r_sdf_used) override;
void initialize();
RasterizerCanvasOpenGL();
RasterizerCanvasGLES3();
};
#endif // OPENGL_BACKEND_ENABLED
#endif // GLES3_BACKEND_ENABLED
#endif // RASTERIZER_CANVAS_OPENGL_H

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* rasterizer_opengl.cpp */
/* rasterizer_gles3.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "rasterizer_opengl.h"
#include "rasterizer_gles3.h"
#ifdef OPENGL_BACKEND_ENABLED
#include "shader_opengl.h"
#ifdef GLES3_BACKEND_ENABLED
#include "shader_gles3.h"
#include "core/config/project_settings.h"
#include "core/os/os.h"
@ -75,9 +75,9 @@
#endif
#if !defined(GLES_OVER_GL) && defined(CAN_DEBUG)
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <GLES2/gl2platform.h>
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
#include <GLES3/gl3platform.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
@ -87,7 +87,7 @@
#define strcpy strcpy_s
#endif
void RasterizerOpenGL::begin_frame(double frame_step) {
void RasterizerGLES3::begin_frame(double frame_step) {
frame++;
delta = frame_step;
@ -117,7 +117,7 @@ void RasterizerOpenGL::begin_frame(double frame_step) {
//scene->iteration();
}
void RasterizerOpenGL::end_frame(bool p_swap_buffers) {
void RasterizerGLES3::end_frame(bool p_swap_buffers) {
// if (OS::get_singleton()->is_layered_allowed()) {
// if (!OS::get_singleton()->get_window_per_pixel_transparency_enabled()) {
//clear alpha
@ -184,7 +184,7 @@ static void GLAPIENTRY _gl_debug_print(GLenum source, GLenum type, GLuint id, GL
ERR_PRINT(output);
}
#endif // CAN_DEBUG
#endif
typedef void (*DEBUGPROCARB)(GLenum source,
GLenum type,
@ -196,7 +196,7 @@ typedef void (*DEBUGPROCARB)(GLenum source,
typedef void (*DebugMessageCallbackARB)(DEBUGPROCARB callback, const void *userParam);
void RasterizerOpenGL::initialize() {
void RasterizerGLES3::initialize() {
print_verbose("Using OpenGL video driver");
storage._main_thread_id = Thread::get_caller_id();
@ -261,7 +261,7 @@ void RasterizerOpenGL::initialize() {
OS::get_singleton()->set_render_main_thread_mode(OS::RENDER_MAIN_THREAD_ONLY);
}
RasterizerOpenGL::RasterizerOpenGL() {
RasterizerGLES3::RasterizerGLES3() {
canvas.storage = &storage;
canvas.scene_render = &scene;
storage.canvas = &canvas;
@ -269,15 +269,15 @@ RasterizerOpenGL::RasterizerOpenGL() {
storage.scene = &scene;
}
void RasterizerOpenGL::prepare_for_blitting_render_targets() {
void RasterizerGLES3::prepare_for_blitting_render_targets() {
}
void RasterizerOpenGL::_blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect) {
void RasterizerGLES3::_blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect) {
ERR_FAIL_COND(storage.frame.current_rt);
// print_line("_blit_render_target_to_screen " + itos (p_screen) + ", rect " + String(Variant(p_screen_rect)));
RasterizerStorageOpenGL::RenderTarget *rt = storage.render_target_owner.get_or_null(p_render_target);
RasterizerStorageGLES3::RenderTarget *rt = storage.render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
canvas._set_texture_rect_mode(true);
@ -287,6 +287,7 @@ void RasterizerOpenGL::_blit_render_target_to_screen(RID p_render_target, const
canvas.canvas_begin();
glDisable(GL_BLEND);
storage.bind_framebuffer_system();
glActiveTexture(GL_TEXTURE0 + storage.config.max_texture_image_units - 1);
if (rt->external.fbo != 0) {
glBindTexture(GL_TEXTURE_2D, rt->external.color);
@ -300,7 +301,7 @@ void RasterizerOpenGL::_blit_render_target_to_screen(RID p_render_target, const
}
// is this p_screen useless in a multi window environment?
void RasterizerOpenGL::blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) {
void RasterizerGLES3::blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) {
// do this once off for all blits
storage.bind_framebuffer_system();
@ -316,7 +317,7 @@ void RasterizerOpenGL::blit_render_targets_to_screen(DisplayServer::WindowID p_s
}
}
void RasterizerOpenGL::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
void RasterizerGLES3::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
if (p_image.is_null() || p_image->is_empty())
return;
@ -362,7 +363,7 @@ void RasterizerOpenGL::set_boot_image(const Ref<Image> &p_image, const Color &p_
screenrect.position += ((Size2(window_w, window_h) - screenrect.size) / 2.0).floor();
}
RasterizerStorageOpenGL::Texture *t = storage.texture_owner.get_or_null(texture);
RasterizerStorageGLES3::Texture *t = storage.texture_owner.get_or_null(texture);
glActiveTexture(GL_TEXTURE0 + storage.config.max_texture_image_units - 1);
glBindTexture(GL_TEXTURE_2D, t->tex_id);
canvas.draw_generic_textured_rect(screenrect, Rect2(0, 0, 1, 1));
@ -374,4 +375,4 @@ void RasterizerOpenGL::set_boot_image(const Ref<Image> &p_image, const Color &p_
end_frame(true);
}
#endif // OPENGL_BACKEND_ENABLED
#endif // GLES3_BACKEND_ENABLED

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* rasterizer_opengl.h */
/* rasterizer_gles3.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -31,15 +31,15 @@
#ifndef RASTERIZER_OPENGL_H
#define RASTERIZER_OPENGL_H
#include "drivers/opengl/rasterizer_platforms.h"
#ifdef OPENGL_BACKEND_ENABLED
#include "drivers/gles3/rasterizer_platforms.h"
#ifdef GLES3_BACKEND_ENABLED
#include "rasterizer_canvas_opengl.h"
#include "rasterizer_scene_opengl.h"
#include "rasterizer_storage_opengl.h"
#include "rasterizer_canvas_gles3.h"
#include "rasterizer_scene_gles3.h"
#include "rasterizer_storage_gles3.h"
#include "servers/rendering/renderer_compositor.h"
class RasterizerOpenGL : public RendererCompositor {
class RasterizerGLES3 : public RendererCompositor {
private:
uint64_t frame = 1;
float delta = 0;
@ -48,9 +48,9 @@ private:
double time_scale = 1.0;
protected:
RasterizerCanvasOpenGL canvas;
RasterizerStorageOpenGL storage;
RasterizerSceneOpenGL scene;
RasterizerCanvasGLES3 canvas;
RasterizerStorageGLES3 storage;
RasterizerSceneGLES3 scene;
void _blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect);
@ -72,7 +72,7 @@ public:
void finalize() {}
static RendererCompositor *_create_current() {
return memnew(RasterizerOpenGL);
return memnew(RasterizerGLES3);
}
static void make_current() {
@ -83,10 +83,10 @@ public:
uint64_t get_frame_number() const { return frame; }
double get_frame_delta_time() const { return delta; }
RasterizerOpenGL();
~RasterizerOpenGL() {}
RasterizerGLES3();
~RasterizerGLES3() {}
};
#endif // OPENGL_BACKEND_ENABLED
#endif // GLES3_BACKEND_ENABLED
#endif

View file

@ -36,13 +36,13 @@
//#ifndef X11_ENABLED
//#define X11_ENABLED
//#endif
//#define OPENGL_BACKEND_ENABLED
//#define GLES3_BACKEND_ENABLED
/////////////////////////////////////////////////////
#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED)
#if defined(GLES3_ENABLED) || defined(GLES_ENABLED)
#define OPENGL_BACKEND_ENABLED
#define GLES3_BACKEND_ENABLED
#endif // defined(OPENGL_ENABLED) || defined(GLES_ENABLED)
#endif // defined(GLES3_ENABLED) || defined(GLES_ENABLED)
#endif // RASTERIZER_PLATFORMS_H

View file

@ -0,0 +1,466 @@
/*************************************************************************/
/* rasterizer_scene_gles3.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "rasterizer_scene_gles3.h"
#ifdef GLES3_BACKEND_ENABLED
// TODO: 3D support not implemented yet.
RasterizerSceneGLES3::GeometryInstance *RasterizerSceneGLES3::geometry_instance_create(RID p_base) {
return nullptr;
}
void RasterizerSceneGLES3::geometry_instance_set_skeleton(GeometryInstance *p_geometry_instance, RID p_skeleton) {
}
void RasterizerSceneGLES3::geometry_instance_set_material_override(GeometryInstance *p_geometry_instance, RID p_override) {
}
void RasterizerSceneGLES3::geometry_instance_set_surface_materials(GeometryInstance *p_geometry_instance, const Vector<RID> &p_material) {
}
void RasterizerSceneGLES3::geometry_instance_set_mesh_instance(GeometryInstance *p_geometry_instance, RID p_mesh_instance) {
}
void RasterizerSceneGLES3::geometry_instance_set_transform(GeometryInstance *p_geometry_instance, const Transform3D &p_transform, const AABB &p_aabb, const AABB &p_transformed_aabbb) {
}
void RasterizerSceneGLES3::geometry_instance_set_layer_mask(GeometryInstance *p_geometry_instance, uint32_t p_layer_mask) {
}
void RasterizerSceneGLES3::geometry_instance_set_lod_bias(GeometryInstance *p_geometry_instance, float p_lod_bias) {
}
void RasterizerSceneGLES3::geometry_instance_set_transparency(GeometryInstance *p_geometry_instance, float p_transparency) {
}
void RasterizerSceneGLES3::geometry_instance_set_fade_range(GeometryInstance *p_geometry_instance, bool p_enable_near, float p_near_begin, float p_near_end, bool p_enable_far, float p_far_begin, float p_far_end) {
}
void RasterizerSceneGLES3::geometry_instance_set_parent_fade_alpha(GeometryInstance *p_geometry_instance, float p_alpha) {
}
void RasterizerSceneGLES3::geometry_instance_set_use_baked_light(GeometryInstance *p_geometry_instance, bool p_enable) {
}
void RasterizerSceneGLES3::geometry_instance_set_use_dynamic_gi(GeometryInstance *p_geometry_instance, bool p_enable) {
}
void RasterizerSceneGLES3::geometry_instance_set_use_lightmap(GeometryInstance *p_geometry_instance, RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) {
}
void RasterizerSceneGLES3::geometry_instance_set_lightmap_capture(GeometryInstance *p_geometry_instance, const Color *p_sh9) {
}
void RasterizerSceneGLES3::geometry_instance_set_instance_shader_parameters_offset(GeometryInstance *p_geometry_instance, int32_t p_offset) {
}
void RasterizerSceneGLES3::geometry_instance_set_cast_double_sided_shadows(GeometryInstance *p_geometry_instance, bool p_enable) {
}
uint32_t RasterizerSceneGLES3::geometry_instance_get_pair_mask() {
return 0;
}
void RasterizerSceneGLES3::geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count) {
}
void RasterizerSceneGLES3::geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) {
}
void RasterizerSceneGLES3::geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) {
}
void RasterizerSceneGLES3::geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) {
}
void RasterizerSceneGLES3::geometry_instance_set_softshadow_projector_pairing(GeometryInstance *p_geometry_instance, bool p_softshadow, bool p_projector) {
}
void RasterizerSceneGLES3::geometry_instance_free(GeometryInstance *p_geometry_instance) {
}
/* SHADOW ATLAS API */
RID RasterizerSceneGLES3::shadow_atlas_create() {
return RID();
}
void RasterizerSceneGLES3::shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits) {
}
void RasterizerSceneGLES3::shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) {
}
bool RasterizerSceneGLES3::shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) {
return false;
}
void RasterizerSceneGLES3::directional_shadow_atlas_set_size(int p_size, bool p_16_bits) {
}
int RasterizerSceneGLES3::get_directional_light_shadow_size(RID p_light_intance) {
return 0;
}
void RasterizerSceneGLES3::set_directional_shadow_count(int p_count) {
}
/* SDFGI UPDATE */
void RasterizerSceneGLES3::sdfgi_update(RID p_render_buffers, RID p_environment, const Vector3 &p_world_position) {
}
int RasterizerSceneGLES3::sdfgi_get_pending_region_count(RID p_render_buffers) const {
return 0;
}
AABB RasterizerSceneGLES3::sdfgi_get_pending_region_bounds(RID p_render_buffers, int p_region) const {
return AABB();
}
uint32_t RasterizerSceneGLES3::sdfgi_get_pending_region_cascade(RID p_render_buffers, int p_region) const {
return 0;
}
/* SKY API */
RID RasterizerSceneGLES3::sky_allocate() {
return RID();
}
void RasterizerSceneGLES3::sky_initialize(RID p_rid) {
}
void RasterizerSceneGLES3::sky_set_radiance_size(RID p_sky, int p_radiance_size) {
}
void RasterizerSceneGLES3::sky_set_mode(RID p_sky, RS::SkyMode p_samples) {
}
void RasterizerSceneGLES3::sky_set_material(RID p_sky, RID p_material) {
}
Ref<Image> RasterizerSceneGLES3::sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) {
return Ref<Image>();
}
/* ENVIRONMENT API */
RID RasterizerSceneGLES3::environment_allocate() {
return RID();
}
void RasterizerSceneGLES3::environment_initialize(RID p_rid) {
}
void RasterizerSceneGLES3::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) {
}
void RasterizerSceneGLES3::environment_set_sky(RID p_env, RID p_sky) {
}
void RasterizerSceneGLES3::environment_set_sky_custom_fov(RID p_env, float p_scale) {
}
void RasterizerSceneGLES3::environment_set_sky_orientation(RID p_env, const Basis &p_orientation) {
}
void RasterizerSceneGLES3::environment_set_bg_color(RID p_env, const Color &p_color) {
}
void RasterizerSceneGLES3::environment_set_bg_energy(RID p_env, float p_energy) {
}
void RasterizerSceneGLES3::environment_set_canvas_max_layer(RID p_env, int p_max_layer) {
}
void RasterizerSceneGLES3::environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source) {
}
void RasterizerSceneGLES3::environment_set_glow(RID p_env, bool p_enable, Vector<float> p_levels, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) {
}
void RasterizerSceneGLES3::environment_glow_set_use_bicubic_upscale(bool p_enable) {
}
void RasterizerSceneGLES3::environment_glow_set_use_high_quality(bool p_enable) {
}
void RasterizerSceneGLES3::environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) {
}
void RasterizerSceneGLES3::environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality) {
}
void RasterizerSceneGLES3::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_power, float p_detail, float p_horizon, float p_sharpness, float p_light_affect, float p_ao_channel_affect) {
}
void RasterizerSceneGLES3::environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) {
}
void RasterizerSceneGLES3::environment_set_sdfgi(RID p_env, bool p_enable, RS::EnvironmentSDFGICascades p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, float p_bounce_feedback, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias) {
}
void RasterizerSceneGLES3::environment_set_sdfgi_ray_count(RS::EnvironmentSDFGIRayCount p_ray_count) {
}
void RasterizerSceneGLES3::environment_set_sdfgi_frames_to_converge(RS::EnvironmentSDFGIFramesToConverge p_frames) {
}
void RasterizerSceneGLES3::environment_set_sdfgi_frames_to_update_light(RS::EnvironmentSDFGIFramesToUpdateLight p_update) {
}
void RasterizerSceneGLES3::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {
}
void RasterizerSceneGLES3::environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, bool p_use_1d_color_correction, RID p_color_correction) {
}
void RasterizerSceneGLES3::environment_set_fog(RID p_env, bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_aerial_perspective) {
}
void RasterizerSceneGLES3::environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_albedo, const Color &p_emission, float p_emission_energy, float p_anisotropy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount, float p_ambient_inject) {
}
void RasterizerSceneGLES3::environment_set_volumetric_fog_volume_size(int p_size, int p_depth) {
}
void RasterizerSceneGLES3::environment_set_volumetric_fog_filter_active(bool p_enable) {
}
Ref<Image> RasterizerSceneGLES3::environment_bake_panorama(RID p_env, bool p_bake_irradiance, const Size2i &p_size) {
return Ref<Image>();
}
bool RasterizerSceneGLES3::is_environment(RID p_env) const {
return false;
}
RS::EnvironmentBG RasterizerSceneGLES3::environment_get_background(RID p_env) const {
return RS::ENV_BG_KEEP;
}
int RasterizerSceneGLES3::environment_get_canvas_max_layer(RID p_env) const {
return 0;
}
RID RasterizerSceneGLES3::camera_effects_allocate() {
return RID();
}
void RasterizerSceneGLES3::camera_effects_initialize(RID p_rid) {
}
void RasterizerSceneGLES3::camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) {
}
void RasterizerSceneGLES3::camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) {
}
void RasterizerSceneGLES3::camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) {
}
void RasterizerSceneGLES3::camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) {
}
void RasterizerSceneGLES3::shadows_quality_set(RS::ShadowQuality p_quality) {
}
void RasterizerSceneGLES3::directional_shadow_quality_set(RS::ShadowQuality p_quality) {
}
RID RasterizerSceneGLES3::light_instance_create(RID p_light) {
return RID();
}
void RasterizerSceneGLES3::light_instance_set_transform(RID p_light_instance, const Transform3D &p_transform) {
}
void RasterizerSceneGLES3::light_instance_set_aabb(RID p_light_instance, const AABB &p_aabb) {
}
void RasterizerSceneGLES3::light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale, float p_range_begin, const Vector2 &p_uv_scale) {
}
void RasterizerSceneGLES3::light_instance_mark_visible(RID p_light_instance) {
}
RID RasterizerSceneGLES3::fog_volume_instance_create(RID p_fog_volume) {
return RID();
}
void RasterizerSceneGLES3::fog_volume_instance_set_transform(RID p_fog_volume_instance, const Transform3D &p_transform) {
}
void RasterizerSceneGLES3::fog_volume_instance_set_active(RID p_fog_volume_instance, bool p_active) {
}
RID RasterizerSceneGLES3::fog_volume_instance_get_volume(RID p_fog_volume_instance) const {
return RID();
}
Vector3 RasterizerSceneGLES3::fog_volume_instance_get_position(RID p_fog_volume_instance) const {
return Vector3();
}
RID RasterizerSceneGLES3::reflection_atlas_create() {
return RID();
}
int RasterizerSceneGLES3::reflection_atlas_get_size(RID p_ref_atlas) const {
return 0;
}
void RasterizerSceneGLES3::reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) {
}
RID RasterizerSceneGLES3::reflection_probe_instance_create(RID p_probe) {
return RID();
}
void RasterizerSceneGLES3::reflection_probe_instance_set_transform(RID p_instance, const Transform3D &p_transform) {
}
void RasterizerSceneGLES3::reflection_probe_release_atlas_index(RID p_instance) {
}
bool RasterizerSceneGLES3::reflection_probe_instance_needs_redraw(RID p_instance) {
return false;
}
bool RasterizerSceneGLES3::reflection_probe_instance_has_reflection(RID p_instance) {
return false;
}
bool RasterizerSceneGLES3::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) {
return false;
}
bool RasterizerSceneGLES3::reflection_probe_instance_postprocess_step(RID p_instance) {
return true;
}
RID RasterizerSceneGLES3::decal_instance_create(RID p_decal) {
return RID();
}
void RasterizerSceneGLES3::decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) {
}
RID RasterizerSceneGLES3::lightmap_instance_create(RID p_lightmap) {
return RID();
}
void RasterizerSceneGLES3::lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) {
}
RID RasterizerSceneGLES3::voxel_gi_instance_create(RID p_voxel_gi) {
return RID();
}
void RasterizerSceneGLES3::voxel_gi_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) {
}
bool RasterizerSceneGLES3::voxel_gi_needs_update(RID p_probe) const {
return false;
}
void RasterizerSceneGLES3::voxel_gi_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects) {
}
void RasterizerSceneGLES3::voxel_gi_set_quality(RS::VoxelGIQuality) {
}
void RasterizerSceneGLES3::render_scene(RID p_render_buffers, const CameraData *p_camera_data, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data, RendererScene::RenderInfo *r_render_info) {
}
void RasterizerSceneGLES3::render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) {
}
void RasterizerSceneGLES3::render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray<GeometryInstance *> &p_instances) {
}
void RasterizerSceneGLES3::set_scene_pass(uint64_t p_pass) {
}
void RasterizerSceneGLES3::set_time(double p_time, double p_step) {
}
void RasterizerSceneGLES3::set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) {
}
RID RasterizerSceneGLES3::render_buffers_create() {
return RID();
}
void RasterizerSceneGLES3::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) {
}
void RasterizerSceneGLES3::gi_set_use_half_resolution(bool p_enable) {
}
void RasterizerSceneGLES3::screen_space_roughness_limiter_set_active(bool p_enable, float p_amount, float p_curve) {
}
bool RasterizerSceneGLES3::screen_space_roughness_limiter_is_active() const {
return false;
}
void RasterizerSceneGLES3::sub_surface_scattering_set_quality(RS::SubSurfaceScatteringQuality p_quality) {
}
void RasterizerSceneGLES3::sub_surface_scattering_set_scale(float p_scale, float p_depth_scale) {
}
TypedArray<Image> RasterizerSceneGLES3::bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size) {
return TypedArray<Image>();
}
bool RasterizerSceneGLES3::free(RID p_rid) {
return false;
}
void RasterizerSceneGLES3::update() {
}
void RasterizerSceneGLES3::sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) {
}
void RasterizerSceneGLES3::decals_set_filter(RS::DecalFilter p_filter) {
}
void RasterizerSceneGLES3::light_projectors_set_filter(RS::LightProjectorFilter p_filter) {
}
RasterizerSceneGLES3::RasterizerSceneGLES3() {
}
#endif // GLES3_BACKEND_ENABLED

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* rasterizer_scene_opengl.h */
/* rasterizer_scene_gles3.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -31,8 +31,8 @@
#ifndef RASTERIZER_SCENE_OPENGL_H
#define RASTERIZER_SCENE_OPENGL_H
#include "drivers/opengl/rasterizer_platforms.h"
#ifdef OPENGL_BACKEND_ENABLED
#include "drivers/gles3/rasterizer_platforms.h"
#ifdef GLES3_BACKEND_ENABLED
#include "core/math/camera_matrix.h"
#include "core/templates/rid_owner.h"
@ -43,10 +43,10 @@
#include "servers/rendering_server.h"
#include "shaders/scene.glsl.gen.h"
class RasterizerSceneOpenGL : public RendererSceneRender {
class RasterizerSceneGLES3 : public RendererSceneRender {
public:
struct State {
SceneShaderOpenGL scene_shader;
SceneShaderGLES3 scene_shader;
} state;
GeometryInstance *geometry_instance_create(RID p_base) override;
@ -57,6 +57,9 @@ public:
void geometry_instance_set_transform(GeometryInstance *p_geometry_instance, const Transform3D &p_transform, const AABB &p_aabb, const AABB &p_transformed_aabbb) override;
void geometry_instance_set_layer_mask(GeometryInstance *p_geometry_instance, uint32_t p_layer_mask) override;
void geometry_instance_set_lod_bias(GeometryInstance *p_geometry_instance, float p_lod_bias) override;
void geometry_instance_set_transparency(GeometryInstance *p_geometry_instance, float p_transparency) override;
void geometry_instance_set_fade_range(GeometryInstance *p_geometry_instance, bool p_enable_near, float p_near_begin, float p_near_end, bool p_enable_far, float p_far_begin, float p_far_end) override;
void geometry_instance_set_parent_fade_alpha(GeometryInstance *p_geometry_instance, float p_alpha) override;
void geometry_instance_set_use_baked_light(GeometryInstance *p_geometry_instance, bool p_enable) override;
void geometry_instance_set_use_dynamic_gi(GeometryInstance *p_geometry_instance, bool p_enable) override;
void geometry_instance_set_use_lightmap(GeometryInstance *p_geometry_instance, RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) override;
@ -133,7 +136,7 @@ public:
void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, bool p_use_1d_color_correction, RID p_color_correction) override;
void environment_set_fog(RID p_env, bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_aerial_perspective) override;
void environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_light, float p_light_energy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount) override;
void environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_albedo, const Color &p_emission, float p_emission_energy, float p_anisotropy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount, float p_ambient_inject) override;
void environment_set_volumetric_fog_volume_size(int p_size, int p_depth) override;
void environment_set_volumetric_fog_filter_active(bool p_enable) override;
@ -160,6 +163,12 @@ public:
void light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale = 1.0, float p_range_begin = 0, const Vector2 &p_uv_scale = Vector2()) override;
void light_instance_mark_visible(RID p_light_instance) override;
RID fog_volume_instance_create(RID p_fog_volume) override;
void fog_volume_instance_set_transform(RID p_fog_volume_instance, const Transform3D &p_transform) override;
void fog_volume_instance_set_active(RID p_fog_volume_instance, bool p_active) override;
RID fog_volume_instance_get_volume(RID p_fog_volume_instance) const override;
Vector3 fog_volume_instance_get_position(RID p_fog_volume_instance) const override;
RID reflection_atlas_create() override;
int reflection_atlas_get_size(RID p_ref_atlas) const override;
void reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) override;
@ -185,7 +194,7 @@ public:
void voxel_gi_set_quality(RS::VoxelGIQuality) override;
void render_scene(RID p_render_buffers, const CameraData *p_camera_data, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RendererScene::RenderInfo *r_info = nullptr) override;
void render_scene(RID p_render_buffers, const CameraData *p_camera_data, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RendererScene::RenderInfo *r_render_info = nullptr) override;
void render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) override;
void render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray<GeometryInstance *> &p_instances) override;
@ -212,9 +221,9 @@ public:
void decals_set_filter(RS::DecalFilter p_filter) override;
void light_projectors_set_filter(RS::LightProjectorFilter p_filter) override;
RasterizerSceneOpenGL();
RasterizerSceneGLES3();
};
#endif // OPENGL_BACKEND_ENABLED
#endif // GLES3_BACKEND_ENABLED
#endif // RASTERIZER_SCENE_OPENGL_H

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* rasterizer_storage_opengl.h */
/* rasterizer_storage_gles3.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -31,34 +31,34 @@
#ifndef RASTERIZER_STORAGE_OPENGL_H
#define RASTERIZER_STORAGE_OPENGL_H
#include "drivers/opengl/rasterizer_platforms.h"
#ifdef OPENGL_BACKEND_ENABLED
#include "drivers/gles3/rasterizer_platforms.h"
#ifdef GLES3_BACKEND_ENABLED
#include "core/templates/local_vector.h"
#include "core/templates/rid_owner.h"
#include "core/templates/self_list.h"
#include "drivers/opengl/rasterizer_asserts.h"
#include "drivers/gles3/rasterizer_asserts.h"
#include "servers/rendering/renderer_compositor.h"
#include "servers/rendering/renderer_storage.h"
#include "servers/rendering/shader_language.h"
#include "shader_compiler_opengl.h"
#include "shader_opengl.h"
#include "shader_compiler_gles3.h"
#include "shader_gles3.h"
#include "shaders/copy.glsl.gen.h"
#include "shaders/cubemap_filter.glsl.gen.h"
class RasterizerCanvasOpenGL;
class RasterizerSceneOpenGL;
class RasterizerCanvasGLES3;
class RasterizerSceneGLES3;
class RasterizerStorageOpenGL : public RendererStorage {
friend class RasterizerOpenGL;
class RasterizerStorageGLES3 : public RendererStorage {
friend class RasterizerGLES3;
Thread::ID _main_thread_id = 0;
bool _is_main_thread();
public:
RasterizerCanvasOpenGL *canvas;
RasterizerSceneOpenGL *scene;
RasterizerCanvasGLES3 *canvas;
RasterizerSceneGLES3 *scene;
static GLuint system_fbo;
@ -78,10 +78,13 @@ public:
bool float_texture_supported;
bool s3tc_supported;
bool etc1_supported;
bool pvrtc_supported;
bool latc_supported;
bool rgtc_supported;
bool bptc_supported;
bool etc_supported;
bool etc2_supported;
bool pvrtc_supported;
bool srgb_decode_supported;
bool keep_original_textures;
@ -99,7 +102,6 @@ public:
bool support_shadow_cubemaps;
bool multisample_supported;
bool render_to_mipmap_supported;
GLuint depth_internalformat;
@ -132,14 +134,14 @@ public:
} resources;
mutable struct Shaders {
ShaderCompilerOpenGL compiler;
ShaderCompilerGLES3 compiler;
CopyShaderOpenGL copy;
CubemapFilterShaderOpenGL cubemap_filter;
CopyShaderGLES3 copy;
CubemapFilterShaderGLES3 cubemap_filter;
ShaderCompilerOpenGL::IdentifierActions actions_canvas;
ShaderCompilerOpenGL::IdentifierActions actions_scene;
ShaderCompilerOpenGL::IdentifierActions actions_particles;
ShaderCompilerGLES3::IdentifierActions actions_canvas;
ShaderCompilerGLES3::IdentifierActions actions_scene;
ShaderCompilerGLES3::IdentifierActions actions_particles;
} shaders;
@ -565,7 +567,7 @@ public:
RID self;
RS::ShaderMode mode;
ShaderOpenGL *shader;
ShaderGLES3 *shader;
String code;
SelfList<Material>::List materials;
@ -1096,6 +1098,17 @@ public:
void particles_collision_instance_set_transform(RID p_collision_instance, const Transform3D &p_transform) override;
void particles_collision_instance_set_active(RID p_collision_instance, bool p_active) override;
/* FOG VOLUMES */
RID fog_volume_allocate() override;
void fog_volume_initialize(RID p_rid) override;
void fog_volume_set_shape(RID p_fog_volume, RS::FogVolumeShape p_shape) override;
void fog_volume_set_extents(RID p_fog_volume, const Vector3 &p_extents) override;
void fog_volume_set_material(RID p_fog_volume, RID p_material) override;
AABB fog_volume_get_aabb(RID p_fog_volume) const override;
RS::FogVolumeShape fog_volume_get_shape(RID p_fog_volume) const override;
/* VISIBILITY NOTIFIER */
RID visibility_notifier_allocate() override;
void visibility_notifier_initialize(RID p_notifier) override;
@ -1392,13 +1405,13 @@ public:
}
void bind_framebuffer_system() {
glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageOpenGL::system_fbo);
glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
}
RasterizerStorageOpenGL();
RasterizerStorageGLES3();
};
inline bool RasterizerStorageOpenGL::safe_buffer_sub_data(unsigned int p_total_buffer_size, GLenum p_target, unsigned int p_offset, unsigned int p_data_size, const void *p_data, unsigned int &r_offset_after) const {
inline bool RasterizerStorageGLES3::safe_buffer_sub_data(unsigned int p_total_buffer_size, GLenum p_target, unsigned int p_offset, unsigned int p_data_size, const void *p_data, unsigned int &r_offset_after) const {
r_offset_after = p_offset + p_data_size;
#ifdef DEBUG_ENABLED
// we are trying to write across the edge of the buffer
@ -1411,7 +1424,7 @@ inline bool RasterizerStorageOpenGL::safe_buffer_sub_data(unsigned int p_total_b
// standardize the orphan / upload in one place so it can be changed per platform as necessary, and avoid future
// bugs causing pipeline stalls
inline void RasterizerStorageOpenGL::buffer_orphan_and_upload(unsigned int p_buffer_size, unsigned int p_offset, unsigned int p_data_size, const void *p_data, GLenum p_target, GLenum p_usage, bool p_optional_orphan) const {
inline void RasterizerStorageGLES3::buffer_orphan_and_upload(unsigned int p_buffer_size, unsigned int p_offset, unsigned int p_data_size, const void *p_data, GLenum p_target, GLenum p_usage, bool p_optional_orphan) const {
// Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
// Was previously #ifndef GLES_OVER_GL however this causes stalls on desktop mac also (and possibly other)
if (!p_optional_orphan || (config.should_orphan)) {
@ -1435,6 +1448,6 @@ inline void RasterizerStorageOpenGL::buffer_orphan_and_upload(unsigned int p_buf
glBufferSubData(p_target, p_offset, p_data_size, p_data);
}
#endif // OPENGL_BACKEND_ENABLED
#endif // GLES3_BACKEND_ENABLED
#endif // RASTERIZER_STORAGE_OPENGL_H

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* shader_compiler_opengl.cpp */
/* shader_compiler_gles3.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "shader_compiler_opengl.h"
#ifdef OPENGL_BACKEND_ENABLED
#include "shader_compiler_gles3.h"
#ifdef GLES3_BACKEND_ENABLED
#include "core/config/project_settings.h"
#include "core/os/os.h"
@ -206,7 +206,7 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
}
}
void ShaderCompilerOpenGL::_dump_function_deps(SL::ShaderNode *p_node, const StringName &p_for_func, const Map<StringName, String> &p_func_code, StringBuilder &r_to_add, Set<StringName> &r_added) {
void ShaderCompilerGLES3::_dump_function_deps(SL::ShaderNode *p_node, const StringName &p_for_func, const Map<StringName, String> &p_func_code, StringBuilder &r_to_add, Set<StringName> &r_added) {
int fidx = -1;
for (int i = 0; i < p_node->functions.size(); i++) {
@ -264,7 +264,7 @@ void ShaderCompilerOpenGL::_dump_function_deps(SL::ShaderNode *p_node, const Str
}
}
String ShaderCompilerOpenGL::_dump_node_code(SL::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning, bool p_use_scope) {
String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning, bool p_use_scope) {
StringBuilder code;
switch (p_node->type) {
@ -649,7 +649,7 @@ String ShaderCompilerOpenGL::_dump_node_code(SL::Node *p_node, int p_level, Gene
if (op_node->arguments[1]->get_datatype() == SL::TYPE_SAMPLER2D) { // ||
// op_node->arguments[1]->get_datatype() == SL::TYPE_SAMPLEREXT) {
code += "texture2D";
code += "texture";
} else if (op_node->arguments[1]->get_datatype() == SL::TYPE_SAMPLERCUBE) {
code += "textureCube";
}
@ -658,7 +658,7 @@ String ShaderCompilerOpenGL::_dump_node_code(SL::Node *p_node, int p_level, Gene
// emit texture call
if (op_node->arguments[1]->get_datatype() == SL::TYPE_SAMPLER2D) {
code += "texture2DLod";
code += "textureLod";
} else if (op_node->arguments[1]->get_datatype() == SL::TYPE_SAMPLERCUBE) {
code += "textureCubeLod";
}
@ -842,13 +842,13 @@ String ShaderCompilerOpenGL::_dump_node_code(SL::Node *p_node, int p_level, Gene
return code.as_string();
}
ShaderLanguage::DataType ShaderCompilerOpenGL::_get_variable_type(const StringName &p_type) {
ShaderLanguage::DataType ShaderCompilerGLES3::_get_variable_type(const StringName &p_type) {
// RS::GlobalVariableType gvt = ((RasterizerStorageRD *)(RendererStorage::base_singleton))->global_variable_get_type_internal(p_type);
RS::GlobalVariableType gvt = RS::GLOBAL_VAR_TYPE_MAX;
return RS::global_variable_type_get_shader_datatype(gvt);
}
Error ShaderCompilerOpenGL::compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) {
Error ShaderCompilerGLES3::compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) {
ShaderLanguage::VaryingFunctionNames var_names;
Error err = parser.compile(p_code, ShaderTypes::get_singleton()->get_functions(p_mode), ShaderTypes::get_singleton()->get_modes(p_mode), var_names, ShaderTypes::get_singleton()->get_types(), _get_variable_type);
@ -860,7 +860,7 @@ Error ShaderCompilerOpenGL::compile(RS::ShaderMode p_mode, const String &p_code,
print_line(itos(i + 1) + " " + shader[i]);
}
_err_print_error(NULL, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER);
_err_print_error(NULL, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), false, ERR_HANDLER_SHADER);
return err;
}
@ -885,7 +885,7 @@ Error ShaderCompilerOpenGL::compile(RS::ShaderMode p_mode, const String &p_code,
return OK;
}
ShaderCompilerOpenGL::ShaderCompilerOpenGL() {
ShaderCompilerGLES3::ShaderCompilerGLES3() {
/** CANVAS ITEM SHADER **/
actions[RS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy";
@ -1117,4 +1117,4 @@ ShaderCompilerOpenGL::ShaderCompilerOpenGL() {
}
}
#endif // OPENGL_BACKEND_ENABLED
#endif // GLES3_BACKEND_ENABLED

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* shader_compiler_opengl.h */
/* shader_compiler_gles3.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -31,8 +31,8 @@
#ifndef SHADER_COMPILER_OPENGL_H
#define SHADER_COMPILER_OPENGL_H
#include "drivers/opengl/rasterizer_platforms.h"
#ifdef OPENGL_BACKEND_ENABLED
#include "drivers/gles3/rasterizer_platforms.h"
#ifdef GLES3_BACKEND_ENABLED
#include "core/string/string_builder.h"
#include "core/templates/pair.h"
@ -40,7 +40,7 @@
#include "servers/rendering/shader_types.h"
#include "servers/rendering_server.h"
class ShaderCompilerOpenGL {
class ShaderCompilerGLES3 {
public:
struct IdentifierActions {
Map<StringName, Pair<int *, int>> render_mode_values;
@ -98,9 +98,9 @@ private:
public:
Error compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code);
ShaderCompilerOpenGL();
ShaderCompilerGLES3();
};
#endif // OPENGL_BACKEND_ENABLED
#endif // GLES3_BACKEND_ENABLED
#endif // SHADER_COMPILER_OPENGL_H

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* shader_opengl.cpp */
/* shader_gles3.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,12 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "shader_opengl.h"
#include "drivers/opengl/rasterizer_platforms.h"
#ifdef OPENGL_BACKEND_ENABLED
#include "shader_gles3.h"
#include "drivers/gles3/rasterizer_platforms.h"
#ifdef GLES3_BACKEND_ENABLED
#include "rasterizer_opengl.h"
#include "rasterizer_storage_opengl.h"
#include "rasterizer_gles3.h"
#include "rasterizer_storage_gles3.h"
#include "core/config/project_settings.h"
#include "core/os/memory.h"
@ -59,7 +59,7 @@
#endif
ShaderOpenGL *ShaderOpenGL::active = NULL;
ShaderGLES3 *ShaderGLES3::active = NULL;
//#define DEBUG_SHADER
@ -73,13 +73,13 @@ ShaderOpenGL *ShaderOpenGL::active = NULL;
#endif
GLint ShaderOpenGL::get_uniform_location(int p_index) const {
GLint ShaderGLES3::get_uniform_location(int p_index) const {
ERR_FAIL_COND_V(!version, -1);
return version->uniform_location[p_index];
}
bool ShaderOpenGL::bind() {
bool ShaderGLES3::bind() {
if (active != this || !version || new_conditional_version.key != conditional_version.key) {
conditional_version = new_conditional_version;
version = get_current_version();
@ -104,7 +104,7 @@ bool ShaderOpenGL::bind() {
return true;
}
void ShaderOpenGL::unbind() {
void ShaderGLES3::unbind() {
version = NULL;
glUseProgram(0);
uniforms_dirty = true;
@ -134,7 +134,7 @@ static String _mkid(const String &p_id) {
return id.replace("__", "_dus_"); //doubleunderscore is reserved in glsl
}
ShaderOpenGL::Version *ShaderOpenGL::get_current_version() {
ShaderGLES3::Version *ShaderGLES3::get_current_version() {
if (!valid)
return nullptr;
@ -172,32 +172,20 @@ ShaderOpenGL::Version *ShaderOpenGL::get_current_version() {
Vector<const char *> strings;
#ifdef GLES_OVER_GL
strings.push_back("#version 120\n");
strings.push_back("#version 330\n");
strings.push_back("#define USE_GLES_OVER_GL\n");
// test
strings.push_back("#define highp\n");
//#ifdef USE_GLES_OVER_GL
//#define lowp
//#define mediump
//#define highp
//#else
// precision highp float;
// precision highp int;
//#endif
#else
strings.push_back("#version 100\n");
strings.push_back("#version 300 es\n");
//angle does not like
#ifdef JAVASCRIPT_ENABLED
strings.push_back("#define USE_HIGHP_PRECISION\n");
#endif
if (GLOBAL_GET("rendering/opengl/compatibility/enable_high_float.Android")) {
// enable USE_HIGHP_PRECISION but safeguarded by an availability check as highp support is optional in OpenGL
// see Section 4.5.4 of the GLSL_ES_Specification_1.00
strings.push_back("#ifdef GL_FRAGMENT_PRECISION_HIGH\n #define USE_HIGHP_PRECISION\n#endif\n");
}
//if (GLOBAL_GET("rendering/opengl/compatibility/enable_high_float.Android")) {
// enable USE_HIGHP_PRECISION but safeguarded by an availability check as highp support is optional in OpenGL
// see Section 4.5.4 of the GLSL_ES_Specification_1.00
//strings.push_back("#ifdef GL_FRAGMENT_PRECISION_HIGH\n #define USE_HIGHP_PRECISION\n#endif\n");
//}
#endif
@ -484,12 +472,12 @@ ShaderOpenGL::Version *ShaderOpenGL::get_current_version() {
return &v;
}
GLint ShaderOpenGL::get_uniform_location(const String &p_name) const {
GLint ShaderGLES3::get_uniform_location(const String &p_name) const {
ERR_FAIL_COND_V(!version, -1);
return glGetUniformLocation(version->id, p_name.ascii().get_data());
}
void ShaderOpenGL::setup(
void ShaderGLES3::setup(
const char **p_conditional_defines,
int p_conditional_count,
const char **p_uniform_names,
@ -579,7 +567,7 @@ void ShaderOpenGL::setup(
valid = true;
}
void ShaderOpenGL::finish() {
void ShaderGLES3::finish() {
const VersionKey *V = NULL;
while ((V = version_map.next(V))) {
@ -593,7 +581,7 @@ void ShaderOpenGL::finish() {
}
}
void ShaderOpenGL::clear_caches() {
void ShaderGLES3::clear_caches() {
const VersionKey *V = NULL;
while ((V = version_map.next(V))) {
@ -612,13 +600,13 @@ void ShaderOpenGL::clear_caches() {
uniforms_dirty = true;
}
uint32_t ShaderOpenGL::create_custom_shader() {
uint32_t ShaderGLES3::create_custom_shader() {
custom_code_map[last_custom_code] = CustomCode();
custom_code_map[last_custom_code].version = 1;
return last_custom_code++;
}
void ShaderOpenGL::set_custom_shader_code(uint32_t p_code_id,
void ShaderGLES3::set_custom_shader_code(uint32_t p_code_id,
const String &p_vertex,
const String &p_vertex_globals,
const String &p_fragment,
@ -641,11 +629,11 @@ void ShaderOpenGL::set_custom_shader_code(uint32_t p_code_id,
cc->version++;
}
void ShaderOpenGL::set_custom_shader(uint32_t p_code_id) {
void ShaderGLES3::set_custom_shader(uint32_t p_code_id) {
new_conditional_version.code_version = p_code_id;
}
void ShaderOpenGL::free_custom_shader(uint32_t p_code_id) {
void ShaderGLES3::free_custom_shader(uint32_t p_code_id) {
ERR_FAIL_COND(!custom_code_map.has(p_code_id));
if (conditional_version.code_version == p_code_id) {
conditional_version.code_version = 0; //do not keep using a version that is going away
@ -671,8 +659,8 @@ void ShaderOpenGL::free_custom_shader(uint32_t p_code_id) {
custom_code_map.erase(p_code_id);
}
void ShaderOpenGL::use_material(void *p_material) {
RasterizerStorageOpenGL::Material *material = (RasterizerStorageOpenGL::Material *)p_material;
void ShaderGLES3::use_material(void *p_material) {
RasterizerStorageGLES3::Material *material = (RasterizerStorageGLES3::Material *)p_material;
if (!material) {
return;
@ -1115,14 +1103,14 @@ void ShaderOpenGL::use_material(void *p_material) {
}
}
ShaderOpenGL::ShaderOpenGL() {
ShaderGLES3::ShaderGLES3() {
version = NULL;
last_custom_code = 1;
uniforms_dirty = true;
}
ShaderOpenGL::~ShaderOpenGL() {
ShaderGLES3::~ShaderGLES3() {
finish();
}
#endif // OPENGL_BACKEND_ENABLED
#endif // GLES3_BACKEND_ENABLED

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* shader_opengl.h */
/* shader_gles3.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -31,8 +31,8 @@
#ifndef SHADER_OPENGL_H
#define SHADER_OPENGL_H
#include "drivers/opengl/rasterizer_platforms.h"
#ifdef OPENGL_BACKEND_ENABLED
#include "drivers/gles3/rasterizer_platforms.h"
#ifdef GLES3_BACKEND_ENABLED
// This must come first to avoid windows.h mess
#include "platform_config.h"
@ -51,9 +51,9 @@
#include <stdio.h>
class RasterizerStorageOpenGL;
class RasterizerStorageGLES3;
class ShaderOpenGL {
class ShaderGLES3 {
protected:
struct Enum {
uint64_t mask;
@ -172,7 +172,7 @@ private:
Version *get_current_version();
static ShaderOpenGL *active;
static ShaderGLES3 *active;
int max_image_units;
@ -195,7 +195,7 @@ protected:
int p_vertex_code_start,
int p_fragment_code_start);
ShaderOpenGL();
ShaderGLES3();
public:
enum {
@ -205,7 +205,7 @@ public:
GLint get_uniform_location(const String &p_name) const;
GLint get_uniform_location(int p_index) const;
static _FORCE_INLINE_ ShaderOpenGL *get_active() { return active; }
static _FORCE_INLINE_ ShaderGLES3 *get_active() { return active; }
bool bind();
void unbind();
@ -229,7 +229,7 @@ public:
uint32_t get_version_key() const { return conditional_version.version; }
// this void* is actually a RasterizerStorageOpenGL::Material, but C++ doesn't
// this void* is actually a RasterizerStorageGLES3::Material, but C++ doesn't
// like forward declared nested classes.
void use_material(void *p_material);
@ -253,18 +253,18 @@ public:
custom_defines.erase(p_define.utf8());
}
virtual ~ShaderOpenGL();
virtual ~ShaderGLES3();
};
// called a lot, made inline
int ShaderOpenGL::_get_uniform(int p_which) const {
int ShaderGLES3::_get_uniform(int p_which) const {
ERR_FAIL_INDEX_V(p_which, uniform_count, -1);
ERR_FAIL_COND_V(!version, -1);
return version->uniform_location[p_which];
}
void ShaderOpenGL::_set_conditional(int p_which, bool p_value) {
void ShaderGLES3::_set_conditional(int p_which, bool p_value) {
ERR_FAIL_INDEX(p_which, conditional_count);
if (p_value)
new_conditional_version.version |= (1 << p_which);
@ -272,6 +272,6 @@ void ShaderOpenGL::_set_conditional(int p_which, bool p_value) {
new_conditional_version.version &= ~(1 << p_which);
}
#endif // OPENGL_BACKEND_ENABLED
#endif // GLES3_BACKEND_ENABLED
#endif // SHADER_OPENGL_H

View file

@ -0,0 +1,14 @@
#!/usr/bin/env python
Import("env")
if "GLES3_GLSL" in env["BUILDERS"]:
env.GLES3_GLSL("copy.glsl")
env.GLES3_GLSL("canvas.glsl")
env.GLES3_GLSL("canvas_shadow.glsl")
env.GLES3_GLSL("scene.glsl")
env.GLES3_GLSL("cubemap_filter.glsl")
env.GLES3_GLSL("cube_to_dp.glsl")
env.GLES3_GLSL("effect_blur.glsl")
env.GLES3_GLSL("tonemap.glsl")
env.GLES3_GLSL("lens_distorted.glsl")

View file

@ -13,44 +13,42 @@ precision highp int;
uniform highp mat4 projection_matrix;
/* clang-format on */
#include "stdlib.glsl"
uniform highp mat4 modelview_matrix;
uniform highp mat4 extra_matrix;
attribute highp vec2 vertex; // attrib:0
layout(location = 0) in highp vec2 vertex;
#ifdef USE_ATTRIB_LIGHT_ANGLE
// shared with tangent, not used in canvas shader
attribute highp float light_angle; // attrib:2
layout(location = 2) in highp float light_angle;
#endif
attribute vec4 color_attrib; // attrib:3
attribute vec2 uv_attrib; // attrib:4
layout(location = 3) in vec4 color_attrib;
layout(location = 4) in vec2 uv_attrib;
#ifdef USE_ATTRIB_MODULATE
attribute highp vec4 modulate_attrib; // attrib:5
layout(location = 5) in highp vec4 modulate_attrib;
#endif
#ifdef USE_ATTRIB_LARGE_VERTEX
// shared with skeleton attributes, not used in batched shader
attribute highp vec2 translate_attrib; // attrib:6
attribute highp vec4 basis_attrib; // attrib:7
layout(location = 6) in highp vec2 translate_attrib;
layout(location = 7) in highp vec4 basis_attrib;
#endif
#ifdef USE_SKELETON
attribute highp vec4 bone_indices; // attrib:6
attribute highp vec4 bone_weights; // attrib:7
layout(location = 6) in highp vec4 bone_indices;
layout(location = 7) in highp vec4 bone_weights;
#endif
#ifdef USE_INSTANCING
attribute highp vec4 instance_xform0; //attrib:8
attribute highp vec4 instance_xform1; //attrib:9
attribute highp vec4 instance_xform2; //attrib:10
attribute highp vec4 instance_color; //attrib:11
layout(location = 8) in highp vec4 instance_xform0;
layout(location = 9) in highp vec4 instance_xform1;
layout(location = 10) in highp vec4 instance_xform2;
layout(location = 11) in highp vec4 instance_color;
#ifdef USE_INSTANCE_CUSTOM
attribute highp vec4 instance_custom_data; //attrib:12
layout(location = 12) in highp vec4 instance_custom_data;
#endif
#endif
@ -62,12 +60,12 @@ uniform highp mat4 skeleton_transform;
uniform highp mat4 skeleton_transform_inverse;
#endif
varying vec2 uv_interp;
varying vec4 color_interp;
out vec2 uv_interp;
out vec4 color_interp;
#ifdef USE_ATTRIB_MODULATE
// modulate doesn't need interpolating but we need to send it to the fragment shader
varying vec4 modulate_interp;
flat out vec4 modulate_interp;
#endif
#ifdef MODULATE_USED
@ -101,12 +99,12 @@ uniform highp float light_height;
uniform highp float light_outside_alpha;
uniform highp float shadow_distance_mult;
varying vec4 light_uv_interp;
varying vec2 transformed_light_uv;
varying vec4 local_rot;
out vec4 light_uv_interp;
out vec2 transformed_light_uv;
out vec4 local_rot;
#ifdef USE_SHADOWS
varying highp vec2 pos;
out highp vec2 pos;
#endif
const bool at_light_pass = true;
@ -295,25 +293,6 @@ VERTEX_SHADER_CODE
/* clang-format off */
[fragment]
// texture2DLodEXT and textureCubeLodEXT are fragment shader specific.
// Do not copy these defines in the vertex section.
#ifndef USE_GLES_OVER_GL
#ifdef GL_EXT_shader_texture_lod
#extension GL_EXT_shader_texture_lod : enable
#define texture2DLod(img, coord, lod) texture2DLodEXT(img, coord, lod)
#define textureCubeLod(img, coord, lod) textureCubeLodEXT(img, coord, lod)
#endif
#endif // !USE_GLES_OVER_GL
#ifdef GL_ARB_shader_texture_lod
#extension GL_ARB_shader_texture_lod : enable
#endif
#if !defined(GL_EXT_shader_texture_lod) && !defined(GL_ARB_shader_texture_lod)
#define texture2DLod(img, coord, lod) texture2D(img, coord, lod)
#define textureCubeLod(img, coord, lod) textureCube(img, coord, lod)
#endif
#ifdef USE_GLES_OVER_GL
#define lowp
#define mediump
@ -328,18 +307,16 @@ precision mediump int;
#endif
#endif
#include "stdlib.glsl"
uniform sampler2D color_texture; // texunit:-1
/* clang-format on */
uniform highp vec2 color_texpixel_size;
uniform mediump sampler2D normal_texture; // texunit:-2
varying mediump vec2 uv_interp;
varying mediump vec4 color_interp;
in mediump vec2 uv_interp;
in mediump vec4 color_interp;
#ifdef USE_ATTRIB_MODULATE
varying mediump vec4 modulate_interp;
in mediump vec4 modulate_interp;
#endif
uniform highp float time;
@ -373,15 +350,15 @@ uniform highp float light_outside_alpha;
uniform highp float shadow_distance_mult;
uniform lowp sampler2D light_texture; // texunit:-6
varying vec4 light_uv_interp;
varying vec2 transformed_light_uv;
in vec4 light_uv_interp;
in vec2 transformed_light_uv;
varying vec4 local_rot;
in vec4 local_rot;
#ifdef USE_SHADOWS
uniform highp sampler2D shadow_texture; // texunit:-5
varying highp vec2 pos;
in highp vec2 pos;
#endif
@ -392,6 +369,8 @@ const bool at_light_pass = false;
uniform bool use_default_normal;
layout(location = 0) out mediump vec4 frag_color;
/* clang-format off */
FRAGMENT_SHADER_GLOBALS
@ -434,7 +413,7 @@ void main() {
#if !defined(COLOR_USED)
//default behavior, texture by color
color *= texture2D(color_texture, uv);
color *= texture(color_texture, uv);
#endif
#ifdef SCREEN_UV_USED
@ -451,7 +430,7 @@ void main() {
#endif
if (use_default_normal) {
normal.xy = texture2D(normal_texture, uv).xy * 2.0 - 1.0;
normal.xy = texture(normal_texture, uv).xy * 2.0 - 1.0;
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy));
normal_used = true;
} else {
@ -497,7 +476,7 @@ FRAGMENT_SHADER_CODE
float att = 1.0;
vec2 light_uv = light_uv_interp.xy;
vec4 light = texture2D(light_texture, light_uv);
vec4 light = texture(light_texture, light_uv);
if (any(lessThan(light_uv_interp.xy, vec2(0.0, 0.0))) || any(greaterThanEqual(light_uv_interp.xy, vec2(1.0, 1.0)))) {
color.a *= light_outside_alpha; //invisible
@ -579,11 +558,11 @@ FRAGMENT_SHADER_CODE
highp float shadow_attenuation = 0.0;
#ifdef USE_RGBA_SHADOWS
#define SHADOW_DEPTH(m_tex, m_uv) dot(texture2D((m_tex), (m_uv)), vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0))
#define SHADOW_DEPTH(m_tex, m_uv) dot(texture((m_tex), (m_uv)), vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0))
#else
#define SHADOW_DEPTH(m_tex, m_uv) (texture2D((m_tex), (m_uv)).r)
#define SHADOW_DEPTH(m_tex, m_uv) (texture((m_tex), (m_uv)).r)
#endif
@ -682,5 +661,5 @@ FRAGMENT_SHADER_CODE
//use lighting
#endif
gl_FragColor = color;
frag_color = color;
}

View file

@ -10,7 +10,7 @@ precision highp float;
precision highp int;
#endif
attribute highp vec3 vertex; // attrib:0
layout(location = 0) highp vec3 vertex;
uniform highp mat4 projection_matrix;
/* clang-format on */
@ -18,7 +18,7 @@ uniform highp mat4 light_matrix;
uniform highp mat4 world_matrix;
uniform highp float distance_norm;
varying highp vec4 position_interp;
out highp vec4 position_interp;
void main() {
gl_Position = projection_matrix * (light_matrix * (world_matrix * vec4(vertex, 1.0)));
@ -42,7 +42,7 @@ precision mediump int;
#endif
#endif
varying highp vec4 position_interp;
in highp vec4 position_interp;
/* clang-format on */
void main() {
@ -52,9 +52,9 @@ void main() {
highp vec4 comp = fract(depth * vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0));
comp -= comp.xxyz * vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
gl_FragColor = comp;
frag_color = comp;
#else
gl_FragColor = vec4(depth);
frag_color = vec4(depth);
#endif
}

View file

@ -10,23 +10,23 @@ precision highp float;
precision highp int;
#endif
attribute highp vec4 vertex_attrib; // attrib:0
layout(location = 0) highp vec4 vertex_attrib;
/* clang-format on */
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
attribute vec3 cube_in; // attrib:4
layout(location = 4) vec3 cube_in;
#else
attribute vec2 uv_in; // attrib:4
layout(location = 4) vec2 uv_in;
#endif
attribute vec2 uv2_in; // attrib:5
layout(location = 5) vec2 uv2_in;
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
varying vec3 cube_interp;
out vec3 cube_interp;
#else
varying vec2 uv_interp;
out vec2 uv_interp;
#endif
varying vec2 uv2_interp;
out vec2 uv2_interp;
// These definitions are here because the shader-wrapper builder does
// not understand `#elif defined()`
@ -79,9 +79,9 @@ precision mediump int;
#endif
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
varying vec3 cube_interp;
in vec3 cube_interp;
#else
varying vec2 uv_interp;
in vec2 uv_interp;
#endif
/* clang-format on */
@ -100,7 +100,7 @@ uniform sampler2D source; // texunit:0
uniform sampler2D CbCr; //texunit:1
#endif
varying vec2 uv2_interp;
in vec2 uv2_interp;
#ifdef USE_MULTIPLIER
uniform float multiplier;
@ -123,11 +123,13 @@ vec4 texturePanorama(sampler2D pano, vec3 normal) {
st /= vec2(M_PI * 2.0, M_PI);
return texture2D(pano, st);
return texture(pano, st);
}
#endif
layout(location = 0) out vec4 frag_color;
void main() {
#ifdef USE_PANORAMA
@ -157,11 +159,11 @@ void main() {
vec4 color = textureCube(source_cube, normalize(cube_interp));
#elif defined(SEP_CBCR_TEXTURE)
vec4 color;
color.r = texture2D(source, uv_interp).r;
color.gb = texture2D(CbCr, uv_interp).rg - vec2(0.5, 0.5);
color.r = texture(source, uv_interp).r;
color.gb = texture(CbCr, uv_interp).rg - vec2(0.5, 0.5);
color.a = 1.0;
#else
vec4 color = texture2D(source, uv_interp);
vec4 color = texture(source, uv_interp);
#endif
#ifdef YCBCR_TO_RGB
@ -172,7 +174,7 @@ void main() {
vec3(1.00000, 1.00000, 1.00000),
vec3(0.00000, -0.34413, 1.77200),
vec3(1.40200, -0.71414, 0.00000)) *
color.rgb;
color.rgb;
#endif
#ifdef USE_NO_ALPHA
@ -187,5 +189,5 @@ void main() {
color.rgb *= multiplier;
#endif
gl_FragColor = color;
frag_color = color;
}

View file

@ -10,11 +10,11 @@ precision mediump float;
precision mediump int;
#endif
attribute highp vec4 vertex_attrib; // attrib:0
layout(location = 0) highp vec4 vertex_attrib;
/* clang-format on */
attribute vec2 uv_in; // attrib:4
layout(location = 4) vec2 uv_in;
varying vec2 uv_interp;
out vec2 uv_interp;
void main() {
uv_interp = uv_in;
@ -40,7 +40,7 @@ precision mediump int;
uniform highp samplerCube source_cube; //texunit:0
/* clang-format on */
varying vec2 uv_interp;
in vec2 uv_interp;
uniform bool z_flip;
uniform highp float z_far;

View file

@ -10,11 +10,11 @@ precision highp float;
precision highp int;
#endif
attribute highp vec2 vertex; // attrib:0
layout(location = 0) highp vec2 vertex;
/* clang-format on */
attribute highp vec2 uv; // attrib:4
layout(location = 4) highp vec2 uv;
varying highp vec2 uv_interp;
out highp vec2 uv_interp;
void main() {
uv_interp = uv;
@ -24,25 +24,6 @@ void main() {
/* clang-format off */
[fragment]
// texture2DLodEXT and textureCubeLodEXT are fragment shader specific.
// Do not copy these defines in the vertex section.
#ifndef USE_GLES_OVER_GL
#ifdef GL_EXT_shader_texture_lod
#extension GL_EXT_shader_texture_lod : enable
#define texture2DLod(img, coord, lod) texture2DLodEXT(img, coord, lod)
#define textureCubeLod(img, coord, lod) textureCubeLodEXT(img, coord, lod)
#endif
#endif // !USE_GLES_OVER_GL
#ifdef GL_ARB_shader_texture_lod
#extension GL_ARB_shader_texture_lod : enable
#endif
#if !defined(GL_EXT_shader_texture_lod) && !defined(GL_ARB_shader_texture_lod)
#define texture2DLod(img, coord, lod) texture2D(img, coord, lod)
#define textureCubeLod(img, coord, lod) textureCube(img, coord, lod)
#endif
#ifdef USE_GLES_OVER_GL
#define lowp
#define mediump
@ -67,7 +48,7 @@ uniform samplerCube source_cube; //texunit:0
uniform int face_id;
uniform float roughness;
varying highp vec2 uv_interp;
in highp vec2 uv_interp;
uniform sampler2D radical_inverse_vdc_cache; // texunit:1
@ -95,7 +76,7 @@ vec4 texturePanorama(sampler2D pano, vec3 normal) {
st /= vec2(M_PI * 2.0, M_PI);
return texture2DLod(pano, st, 0.0);
return textureLod(pano, st, 0.0);
}
#endif
@ -167,7 +148,7 @@ vec3 ImportanceSampleGGX(vec2 Xi, float Roughness, vec3 N) {
}
float radical_inverse_VdC(int i) {
return texture2D(radical_inverse_vdc_cache, vec2(float(i) / 512.0, 0.0)).x;
return texture(radical_inverse_vdc_cache, vec2(float(i) / 512.0, 0.0)).x;
}
vec2 Hammersley(int i, int N) {
@ -176,6 +157,8 @@ vec2 Hammersley(int i, int N) {
uniform bool z_flip;
layout(location = 0) out vec4 frag_color;
void main() {
vec3 color = vec3(0.0);
@ -186,10 +169,10 @@ void main() {
#ifdef USE_SOURCE_PANORAMA
gl_FragColor = vec4(texturePanorama(source_panorama, N).rgb, 1.0);
frag_color = vec4(texturePanorama(source_panorama, N).rgb, 1.0);
#else
gl_FragColor = vec4(textureCube(source_cube, N).rgb, 1.0);
frag_color = vec4(textureCube(source_cube, N).rgb, 1.0);
#endif //USE_SOURCE_PANORAMA
#else
@ -226,6 +209,6 @@ void main() {
vec3 a = vec3(0.055);
sum.rgb = mix((vec3(1.0) + a) * pow(sum.rgb, vec3(1.0 / 2.4)) - a, 12.92 * sum.rgb, vec3(lessThan(sum.rgb, vec3(0.0031308))));
gl_FragColor = vec4(sum.rgb, 1.0);
frag_color = vec4(sum.rgb, 1.0);
#endif
}

View file

@ -10,11 +10,11 @@ precision highp float;
precision highp int;
#endif
attribute vec2 vertex_attrib; // attrib:0
layout(location = 0) vec2 vertex_attrib;
/* clang-format on */
attribute vec2 uv_in; // attrib:4
layout(location = 4) vec2 uv_in;
varying vec2 uv_interp;
out vec2 uv_interp;
#ifdef USE_BLUR_SECTION
@ -35,25 +35,6 @@ void main() {
/* clang-format off */
[fragment]
// texture2DLodEXT and textureCubeLodEXT are fragment shader specific.
// Do not copy these defines in the vertex section.
#ifndef USE_GLES_OVER_GL
#ifdef GL_EXT_shader_texture_lod
#extension GL_EXT_shader_texture_lod : enable
#define texture2DLod(img, coord, lod) texture2DLodEXT(img, coord, lod)
#define textureCubeLod(img, coord, lod) textureCubeLodEXT(img, coord, lod)
#endif
#endif // !USE_GLES_OVER_GL
#ifdef GL_ARB_shader_texture_lod
#extension GL_ARB_shader_texture_lod : enable
#endif
#if !defined(GL_EXT_shader_texture_lod) && !defined(GL_ARB_shader_texture_lod)
#define texture2DLod(img, coord, lod) texture2D(img, coord, lod)
#define textureCubeLod(img, coord, lod) textureCube(img, coord, lod)
#endif
#ifdef USE_GLES_OVER_GL
#define lowp
#define mediump
@ -68,7 +49,7 @@ precision mediump int;
#endif
#endif
varying vec2 uv_interp;
in vec2 uv_interp;
/* clang-format on */
uniform sampler2D source_color; //texunit:0
@ -125,29 +106,31 @@ uniform float glow_hdr_scale;
uniform float camera_z_far;
uniform float camera_z_near;
layout(location = 0) out vec4 frag_color;
void main() {
#ifdef GLOW_GAUSSIAN_HORIZONTAL
vec2 pix_size = pixel_size;
pix_size *= 0.5; //reading from larger buffer, so use more samples
vec4 color = texture2DLod(source_color, uv_interp + vec2(0.0, 0.0) * pix_size, lod) * 0.174938;
color += texture2DLod(source_color, uv_interp + vec2(1.0, 0.0) * pix_size, lod) * 0.165569;
color += texture2DLod(source_color, uv_interp + vec2(2.0, 0.0) * pix_size, lod) * 0.140367;
color += texture2DLod(source_color, uv_interp + vec2(3.0, 0.0) * pix_size, lod) * 0.106595;
color += texture2DLod(source_color, uv_interp + vec2(-1.0, 0.0) * pix_size, lod) * 0.165569;
color += texture2DLod(source_color, uv_interp + vec2(-2.0, 0.0) * pix_size, lod) * 0.140367;
color += texture2DLod(source_color, uv_interp + vec2(-3.0, 0.0) * pix_size, lod) * 0.106595;
vec4 color = textureLod(source_color, uv_interp + vec2(0.0, 0.0) * pix_size, lod) * 0.174938;
color += textureLod(source_color, uv_interp + vec2(1.0, 0.0) * pix_size, lod) * 0.165569;
color += textureLod(source_color, uv_interp + vec2(2.0, 0.0) * pix_size, lod) * 0.140367;
color += textureLod(source_color, uv_interp + vec2(3.0, 0.0) * pix_size, lod) * 0.106595;
color += textureLod(source_color, uv_interp + vec2(-1.0, 0.0) * pix_size, lod) * 0.165569;
color += textureLod(source_color, uv_interp + vec2(-2.0, 0.0) * pix_size, lod) * 0.140367;
color += textureLod(source_color, uv_interp + vec2(-3.0, 0.0) * pix_size, lod) * 0.106595;
color *= glow_strength;
gl_FragColor = color;
frag_color = color;
#endif
#ifdef GLOW_GAUSSIAN_VERTICAL
vec4 color = texture2DLod(source_color, uv_interp + vec2(0.0, 0.0) * pixel_size, lod) * 0.288713;
color += texture2DLod(source_color, uv_interp + vec2(0.0, 1.0) * pixel_size, lod) * 0.233062;
color += texture2DLod(source_color, uv_interp + vec2(0.0, 2.0) * pixel_size, lod) * 0.122581;
color += texture2DLod(source_color, uv_interp + vec2(0.0, -1.0) * pixel_size, lod) * 0.233062;
color += texture2DLod(source_color, uv_interp + vec2(0.0, -2.0) * pixel_size, lod) * 0.122581;
vec4 color = textureLod(source_color, uv_interp + vec2(0.0, 0.0) * pixel_size, lod) * 0.288713;
color += textureLod(source_color, uv_interp + vec2(0.0, 1.0) * pixel_size, lod) * 0.233062;
color += textureLod(source_color, uv_interp + vec2(0.0, 2.0) * pixel_size, lod) * 0.122581;
color += textureLod(source_color, uv_interp + vec2(0.0, -1.0) * pixel_size, lod) * 0.233062;
color += textureLod(source_color, uv_interp + vec2(0.0, -2.0) * pixel_size, lod) * 0.122581;
color *= glow_strength;
gl_FragColor = color;
frag_color = color;
#endif
#ifndef USE_GLES_OVER_GL
@ -214,7 +197,7 @@ void main() {
vec4 color_accum = vec4(0.0);
float depth = texture2DLod(dof_source_depth, uv_interp, 0.0).r;
float depth = textureLod(dof_source_depth, uv_interp, 0.0).r;
depth = depth * 2.0 - 1.0;
#ifdef USE_ORTHOGONAL_PROJECTION
depth = ((depth + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0;
@ -231,7 +214,7 @@ void main() {
float tap_k = dof_kernel[i];
float tap_depth = texture2D(dof_source_depth, tap_uv, 0.0).r;
float tap_depth = texture(dof_source_depth, tap_uv, 0.0).r;
tap_depth = tap_depth * 2.0 - 1.0;
#ifdef USE_ORTHOGONAL_PROJECTION
tap_depth = ((tap_depth + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0;
@ -241,7 +224,7 @@ void main() {
float tap_amount = int_ofs == 0 ? 1.0 : smoothstep(dof_begin, dof_end, tap_depth);
tap_amount *= tap_amount * tap_amount; //prevent undesired glow effect
vec4 tap_color = texture2DLod(source_color, tap_uv, 0.0) * tap_k;
vec4 tap_color = textureLod(source_color, tap_uv, 0.0) * tap_k;
k_accum += tap_k * tap_amount;
color_accum += tap_color * tap_amount;
@ -251,7 +234,7 @@ void main() {
color_accum /= k_accum;
}
gl_FragColor = color_accum; ///k_accum;
frag_color = color_accum; ///k_accum;
#endif
@ -268,9 +251,9 @@ void main() {
float tap_k = dof_kernel[i];
vec4 tap_color = texture2DLod(source_color, tap_uv, 0.0);
vec4 tap_color = textureLod(source_color, tap_uv, 0.0);
float tap_depth = texture2D(dof_source_depth, tap_uv, 0.0).r;
float tap_depth = texture(dof_source_depth, tap_uv, 0.0).r;
tap_depth = tap_depth * 2.0 - 1.0;
#ifdef USE_ORTHOGONAL_PROJECTION
tap_depth = ((tap_depth + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0;
@ -293,16 +276,16 @@ void main() {
color_accum.a = max(color_accum.a, sqrt(max_accum));
gl_FragColor = color_accum;
frag_color = color_accum;
#endif
#ifdef GLOW_FIRST_PASS
float luminance = max(gl_FragColor.r, max(gl_FragColor.g, gl_FragColor.b));
float luminance = max(frag_color.r, max(frag_color.g, frag_color.b));
float feedback = max(smoothstep(glow_hdr_threshold, glow_hdr_threshold + glow_hdr_scale, luminance), glow_bloom);
gl_FragColor = min(gl_FragColor * feedback, vec4(luminance_cap));
frag_color = min(frag_color * feedback, vec4(luminance_cap));
#endif
}

View file

@ -10,13 +10,13 @@ precision highp float;
precision highp int;
#endif
attribute highp vec2 vertex; // attrib:0
layout(location = 0) highp vec2 vertex;
/* clang-format on */
uniform vec2 offset;
uniform vec2 scale;
varying vec2 uv_interp;
out vec2 uv_interp;
void main() {
uv_interp = vertex.xy * 2.0 - 1.0;
@ -51,7 +51,9 @@ uniform float k2;
uniform float upscale;
uniform float aspect_ratio;
varying vec2 uv_interp;
in vec2 uv_interp;
layout(location = 0) out vec4 frag_color;
void main() {
vec2 coords = uv_interp;
@ -76,9 +78,9 @@ void main() {
// and check our color
if (coords.x < -1.0 || coords.y < -1.0 || coords.x > 1.0 || coords.y > 1.0) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
frag_color = vec4(0.0, 0.0, 0.0, 1.0);
} else {
coords = (coords + vec2(1.0)) / vec2(2.0);
gl_FragColor = texture2D(source, coords);
frag_color = texture(source, coords);
}
}

View file

@ -10,11 +10,7 @@ precision highp float;
precision highp int;
#endif
/* clang-format on */
#include "stdlib.glsl"
/* clang-format off */
#define SHADER_IS_SRGB true
#define SHADER_IS_SRGB true //TODO remove
#define M_PI 3.14159265359
@ -22,38 +18,38 @@ precision highp int;
// attributes
//
attribute highp vec4 vertex_attrib; // attrib:0
layout(location = 0) highp vec4 vertex_attrib;
/* clang-format on */
attribute vec3 normal_attrib; // attrib:1
layout(location = 1) vec3 normal_attrib;
#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP)
attribute vec4 tangent_attrib; // attrib:2
layout(location = 2) vec4 tangent_attrib;
#endif
#if defined(ENABLE_COLOR_INTERP)
attribute vec4 color_attrib; // attrib:3
layout(location = 3) vec4 color_attrib;
#endif
#if defined(ENABLE_UV_INTERP)
attribute vec2 uv_attrib; // attrib:4
layout(location = 4) vec2 uv_attrib;
#endif
#if defined(ENABLE_UV2_INTERP) || defined(USE_LIGHTMAP)
attribute vec2 uv2_attrib; // attrib:5
layout(location = 5) vec2 uv2_attrib;
#endif
#ifdef USE_SKELETON
#ifdef USE_SKELETON_SOFTWARE
attribute highp vec4 bone_transform_row_0; // attrib:13
attribute highp vec4 bone_transform_row_1; // attrib:14
attribute highp vec4 bone_transform_row_2; // attrib:15
layout(location = 13) highp vec4 bone_transform_row_0;
layout(location = 14) highp vec4 bone_transform_row_1;
layout(location = 15) highp vec4 bone_transform_row_2;
#else
attribute vec4 bone_ids; // attrib:6
attribute highp vec4 bone_weights; // attrib:7
layout(location = 6) vec4 bone_ids;
layout(location = 7) highp vec4 bone_weights;
uniform highp sampler2D bone_transforms; // texunit:-1
uniform ivec2 skeleton_texture_size;
@ -64,12 +60,12 @@ uniform ivec2 skeleton_texture_size;
#ifdef USE_INSTANCING
attribute highp vec4 instance_xform_row_0; // attrib:8
attribute highp vec4 instance_xform_row_1; // attrib:9
attribute highp vec4 instance_xform_row_2; // attrib:10
layout(location = 8) highp vec4 instance_xform_row_0;
layout(location = 9) highp vec4 instance_xform_row_1;
layout(location = 10) highp vec4 instance_xform_row_2;
attribute highp vec4 instance_color; // attrib:11
attribute highp vec4 instance_custom_data; // attrib:12
layout(location = 11) highp vec4 instance_color;
layout(location = 12) highp vec4 instance_custom_data;
#endif
@ -98,27 +94,27 @@ uniform float light_normal_bias;
//
#if defined(RENDER_DEPTH) && defined(USE_RGBA_SHADOWS)
varying highp vec4 position_interp;
out highp vec4 position_interp;
#endif
varying highp vec3 vertex_interp;
varying vec3 normal_interp;
out highp vec3 vertex_interp;
out vec3 normal_interp;
#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP)
varying vec3 tangent_interp;
varying vec3 binormal_interp;
out vec3 tangent_interp;
out vec3 binormal_interp;
#endif
#if defined(ENABLE_COLOR_INTERP)
varying vec4 color_interp;
out vec4 color_interp;
#endif
#if defined(ENABLE_UV_INTERP)
varying vec2 uv_interp;
out vec2 uv_interp;
#endif
#if defined(ENABLE_UV2_INTERP) || defined(USE_LIGHTMAP)
varying vec2 uv2_interp;
out vec2 uv2_interp;
#endif
/* clang-format off */
@ -129,7 +125,7 @@ VERTEX_SHADER_GLOBALS
#ifdef RENDER_DEPTH_DUAL_PARABOLOID
varying highp float dp_clip;
out highp float dp_clip;
uniform highp float shadow_dual_paraboloid_render_zfar;
uniform highp float shadow_dual_paraboloid_render_side;
@ -138,19 +134,19 @@ uniform highp float shadow_dual_paraboloid_render_side;
#if defined(USE_SHADOW) && defined(USE_LIGHTING)
uniform highp mat4 light_shadow_matrix;
varying highp vec4 shadow_coord;
out highp vec4 shadow_coord;
#if defined(LIGHT_USE_PSSM2) || defined(LIGHT_USE_PSSM4)
uniform highp mat4 light_shadow_matrix2;
varying highp vec4 shadow_coord2;
out highp vec4 shadow_coord2;
#endif
#if defined(LIGHT_USE_PSSM4)
uniform highp mat4 light_shadow_matrix3;
uniform highp mat4 light_shadow_matrix4;
varying highp vec4 shadow_coord3;
varying highp vec4 shadow_coord4;
out highp vec4 shadow_coord3;
out highp vec4 shadow_coord4;
#endif
@ -158,8 +154,8 @@ varying highp vec4 shadow_coord4;
#if defined(USE_VERTEX_LIGHTING) && defined(USE_LIGHTING)
varying highp vec3 diffuse_interp;
varying highp vec3 specular_interp;
out highp vec3 diffuse_interp;
out highp vec3 specular_interp;
// general for all lights
uniform highp vec4 light_color;
@ -266,11 +262,11 @@ void light_compute(
#ifdef USE_REFLECTION_PROBE1
uniform highp mat4 refprobe1_local_matrix;
varying mediump vec4 refprobe1_reflection_normal_blend;
out mediump vec4 refprobe1_reflection_normal_blend;
uniform highp vec3 refprobe1_box_extents;
#ifndef USE_LIGHTMAP
varying mediump vec3 refprobe1_ambient_normal;
out mediump vec3 refprobe1_ambient_normal;
#endif
#endif //reflection probe1
@ -278,11 +274,11 @@ varying mediump vec3 refprobe1_ambient_normal;
#ifdef USE_REFLECTION_PROBE2
uniform highp mat4 refprobe2_local_matrix;
varying mediump vec4 refprobe2_reflection_normal_blend;
out mediump vec4 refprobe2_reflection_normal_blend;
uniform highp vec3 refprobe2_box_extents;
#ifndef USE_LIGHTMAP
varying mediump vec3 refprobe2_ambient_normal;
out mediump vec3 refprobe2_ambient_normal;
#endif
#endif //reflection probe2
@ -291,7 +287,7 @@ varying mediump vec3 refprobe2_ambient_normal;
#if defined(FOG_DEPTH_ENABLED) || defined(FOG_HEIGHT_ENABLED)
varying vec4 fog_interp;
out vec4 fog_interp;
uniform mediump vec4 fog_color_base;
#ifdef LIGHT_MODE_DIRECTIONAL
@ -663,25 +659,6 @@ VERTEX_SHADER_CODE
/* clang-format off */
[fragment]
// texture2DLodEXT and textureCubeLodEXT are fragment shader specific.
// Do not copy these defines in the vertex section.
#ifndef USE_GLES_OVER_GL
#ifdef GL_EXT_shader_texture_lod
#extension GL_EXT_shader_texture_lod : enable
#define texture2DLod(img, coord, lod) texture2DLodEXT(img, coord, lod)
#define textureCubeLod(img, coord, lod) textureCubeLodEXT(img, coord, lod)
#endif
#endif // !USE_GLES_OVER_GL
#ifdef GL_ARB_shader_texture_lod
#extension GL_ARB_shader_texture_lod : enable
#endif
#if !defined(GL_EXT_shader_texture_lod) && !defined(GL_ARB_shader_texture_lod)
#define texture2DLod(img, coord, lod) texture2D(img, coord, lod)
#define textureCubeLod(img, coord, lod) textureCube(img, coord, lod)
#endif
#ifdef USE_GLES_OVER_GL
#define lowp
#define mediump
@ -696,8 +673,6 @@ precision mediump int;
#endif
#endif
#include "stdlib.glsl"
#define M_PI 3.14159265359
#define SHADER_IS_SRGB true
@ -732,9 +707,9 @@ uniform highp sampler2D depth_texture; //texunit:-4
#ifdef USE_VERTEX_LIGHTING
varying mediump vec4 refprobe1_reflection_normal_blend;
in mediump vec4 refprobe1_reflection_normal_blend;
#ifndef USE_LIGHTMAP
varying mediump vec3 refprobe1_ambient_normal;
in mediump vec3 refprobe1_ambient_normal;
#endif
#else
@ -759,9 +734,9 @@ uniform vec4 refprobe1_ambient;
#ifdef USE_VERTEX_LIGHTING
varying mediump vec4 refprobe2_reflection_normal_blend;
in mediump vec4 refprobe2_reflection_normal_blend;
#ifndef USE_LIGHTMAP
varying mediump vec3 refprobe2_ambient_normal;
in mediump vec3 refprobe2_ambient_normal;
#endif
#else
@ -909,8 +884,8 @@ uniform highp vec4 shadow_color;
#ifdef USE_VERTEX_LIGHTING
//get from vertex
varying highp vec3 diffuse_interp;
varying highp vec3 specular_interp;
in highp vec3 diffuse_interp;
in highp vec3 specular_interp;
uniform highp vec3 light_direction; //may be used by fog, so leave here
@ -950,16 +925,16 @@ uniform highp sampler2D light_directional_shadow; // texunit:-3
uniform highp vec4 light_split_offsets;
#endif
varying highp vec4 shadow_coord;
in highp vec4 shadow_coord;
#if defined(LIGHT_USE_PSSM2) || defined(LIGHT_USE_PSSM4)
varying highp vec4 shadow_coord2;
in highp vec4 shadow_coord2;
#endif
#if defined(LIGHT_USE_PSSM4)
varying highp vec4 shadow_coord3;
varying highp vec4 shadow_coord4;
in highp vec4 shadow_coord3;
in highp vec4 shadow_coord4;
#endif
@ -976,30 +951,32 @@ uniform vec4 light_clamp;
//
#if defined(RENDER_DEPTH) && defined(USE_RGBA_SHADOWS)
varying highp vec4 position_interp;
in highp vec4 position_interp;
#endif
varying highp vec3 vertex_interp;
varying vec3 normal_interp;
in highp vec3 vertex_interp;
in vec3 normal_interp;
#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP)
varying vec3 tangent_interp;
varying vec3 binormal_interp;
in vec3 tangent_interp;
in vec3 binormal_interp;
#endif
#if defined(ENABLE_COLOR_INTERP)
varying vec4 color_interp;
in vec4 color_interp;
#endif
#if defined(ENABLE_UV_INTERP)
varying vec2 uv_interp;
in vec2 uv_interp;
#endif
#if defined(ENABLE_UV2_INTERP) || defined(USE_LIGHTMAP)
varying vec2 uv2_interp;
in vec2 uv2_interp;
#endif
varying vec3 view_interp;
in vec3 view_interp;
layout(location = 0) out vec4 frag_color;
vec3 F0(float metallic, float specular, vec3 albedo) {
float dielectric = 0.16 * specular * specular;
@ -1016,7 +993,7 @@ FRAGMENT_SHADER_GLOBALS
#ifdef RENDER_DEPTH_DUAL_PARABOLOID
varying highp float dp_clip;
in highp float dp_clip;
#endif
@ -1354,8 +1331,8 @@ LIGHT_SHADER_CODE
#endif
#define SAMPLE_SHADOW_TEXEL(p_shadow, p_pos, p_depth) step(p_depth, SHADOW_DEPTH(texture2D(p_shadow, p_pos)))
#define SAMPLE_SHADOW_TEXEL_PROJ(p_shadow, p_pos) step(p_pos.z, SHADOW_DEPTH(texture2DProj(p_shadow, p_pos)))
#define SAMPLE_SHADOW_TEXEL(p_shadow, p_pos, p_depth) step(p_depth, SHADOW_DEPTH(texture(p_shadow, p_pos)))
#define SAMPLE_SHADOW_TEXEL_PROJ(p_shadow, p_pos) step(p_pos.z, SHADOW_DEPTH(textureProj(p_shadow, p_pos)))
float sample_shadow(highp sampler2D shadow, highp vec4 spos) {
#ifdef SHADOW_MODE_PCF_13
@ -1407,7 +1384,7 @@ float sample_shadow(highp sampler2D shadow, highp vec4 spos) {
#if defined(USE_VERTEX_LIGHTING)
varying vec4 fog_interp;
in vec4 fog_interp;
#else
uniform mediump vec4 fog_color_base;
@ -1648,7 +1625,7 @@ FRAGMENT_SHADER_CODE
#ifdef USE_LIGHTMAP
//ambient light will come entirely from lightmap is lightmap is used
ambient_light = texture2D(lightmap, uv2_interp).rgb * lightmap_energy;
ambient_light = texture(lightmap, uv2_interp).rgb * lightmap_energy;
#endif
#ifdef USE_LIGHTMAP_CAPTURE
@ -2084,7 +2061,7 @@ FRAGMENT_SHADER_CODE
#ifdef SHADELESS
gl_FragColor = vec4(albedo, alpha);
frag_color = vec4(albedo, alpha);
#else
ambient_light *= albedo;
@ -2099,13 +2076,13 @@ FRAGMENT_SHADER_CODE
diffuse_light *= 1.0 - metallic;
ambient_light *= 1.0 - metallic;
gl_FragColor = vec4(ambient_light + diffuse_light + specular_light, alpha);
frag_color = vec4(ambient_light + diffuse_light + specular_light, alpha);
//add emission if in base pass
#ifdef BASE_PASS
gl_FragColor.rgb += emission;
frag_color.rgb += emission;
#endif
// gl_FragColor = vec4(normal, 1.0);
// frag_color = vec4(normal, 1.0);
//apply fog
#if defined(FOG_DEPTH_ENABLED) || defined(FOG_HEIGHT_ENABLED)
@ -2113,9 +2090,9 @@ FRAGMENT_SHADER_CODE
#if defined(USE_VERTEX_LIGHTING)
#if defined(BASE_PASS)
gl_FragColor.rgb = mix(gl_FragColor.rgb, fog_interp.rgb, fog_interp.a);
frag_color.rgb = mix(frag_color.rgb, fog_interp.rgb, fog_interp.a);
#else
gl_FragColor.rgb *= (1.0 - fog_interp.a);
frag_color.rgb *= (1.0 - fog_interp.a);
#endif // BASE_PASS
#else //pixel based fog
@ -2136,7 +2113,7 @@ FRAGMENT_SHADER_CODE
fog_amount = pow(fog_z, fog_depth_curve) * fog_color_base.a;
if (fog_transmit_enabled) {
vec3 total_light = gl_FragColor.rgb;
vec3 total_light = frag_color.rgb;
float transmit = pow(fog_z, fog_transmit_curve);
fog_color = mix(max(total_light, fog_color), fog_color, transmit);
}
@ -2151,9 +2128,9 @@ FRAGMENT_SHADER_CODE
#endif
#if defined(BASE_PASS)
gl_FragColor.rgb = mix(gl_FragColor.rgb, fog_color, fog_amount);
frag_color.rgb = mix(frag_color.rgb, fog_color, fog_amount);
#else
gl_FragColor.rgb *= (1.0 - fog_amount);
frag_color.rgb *= (1.0 - fog_amount);
#endif // BASE_PASS
#endif //use vertex lit
@ -2169,7 +2146,7 @@ FRAGMENT_SHADER_CODE
highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0; // bias
highp vec4 comp = fract(depth * vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0));
comp -= comp.xxyz * vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
gl_FragColor = comp;
frag_color = comp;
#endif
#endif

View file

@ -10,11 +10,11 @@ precision highp float;
precision highp int;
#endif
attribute vec2 vertex_attrib; // attrib:0
layout(location = 0) vec2 vertex_attrib;
/* clang-format on */
attribute vec2 uv_in; // attrib:4
layout(location = 4) vec2 uv_in;
varying vec2 uv_interp;
out vec2 uv_interp;
void main() {
gl_Position = vec4(vertex_attrib, 0.0, 1.0);
@ -25,30 +25,6 @@ void main() {
/* clang-format off */
[fragment]
// texture2DLodEXT and textureCubeLodEXT are fragment shader specific.
// Do not copy these defines in the vertex section.
#ifndef USE_GLES_OVER_GL
#ifdef GL_EXT_shader_texture_lod
#extension GL_EXT_shader_texture_lod : enable
#define texture2DLod(img, coord, lod) texture2DLodEXT(img, coord, lod)
#define textureCubeLod(img, coord, lod) textureCubeLodEXT(img, coord, lod)
#endif
#endif // !USE_GLES_OVER_GL
#ifdef GL_ARB_shader_texture_lod
#extension GL_ARB_shader_texture_lod : enable
#endif
#if !defined(GL_EXT_shader_texture_lod) && !defined(GL_ARB_shader_texture_lod)
#define texture2DLod(img, coord, lod) texture2D(img, coord, lod)
#define textureCubeLod(img, coord, lod) textureCube(img, coord, lod)
#endif
// Allows the use of bitshift operators for bicubic upscale
#ifdef GL_EXT_gpu_shader4
#extension GL_EXT_gpu_shader4 : enable
#endif
#ifdef USE_GLES_OVER_GL
#define lowp
#define mediump
@ -63,11 +39,11 @@ precision mediump int;
#endif
#endif
#include "stdlib.glsl"
varying vec2 uv_interp;
in vec2 uv_interp;
/* clang-format on */
layout(location = 0) out vec4 frag_color;
uniform highp sampler2D source; //texunit:0
#if defined(USE_GLOW_LEVEL1) || defined(USE_GLOW_LEVEL2) || defined(USE_GLOW_LEVEL3) || defined(USE_GLOW_LEVEL4) || defined(USE_GLOW_LEVEL5) || defined(USE_GLOW_LEVEL6) || defined(USE_GLOW_LEVEL7)
@ -101,7 +77,6 @@ uniform vec2 pixel_size;
uniform sampler2D color_correction; //texunit:1
#endif
#ifdef GL_EXT_gpu_shader4
#ifdef USE_GLOW_FILTER_BICUBIC
// w0, w1, w2, and w3 are the four cubic B-spline basis functions
float w0(float a) {
@ -140,7 +115,7 @@ float h1(float a) {
uniform ivec2 glow_texture_size;
vec4 texture2D_bicubic(sampler2D tex, vec2 uv, int p_lod) {
vec4 texture_bicubic(sampler2D tex, vec2 uv, int p_lod) {
float lod = float(p_lod);
vec2 tex_size = vec2(glow_texture_size >> p_lod);
vec2 texel_size = vec2(1.0) / tex_size;
@ -162,19 +137,15 @@ vec4 texture2D_bicubic(sampler2D tex, vec2 uv, int p_lod) {
vec2 p2 = (vec2(iuv.x + h0x, iuv.y + h1y) - vec2(0.5)) * texel_size;
vec2 p3 = (vec2(iuv.x + h1x, iuv.y + h1y) - vec2(0.5)) * texel_size;
return (g0(fuv.y) * (g0x * texture2DLod(tex, p0, lod) + g1x * texture2DLod(tex, p1, lod))) +
(g1(fuv.y) * (g0x * texture2DLod(tex, p2, lod) + g1x * texture2DLod(tex, p3, lod)));
return (g0(fuv.y) * (g0x * textureLod(tex, p0, lod) + g1x * textureLod(tex, p1, lod))) +
(g1(fuv.y) * (g0x * textureLod(tex, p2, lod) + g1x * textureLod(tex, p3, lod)));
}
#define GLOW_TEXTURE_SAMPLE(m_tex, m_uv, m_lod) texture2D_bicubic(m_tex, m_uv, m_lod)
#define GLOW_TEXTURE_SAMPLE(m_tex, m_uv, m_lod) texture_bicubic(m_tex, m_uv, m_lod)
#else //!USE_GLOW_FILTER_BICUBIC
#define GLOW_TEXTURE_SAMPLE(m_tex, m_uv, m_lod) texture2DLod(m_tex, m_uv, float(m_lod))
#define GLOW_TEXTURE_SAMPLE(m_tex, m_uv, m_lod) textureLod(m_tex, m_uv, float(m_lod))
#endif //USE_GLOW_FILTER_BICUBIC
#else //!GL_EXT_gpu_shader4
#define GLOW_TEXTURE_SAMPLE(m_tex, m_uv, m_lod) texture2DLod(m_tex, m_uv, float(m_lod))
#endif //GL_EXT_gpu_shader4
vec3 apply_glow(vec3 color, vec3 glow) { // apply glow using the selected blending mode
#ifdef USE_GLOW_REPLACE
color = glow;
@ -208,9 +179,9 @@ vec3 apply_bcs(vec3 color, vec3 bcs) {
}
vec3 apply_color_correction(vec3 color, sampler2D correction_tex) {
color.r = texture2D(correction_tex, vec2(color.r, 0.0)).r;
color.g = texture2D(correction_tex, vec2(color.g, 0.0)).g;
color.b = texture2D(correction_tex, vec2(color.b, 0.0)).b;
color.r = texture(correction_tex, vec2(color.r, 0.0)).r;
color.g = texture(correction_tex, vec2(color.g, 0.0)).g;
color.b = texture(correction_tex, vec2(color.b, 0.0)).b;
return color;
}
@ -220,10 +191,10 @@ vec3 apply_fxaa(vec3 color, vec2 uv_interp, vec2 pixel_size) {
const float FXAA_REDUCE_MUL = (1.0 / 8.0);
const float FXAA_SPAN_MAX = 8.0;
vec3 rgbNW = texture2DLod(source, uv_interp + vec2(-1.0, -1.0) * pixel_size, 0.0).xyz;
vec3 rgbNE = texture2DLod(source, uv_interp + vec2(1.0, -1.0) * pixel_size, 0.0).xyz;
vec3 rgbSW = texture2DLod(source, uv_interp + vec2(-1.0, 1.0) * pixel_size, 0.0).xyz;
vec3 rgbSE = texture2DLod(source, uv_interp + vec2(1.0, 1.0) * pixel_size, 0.0).xyz;
vec3 rgbNW = textureLod(source, uv_interp + vec2(-1.0, -1.0) * pixel_size, 0.0).xyz;
vec3 rgbNE = textureLod(source, uv_interp + vec2(1.0, -1.0) * pixel_size, 0.0).xyz;
vec3 rgbSW = textureLod(source, uv_interp + vec2(-1.0, 1.0) * pixel_size, 0.0).xyz;
vec3 rgbSE = textureLod(source, uv_interp + vec2(1.0, 1.0) * pixel_size, 0.0).xyz;
vec3 rgbM = color;
vec3 luma = vec3(0.299, 0.587, 0.114);
float lumaNW = dot(rgbNW, luma);
@ -239,18 +210,17 @@ vec3 apply_fxaa(vec3 color, vec2 uv_interp, vec2 pixel_size) {
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *
(0.25 * FXAA_REDUCE_MUL),
(0.25 * FXAA_REDUCE_MUL),
FXAA_REDUCE_MIN);
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
dir * rcpDirMin)) *
pixel_size;
pixel_size;
vec3 rgbA = 0.5 * (texture2DLod(source, uv_interp + dir * (1.0 / 3.0 - 0.5), 0.0).xyz + texture2DLod(source, uv_interp + dir * (2.0 / 3.0 - 0.5), 0.0).xyz);
vec3 rgbB = rgbA * 0.5 + 0.25 * (texture2DLod(source, uv_interp + dir * -0.5, 0.0).xyz +
texture2DLod(source, uv_interp + dir * 0.5, 0.0).xyz);
vec3 rgbA = 0.5 * (textureLod(source, uv_interp + dir * (1.0 / 3.0 - 0.5), 0.0).xyz + textureLod(source, uv_interp + dir * (2.0 / 3.0 - 0.5), 0.0).xyz);
vec3 rgbB = rgbA * 0.5 + 0.25 * (textureLod(source, uv_interp + dir * -0.5, 0.0).xyz + textureLod(source, uv_interp + dir * 0.5, 0.0).xyz);
float lumaB = dot(rgbB, luma);
if ((lumaB < lumaMin) || (lumaB > lumaMax)) {
@ -261,7 +231,7 @@ vec3 apply_fxaa(vec3 color, vec2 uv_interp, vec2 pixel_size) {
}
void main() {
vec3 color = texture2DLod(source, uv_interp, 0.0).rgb;
vec3 color = textureLod(source, uv_interp, 0.0).rgb;
#ifdef USE_FXAA
color = apply_fxaa(color, uv_interp, pixel_size);
@ -339,5 +309,5 @@ void main() {
color = apply_color_correction(color, color_correction);
#endif
gl_FragColor = vec4(color, 1.0);
frag_color = vec4(color, 1.0);
}

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* texture_loader_opengl.cpp */
/* texture_loader_gles3.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "texture_loader_opengl.h"
#ifdef OPENGL_BACKEND_ENABLED
#include "texture_loader_gles3.h"
#ifdef GLES3_BACKEND_ENABLED
#include "core/io/file_access.h"
#include "core/string/print_string.h"

View file

@ -1,5 +1,5 @@
/*************************************************************************/
/* texture_loader_opengl.h */
/* texture_loader_gles3.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -31,8 +31,8 @@
#ifndef TEXTURE_LOADER_OPENGL_H
#define TEXTURE_LOADER_OPENGL_H
#include "drivers/opengl/rasterizer_platforms.h"
#ifdef OPENGL_BACKEND_ENABLED
#include "drivers/gles3/rasterizer_platforms.h"
#ifdef GLES3_BACKEND_ENABLED
#include "core/io/resource_loader.h"
#include "scene/resources/texture.h"
@ -47,6 +47,6 @@ public:
virtual ~ResourceFormatGLES2Texture() {}
};
#endif // OPENGL_BACKEND_ENABLED
#endif // GLES3_BACKEND_ENABLED
#endif // TEXTURE_LOADER_OPENGL_H

View file

@ -1,439 +0,0 @@
/*************************************************************************/
/* rasterizer_scene_opengl.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "rasterizer_scene_opengl.h"
#ifdef OPENGL_BACKEND_ENABLED
// TODO: 3D support not implemented yet.
RasterizerSceneOpenGL::GeometryInstance *RasterizerSceneOpenGL::geometry_instance_create(RID p_base) {
return nullptr;
}
void RasterizerSceneOpenGL::geometry_instance_set_skeleton(GeometryInstance *p_geometry_instance, RID p_skeleton) {
}
void RasterizerSceneOpenGL::geometry_instance_set_material_override(GeometryInstance *p_geometry_instance, RID p_override) {
}
void RasterizerSceneOpenGL::geometry_instance_set_surface_materials(GeometryInstance *p_geometry_instance, const Vector<RID> &p_material) {
}
void RasterizerSceneOpenGL::geometry_instance_set_mesh_instance(GeometryInstance *p_geometry_instance, RID p_mesh_instance) {
}
void RasterizerSceneOpenGL::geometry_instance_set_transform(GeometryInstance *p_geometry_instance, const Transform3D &p_transform, const AABB &p_aabb, const AABB &p_transformed_aabbb) {
}
void RasterizerSceneOpenGL::geometry_instance_set_layer_mask(GeometryInstance *p_geometry_instance, uint32_t p_layer_mask) {
}
void RasterizerSceneOpenGL::geometry_instance_set_lod_bias(GeometryInstance *p_geometry_instance, float p_lod_bias) {
}
void RasterizerSceneOpenGL::geometry_instance_set_use_baked_light(GeometryInstance *p_geometry_instance, bool p_enable) {
}
void RasterizerSceneOpenGL::geometry_instance_set_use_dynamic_gi(GeometryInstance *p_geometry_instance, bool p_enable) {
}
void RasterizerSceneOpenGL::geometry_instance_set_use_lightmap(GeometryInstance *p_geometry_instance, RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) {
}
void RasterizerSceneOpenGL::geometry_instance_set_lightmap_capture(GeometryInstance *p_geometry_instance, const Color *p_sh9) {
}
void RasterizerSceneOpenGL::geometry_instance_set_instance_shader_parameters_offset(GeometryInstance *p_geometry_instance, int32_t p_offset) {
}
void RasterizerSceneOpenGL::geometry_instance_set_cast_double_sided_shadows(GeometryInstance *p_geometry_instance, bool p_enable) {
}
uint32_t RasterizerSceneOpenGL::geometry_instance_get_pair_mask() {
return 0;
}
void RasterizerSceneOpenGL::geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count) {
}
void RasterizerSceneOpenGL::geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) {
}
void RasterizerSceneOpenGL::geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) {
}
void RasterizerSceneOpenGL::geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) {
}
void RasterizerSceneOpenGL::geometry_instance_set_softshadow_projector_pairing(GeometryInstance *p_geometry_instance, bool p_softshadow, bool p_projector) {
}
void RasterizerSceneOpenGL::geometry_instance_free(GeometryInstance *p_geometry_instance) {
}
/* SHADOW ATLAS API */
RID RasterizerSceneOpenGL::shadow_atlas_create() {
return RID();
}
void RasterizerSceneOpenGL::shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits) {
}
void RasterizerSceneOpenGL::shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) {
}
bool RasterizerSceneOpenGL::shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) {
return false;
}
void RasterizerSceneOpenGL::directional_shadow_atlas_set_size(int p_size, bool p_16_bits) {
}
int RasterizerSceneOpenGL::get_directional_light_shadow_size(RID p_light_intance) {
return 0;
}
void RasterizerSceneOpenGL::set_directional_shadow_count(int p_count) {
}
/* SDFGI UPDATE */
void RasterizerSceneOpenGL::sdfgi_update(RID p_render_buffers, RID p_environment, const Vector3 &p_world_position) {
}
int RasterizerSceneOpenGL::sdfgi_get_pending_region_count(RID p_render_buffers) const {
return 0;
}
AABB RasterizerSceneOpenGL::sdfgi_get_pending_region_bounds(RID p_render_buffers, int p_region) const {
return AABB();
}
uint32_t RasterizerSceneOpenGL::sdfgi_get_pending_region_cascade(RID p_render_buffers, int p_region) const {
return 0;
}
/* SKY API */
RID RasterizerSceneOpenGL::sky_allocate() {
return RID();
}
void RasterizerSceneOpenGL::sky_initialize(RID p_rid) {
}
void RasterizerSceneOpenGL::sky_set_radiance_size(RID p_sky, int p_radiance_size) {
}
void RasterizerSceneOpenGL::sky_set_mode(RID p_sky, RS::SkyMode p_samples) {
}
void RasterizerSceneOpenGL::sky_set_material(RID p_sky, RID p_material) {
}
Ref<Image> RasterizerSceneOpenGL::sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) {
return Ref<Image>();
}
/* ENVIRONMENT API */
RID RasterizerSceneOpenGL::environment_allocate() {
return RID();
}
void RasterizerSceneOpenGL::environment_initialize(RID p_rid) {
}
void RasterizerSceneOpenGL::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) {
}
void RasterizerSceneOpenGL::environment_set_sky(RID p_env, RID p_sky) {
}
void RasterizerSceneOpenGL::environment_set_sky_custom_fov(RID p_env, float p_scale) {
}
void RasterizerSceneOpenGL::environment_set_sky_orientation(RID p_env, const Basis &p_orientation) {
}
void RasterizerSceneOpenGL::environment_set_bg_color(RID p_env, const Color &p_color) {
}
void RasterizerSceneOpenGL::environment_set_bg_energy(RID p_env, float p_energy) {
}
void RasterizerSceneOpenGL::environment_set_canvas_max_layer(RID p_env, int p_max_layer) {
}
void RasterizerSceneOpenGL::environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source) {
}
void RasterizerSceneOpenGL::environment_set_glow(RID p_env, bool p_enable, Vector<float> p_levels, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) {
}
void RasterizerSceneOpenGL::environment_glow_set_use_bicubic_upscale(bool p_enable) {
}
void RasterizerSceneOpenGL::environment_glow_set_use_high_quality(bool p_enable) {
}
void RasterizerSceneOpenGL::environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) {
}
void RasterizerSceneOpenGL::environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality) {
}
void RasterizerSceneOpenGL::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_power, float p_detail, float p_horizon, float p_sharpness, float p_light_affect, float p_ao_channel_affect) {
}
void RasterizerSceneOpenGL::environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) {
}
void RasterizerSceneOpenGL::environment_set_sdfgi(RID p_env, bool p_enable, RS::EnvironmentSDFGICascades p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, float p_bounce_feedback, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias) {
}
void RasterizerSceneOpenGL::environment_set_sdfgi_ray_count(RS::EnvironmentSDFGIRayCount p_ray_count) {
}
void RasterizerSceneOpenGL::environment_set_sdfgi_frames_to_converge(RS::EnvironmentSDFGIFramesToConverge p_frames) {
}
void RasterizerSceneOpenGL::environment_set_sdfgi_frames_to_update_light(RS::EnvironmentSDFGIFramesToUpdateLight p_update) {
}
void RasterizerSceneOpenGL::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {
}
void RasterizerSceneOpenGL::environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, bool p_use_1d_color_correction, RID p_color_correction) {
}
void RasterizerSceneOpenGL::environment_set_fog(RID p_env, bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_aerial_perspective) {
}
void RasterizerSceneOpenGL::environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_light, float p_light_energy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount) {
}
void RasterizerSceneOpenGL::environment_set_volumetric_fog_volume_size(int p_size, int p_depth) {
}
void RasterizerSceneOpenGL::environment_set_volumetric_fog_filter_active(bool p_enable) {
}
Ref<Image> RasterizerSceneOpenGL::environment_bake_panorama(RID p_env, bool p_bake_irradiance, const Size2i &p_size) {
return Ref<Image>();
}
bool RasterizerSceneOpenGL::is_environment(RID p_env) const {
return false;
}
RS::EnvironmentBG RasterizerSceneOpenGL::environment_get_background(RID p_env) const {
return RS::ENV_BG_KEEP;
}
int RasterizerSceneOpenGL::environment_get_canvas_max_layer(RID p_env) const {
return 0;
}
RID RasterizerSceneOpenGL::camera_effects_allocate() {
return RID();
}
void RasterizerSceneOpenGL::camera_effects_initialize(RID p_rid) {
}
void RasterizerSceneOpenGL::camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) {
}
void RasterizerSceneOpenGL::camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) {
}
void RasterizerSceneOpenGL::camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) {
}
void RasterizerSceneOpenGL::camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) {
}
void RasterizerSceneOpenGL::shadows_quality_set(RS::ShadowQuality p_quality) {
}
void RasterizerSceneOpenGL::directional_shadow_quality_set(RS::ShadowQuality p_quality) {
}
RID RasterizerSceneOpenGL::light_instance_create(RID p_light) {
return RID();
}
void RasterizerSceneOpenGL::light_instance_set_transform(RID p_light_instance, const Transform3D &p_transform) {
}
void RasterizerSceneOpenGL::light_instance_set_aabb(RID p_light_instance, const AABB &p_aabb) {
}
void RasterizerSceneOpenGL::light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale, float p_range_begin, const Vector2 &p_uv_scale) {
}
void RasterizerSceneOpenGL::light_instance_mark_visible(RID p_light_instance) {
}
RID RasterizerSceneOpenGL::reflection_atlas_create() {
return RID();
}
int RasterizerSceneOpenGL::reflection_atlas_get_size(RID p_ref_atlas) const {
return 0;
}
void RasterizerSceneOpenGL::reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) {
}
RID RasterizerSceneOpenGL::reflection_probe_instance_create(RID p_probe) {
return RID();
}
void RasterizerSceneOpenGL::reflection_probe_instance_set_transform(RID p_instance, const Transform3D &p_transform) {
}
void RasterizerSceneOpenGL::reflection_probe_release_atlas_index(RID p_instance) {
}
bool RasterizerSceneOpenGL::reflection_probe_instance_needs_redraw(RID p_instance) {
return false;
}
bool RasterizerSceneOpenGL::reflection_probe_instance_has_reflection(RID p_instance) {
return false;
}
bool RasterizerSceneOpenGL::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) {
return false;
}
bool RasterizerSceneOpenGL::reflection_probe_instance_postprocess_step(RID p_instance) {
return true;
}
RID RasterizerSceneOpenGL::decal_instance_create(RID p_decal) {
return RID();
}
void RasterizerSceneOpenGL::decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) {
}
RID RasterizerSceneOpenGL::lightmap_instance_create(RID p_lightmap) {
return RID();
}
void RasterizerSceneOpenGL::lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) {
}
RID RasterizerSceneOpenGL::voxel_gi_instance_create(RID p_voxel_gi) {
return RID();
}
void RasterizerSceneOpenGL::voxel_gi_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) {
}
bool RasterizerSceneOpenGL::voxel_gi_needs_update(RID p_probe) const {
return false;
}
void RasterizerSceneOpenGL::voxel_gi_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects) {
}
void RasterizerSceneOpenGL::voxel_gi_set_quality(RS::VoxelGIQuality) {
}
void RasterizerSceneOpenGL::render_scene(RID p_render_buffers, const CameraData *p_camera_data, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data, RendererScene::RenderInfo *r_info) {
}
void RasterizerSceneOpenGL::render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) {
}
void RasterizerSceneOpenGL::render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray<GeometryInstance *> &p_instances) {
}
void RasterizerSceneOpenGL::set_scene_pass(uint64_t p_pass) {
}
void RasterizerSceneOpenGL::set_time(double p_time, double p_step) {
}
void RasterizerSceneOpenGL::set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) {
}
RID RasterizerSceneOpenGL::render_buffers_create() {
return RID();
}
void RasterizerSceneOpenGL::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) {
}
void RasterizerSceneOpenGL::gi_set_use_half_resolution(bool p_enable) {
}
void RasterizerSceneOpenGL::screen_space_roughness_limiter_set_active(bool p_enable, float p_amount, float p_curve) {
}
bool RasterizerSceneOpenGL::screen_space_roughness_limiter_is_active() const {
return false;
}
void RasterizerSceneOpenGL::sub_surface_scattering_set_quality(RS::SubSurfaceScatteringQuality p_quality) {
}
void RasterizerSceneOpenGL::sub_surface_scattering_set_scale(float p_scale, float p_depth_scale) {
}
TypedArray<Image> RasterizerSceneOpenGL::bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size) {
return TypedArray<Image>();
}
bool RasterizerSceneOpenGL::free(RID p_rid) {
return false;
}
void RasterizerSceneOpenGL::update() {
}
void RasterizerSceneOpenGL::sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) {
}
void RasterizerSceneOpenGL::decals_set_filter(RS::DecalFilter p_filter) {
}
void RasterizerSceneOpenGL::light_projectors_set_filter(RS::LightProjectorFilter p_filter) {
}
RasterizerSceneOpenGL::RasterizerSceneOpenGL() {
}
#endif // OPENGL_BACKEND_ENABLED

View file

@ -1,14 +0,0 @@
#!/usr/bin/env python
Import("env")
if "OpenGL_GLSL" in env["BUILDERS"]:
env.OpenGL_GLSL("copy.glsl")
env.OpenGL_GLSL("canvas.glsl")
env.OpenGL_GLSL("canvas_shadow.glsl")
env.OpenGL_GLSL("scene.glsl")
env.OpenGL_GLSL("cubemap_filter.glsl")
env.OpenGL_GLSL("cube_to_dp.glsl")
env.OpenGL_GLSL("effect_blur.glsl")
env.OpenGL_GLSL("tonemap.glsl")
env.OpenGL_GLSL("lens_distorted.glsl")

View file

@ -1,420 +0,0 @@
vec2 select2(vec2 a, vec2 b, bvec2 c) {
vec2 ret;
ret.x = c.x ? b.x : a.x;
ret.y = c.y ? b.y : a.y;
return ret;
}
vec3 select3(vec3 a, vec3 b, bvec3 c) {
vec3 ret;
ret.x = c.x ? b.x : a.x;
ret.y = c.y ? b.y : a.y;
ret.z = c.z ? b.z : a.z;
return ret;
}
vec4 select4(vec4 a, vec4 b, bvec4 c) {
vec4 ret;
ret.x = c.x ? b.x : a.x;
ret.y = c.y ? b.y : a.y;
ret.z = c.z ? b.z : a.z;
ret.w = c.w ? b.w : a.w;
return ret;
}
highp vec4 texel2DFetch(highp sampler2D tex, ivec2 size, ivec2 coord) {
float x_coord = float(2 * coord.x + 1) / float(size.x * 2);
float y_coord = float(2 * coord.y + 1) / float(size.y * 2);
return texture2DLod(tex, vec2(x_coord, y_coord), 0.0);
}
#if defined(SINH_USED)
highp float sinh(highp float x) {
return 0.5 * (exp(x) - exp(-x));
}
highp vec2 sinh(highp vec2 x) {
return 0.5 * vec2(exp(x.x) - exp(-x.x), exp(x.y) - exp(-x.y));
}
highp vec3 sinh(highp vec3 x) {
return 0.5 * vec3(exp(x.x) - exp(-x.x), exp(x.y) - exp(-x.y), exp(x.z) - exp(-x.z));
}
highp vec4 sinh(highp vec4 x) {
return 0.5 * vec4(exp(x.x) - exp(-x.x), exp(x.y) - exp(-x.y), exp(x.z) - exp(-x.z), exp(x.w) - exp(-x.w));
}
#endif
#if defined(COSH_USED)
highp float cosh(highp float x) {
return 0.5 * (exp(x) + exp(-x));
}
highp vec2 cosh(highp vec2 x) {
return 0.5 * vec2(exp(x.x) + exp(-x.x), exp(x.y) + exp(-x.y));
}
highp vec3 cosh(highp vec3 x) {
return 0.5 * vec3(exp(x.x) + exp(-x.x), exp(x.y) + exp(-x.y), exp(x.z) + exp(-x.z));
}
highp vec4 cosh(highp vec4 x) {
return 0.5 * vec4(exp(x.x) + exp(-x.x), exp(x.y) + exp(-x.y), exp(x.z) + exp(-x.z), exp(x.w) + exp(-x.w));
}
#endif
#if defined(TANH_USED)
highp float tanh(highp float x) {
highp float exp2x = exp(2.0 * x);
return (exp2x - 1.0) / (exp2x + 1.0);
}
highp vec2 tanh(highp vec2 x) {
highp float exp2x = exp(2.0 * x.x);
highp float exp2y = exp(2.0 * x.y);
return vec2((exp2x - 1.0) / (exp2x + 1.0), (exp2y - 1.0) / (exp2y + 1.0));
}
highp vec3 tanh(highp vec3 x) {
highp float exp2x = exp(2.0 * x.x);
highp float exp2y = exp(2.0 * x.y);
highp float exp2z = exp(2.0 * x.z);
return vec3((exp2x - 1.0) / (exp2x + 1.0), (exp2y - 1.0) / (exp2y + 1.0), (exp2z - 1.0) / (exp2z + 1.0));
}
highp vec4 tanh(highp vec4 x) {
highp float exp2x = exp(2.0 * x.x);
highp float exp2y = exp(2.0 * x.y);
highp float exp2z = exp(2.0 * x.z);
highp float exp2w = exp(2.0 * x.w);
return vec4((exp2x - 1.0) / (exp2x + 1.0), (exp2y - 1.0) / (exp2y + 1.0), (exp2z - 1.0) / (exp2z + 1.0), (exp2w - 1.0) / (exp2w + 1.0));
}
#endif
#if defined(ASINH_USED)
highp float asinh(highp float x) {
return sign(x) * log(abs(x) + sqrt(1.0 + x * x));
}
highp vec2 asinh(highp vec2 x) {
return vec2(sign(x.x) * log(abs(x.x) + sqrt(1.0 + x.x * x.x)), sign(x.y) * log(abs(x.y) + sqrt(1.0 + x.y * x.y)));
}
highp vec3 asinh(highp vec3 x) {
return vec3(sign(x.x) * log(abs(x.x) + sqrt(1.0 + x.x * x.x)), sign(x.y) * log(abs(x.y) + sqrt(1.0 + x.y * x.y)), sign(x.z) * log(abs(x.z) + sqrt(1.0 + x.z * x.z)));
}
highp vec4 asinh(highp vec4 x) {
return vec4(sign(x.x) * log(abs(x.x) + sqrt(1.0 + x.x * x.x)), sign(x.y) * log(abs(x.y) + sqrt(1.0 + x.y * x.y)), sign(x.z) * log(abs(x.z) + sqrt(1.0 + x.z * x.z)), sign(x.w) * log(abs(x.w) + sqrt(1.0 + x.w * x.w)));
}
#endif
#if defined(ACOSH_USED)
highp float acosh(highp float x) {
return log(x + sqrt(x * x - 1.0));
}
highp vec2 acosh(highp vec2 x) {
return vec2(log(x.x + sqrt(x.x * x.x - 1.0)), log(x.y + sqrt(x.y * x.y - 1.0)));
}
highp vec3 acosh(highp vec3 x) {
return vec3(log(x.x + sqrt(x.x * x.x - 1.0)), log(x.y + sqrt(x.y * x.y - 1.0)), log(x.z + sqrt(x.z * x.z - 1.0)));
}
highp vec4 acosh(highp vec4 x) {
return vec4(log(x.x + sqrt(x.x * x.x - 1.0)), log(x.y + sqrt(x.y * x.y - 1.0)), log(x.z + sqrt(x.z * x.z - 1.0)), log(x.w + sqrt(x.w * x.w - 1.0)));
}
#endif
#if defined(ATANH_USED)
highp float atanh(highp float x) {
return 0.5 * log((1.0 + x) / (1.0 - x));
}
highp vec2 atanh(highp vec2 x) {
return 0.5 * vec2(log((1.0 + x.x) / (1.0 - x.x)), log((1.0 + x.y) / (1.0 - x.y)));
}
highp vec3 atanh(highp vec3 x) {
return 0.5 * vec3(log((1.0 + x.x) / (1.0 - x.x)), log((1.0 + x.y) / (1.0 - x.y)), log((1.0 + x.z) / (1.0 - x.z)));
}
highp vec4 atanh(highp vec4 x) {
return 0.5 * vec4(log((1.0 + x.x) / (1.0 - x.x)), log((1.0 + x.y) / (1.0 - x.y)), log((1.0 + x.z) / (1.0 - x.z)), log((1.0 + x.w) / (1.0 - x.w)));
}
#endif
#if defined(ROUND_USED)
highp float round(highp float x) {
return floor(x + 0.5);
}
highp vec2 round(highp vec2 x) {
return floor(x + vec2(0.5));
}
highp vec3 round(highp vec3 x) {
return floor(x + vec3(0.5));
}
highp vec4 round(highp vec4 x) {
return floor(x + vec4(0.5));
}
#endif
#if defined(ROUND_EVEN_USED)
highp float roundEven(highp float x) {
highp float t = x + 0.5;
highp float f = floor(t);
highp float r;
if (t == f) {
if (x > 0)
r = f - mod(f, 2);
else
r = f + mod(f, 2);
} else
r = f;
return r;
}
highp vec2 roundEven(highp vec2 x) {
return vec2(roundEven(x.x), roundEven(x.y));
}
highp vec3 roundEven(highp vec3 x) {
return vec3(roundEven(x.x), roundEven(x.y), roundEven(x.z));
}
highp vec4 roundEven(highp vec4 x) {
return vec4(roundEven(x.x), roundEven(x.y), roundEven(x.z), roundEven(x.w));
}
#endif
#if defined(IS_INF_USED)
bool isinf(highp float x) {
return (2 * x == x) && (x != 0);
}
bvec2 isinf(highp vec2 x) {
return bvec2((2 * x.x == x.x) && (x.x != 0), (2 * x.y == x.y) && (x.y != 0));
}
bvec3 isinf(highp vec3 x) {
return bvec3((2 * x.x == x.x) && (x.x != 0), (2 * x.y == x.y) && (x.y != 0), (2 * x.z == x.z) && (x.z != 0));
}
bvec4 isinf(highp vec4 x) {
return bvec4((2 * x.x == x.x) && (x.x != 0), (2 * x.y == x.y) && (x.y != 0), (2 * x.z == x.z) && (x.z != 0), (2 * x.w == x.w) && (x.w != 0));
}
#endif
#if defined(IS_NAN_USED)
bool isnan(highp float x) {
return x != x;
}
bvec2 isnan(highp vec2 x) {
return bvec2(x.x != x.x, x.y != x.y);
}
bvec3 isnan(highp vec3 x) {
return bvec3(x.x != x.x, x.y != x.y, x.z != x.z);
}
bvec4 isnan(highp vec4 x) {
return bvec4(x.x != x.x, x.y != x.y, x.z != x.z, x.w != x.w);
}
#endif
#if defined(TRUNC_USED)
highp float trunc(highp float x) {
return x < 0 ? -floor(-x) : floor(x);
}
highp vec2 trunc(highp vec2 x) {
return vec2(x.x < 0 ? -floor(-x.x) : floor(x.x), x.y < 0 ? -floor(-x.y) : floor(x.y));
}
highp vec3 trunc(highp vec3 x) {
return vec3(x.x < 0 ? -floor(-x.x) : floor(x.x), x.y < 0 ? -floor(-x.y) : floor(x.y), x.z < 0 ? -floor(-x.z) : floor(x.z));
}
highp vec4 trunc(highp vec4 x) {
return vec4(x.x < 0 ? -floor(-x.x) : floor(x.x), x.y < 0 ? -floor(-x.y) : floor(x.y), x.z < 0 ? -floor(-x.z) : floor(x.z), x.w < 0 ? -floor(-x.w) : floor(x.w));
}
#endif
#if defined(DETERMINANT_USED)
highp float determinant(highp mat2 m) {
return m[0].x * m[1].y - m[1].x * m[0].y;
}
highp float determinant(highp mat3 m) {
return m[0].x * (m[1].y * m[2].z - m[2].y * m[1].z) - m[1].x * (m[0].y * m[2].z - m[2].y * m[0].z) + m[2].x * (m[0].y * m[1].z - m[1].y * m[0].z);
}
highp float determinant(highp mat4 m) {
highp float s00 = m[2].z * m[3].w - m[3].z * m[2].w;
highp float s01 = m[2].y * m[3].w - m[3].y * m[2].w;
highp float s02 = m[2].y * m[3].z - m[3].y * m[2].z;
highp float s03 = m[2].x * m[3].w - m[3].x * m[2].w;
highp float s04 = m[2].x * m[3].z - m[3].x * m[2].z;
highp float s05 = m[2].x * m[3].y - m[3].x * m[2].y;
highp vec4 c = vec4((m[1].y * s00 - m[1].z * s01 + m[1].w * s02), -(m[1].x * s00 - m[1].z * s03 + m[1].w * s04), (m[1].x * s01 - m[1].y * s03 + m[1].w * s05), -(m[1].x * s02 - m[1].y * s04 + m[1].z * s05));
return m[0].x * c.x + m[0].y * c.y + m[0].z * c.z + m[0].w * c.w;
}
#endif
#if defined(INVERSE_USED)
highp mat2 inverse(highp mat2 m) {
highp float d = 1.0 / (m[0].x * m[1].y - m[1].x * m[0].y);
return mat2(
vec2(m[1].y * d, -m[0].y * d),
vec2(-m[1].x * d, m[0].x * d));
}
highp mat3 inverse(highp mat3 m) {
highp float d = 1.0 / (m[0].x * (m[1].y * m[2].z - m[2].y * m[1].z) - m[1].x * (m[0].y * m[2].z - m[2].y * m[0].z) + m[2].x * (m[0].y * m[1].z - m[1].y * m[0].z));
return mat3(
vec3((m[1].y * m[2].z - m[2].y * m[1].z), -(m[1].x * m[2].z - m[2].x * m[1].z), (m[1].x * m[2].y - m[2].x * m[1].y)) * d,
vec3(-(m[0].y * m[2].z - m[2].y * m[0].z), (m[0].x * m[2].z - m[2].x * m[0].z), -(m[0].x * m[2].y - m[2].x * m[0].y)) * d,
vec3((m[0].y * m[1].z - m[1].y * m[0].z), -(m[0].x * m[1].z - m[1].x * m[0].z), (m[0].x * m[1].y - m[1].x * m[0].y)) * d);
}
highp mat4 inverse(highp mat4 m) {
highp float c00 = m[2].z * m[3].w - m[3].z * m[2].w;
highp float c02 = m[1].z * m[3].w - m[3].z * m[1].w;
highp float c03 = m[1].z * m[2].w - m[2].z * m[1].w;
highp float c04 = m[2].y * m[3].w - m[3].y * m[2].w;
highp float c06 = m[1].y * m[3].w - m[3].y * m[1].w;
highp float c07 = m[1].y * m[2].w - m[2].y * m[1].w;
highp float c08 = m[2].y * m[3].z - m[3].y * m[2].z;
highp float c10 = m[1].y * m[3].z - m[3].y * m[1].z;
highp float c11 = m[1].y * m[2].z - m[2].y * m[1].z;
highp float c12 = m[2].x * m[3].w - m[3].x * m[2].w;
highp float c14 = m[1].x * m[3].w - m[3].x * m[1].w;
highp float c15 = m[1].x * m[2].w - m[2].x * m[1].w;
highp float c16 = m[2].x * m[3].z - m[3].x * m[2].z;
highp float c18 = m[1].x * m[3].z - m[3].x * m[1].z;
highp float c19 = m[1].x * m[2].z - m[2].x * m[1].z;
highp float c20 = m[2].x * m[3].y - m[3].x * m[2].y;
highp float c22 = m[1].x * m[3].y - m[3].x * m[1].y;
highp float c23 = m[1].x * m[2].y - m[2].x * m[1].y;
vec4 f0 = vec4(c00, c00, c02, c03);
vec4 f1 = vec4(c04, c04, c06, c07);
vec4 f2 = vec4(c08, c08, c10, c11);
vec4 f3 = vec4(c12, c12, c14, c15);
vec4 f4 = vec4(c16, c16, c18, c19);
vec4 f5 = vec4(c20, c20, c22, c23);
vec4 v0 = vec4(m[1].x, m[0].x, m[0].x, m[0].x);
vec4 v1 = vec4(m[1].y, m[0].y, m[0].y, m[0].y);
vec4 v2 = vec4(m[1].z, m[0].z, m[0].z, m[0].z);
vec4 v3 = vec4(m[1].w, m[0].w, m[0].w, m[0].w);
vec4 inv0 = vec4(v1 * f0 - v2 * f1 + v3 * f2);
vec4 inv1 = vec4(v0 * f0 - v2 * f3 + v3 * f4);
vec4 inv2 = vec4(v0 * f1 - v1 * f3 + v3 * f5);
vec4 inv3 = vec4(v0 * f2 - v1 * f4 + v2 * f5);
vec4 sa = vec4(+1, -1, +1, -1);
vec4 sb = vec4(-1, +1, -1, +1);
mat4 inv = mat4(inv0 * sa, inv1 * sb, inv2 * sa, inv3 * sb);
vec4 r0 = vec4(inv[0].x, inv[1].x, inv[2].x, inv[3].x);
vec4 d0 = vec4(m[0] * r0);
highp float d1 = (d0.x + d0.y) + (d0.z + d0.w);
highp float d = 1.0 / d1;
return inv * d;
}
#endif
#ifndef USE_GLES_OVER_GL
#if defined(TRANSPOSE_USED)
highp mat2 transpose(highp mat2 m) {
return mat2(
vec2(m[0].x, m[1].x),
vec2(m[0].y, m[1].y));
}
highp mat3 transpose(highp mat3 m) {
return mat3(
vec3(m[0].x, m[1].x, m[2].x),
vec3(m[0].y, m[1].y, m[2].y),
vec3(m[0].z, m[1].z, m[2].z));
}
#endif
highp mat4 transpose(highp mat4 m) {
return mat4(
vec4(m[0].x, m[1].x, m[2].x, m[3].x),
vec4(m[0].y, m[1].y, m[2].y, m[3].y),
vec4(m[0].z, m[1].z, m[2].z, m[3].z),
vec4(m[0].w, m[1].w, m[2].w, m[3].w));
}
#if defined(OUTER_PRODUCT_USED)
highp mat2 outerProduct(highp vec2 c, highp vec2 r) {
return mat2(c * r.x, c * r.y);
}
highp mat3 outerProduct(highp vec3 c, highp vec3 r) {
return mat3(c * r.x, c * r.y, c * r.z);
}
highp mat4 outerProduct(highp vec4 c, highp vec4 r) {
return mat4(c * r.x, c * r.y, c * r.z, c * r.w);
}
#endif
#endif

View file

@ -1498,7 +1498,7 @@ String EditorExportPlatform::test_etc2() const {
bool etc_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc");
bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2");
if (driver == "OpenGL" && !etc_supported) {
if (driver == "OpenGL3" && !etc_supported) {
return TTR("Target platform requires 'ETC' texture compression for OpenGL. Enable 'Import Etc' in Project Settings.");
} else if (driver == "Vulkan" && !etc2_supported) {
// FIXME: Review if this is true for Vulkan.
@ -1515,7 +1515,7 @@ String EditorExportPlatform::test_etc2_or_pvrtc() const {
// bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2");
// bool pvrtc_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_pvrtc");
if (driver == "OpenGL" && !pvrtc_supported) {
if (driver == "OpenGL3" && !pvrtc_supported) {
return TTR("Target platform requires 'PVRTC' texture compression for OpenGL. Enable 'Import Pvrtc' in Project Settings.");
} else if (driver == "Vulkan" && !etc2_supported && !pvrtc_supported) {
// FIXME: Review if this is true for Vulkan.

View file

@ -5596,7 +5596,7 @@ void EditorNode::_bottom_panel_raise_toggled(bool p_pressed) {
}
void EditorNode::_update_rendering_driver_color() {
if (rendering_driver->get_text() == "opengl") {
if (rendering_driver->get_text() == "opengl3") {
rendering_driver->add_theme_color_override("font_color", Color::hex(0x5586a4ff));
} else if (rendering_driver->get_text() == "vulkan") {
rendering_driver->add_theme_color_override("font_color", theme_base->get_theme_color("vulkan_color", "Editor"));
@ -6619,28 +6619,12 @@ EditorNode::EditorNode() {
HBoxContainer *right_menu_hb = memnew(HBoxContainer);
menu_hb->add_child(right_menu_hb);
// Toggle for video driver
// video_driver = memnew(OptionButton);
// video_driver->set_focus_mode(Control::FOCUS_NONE);
// video_driver->connect("item_selected", callable_mp(this, &EditorNode::_video_driver_selected));
// video_driver->add_theme_font_override("font", gui_base->get_theme_font(SNAME("bold"), SNAME("EditorFonts")));
// video_driver->add_theme_font_size_override("font_size", gui_base->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")));
// // TODO: Show again when OpenGL is ported.
// video_driver->set_visible(false);
// right_menu_hb->add_child(video_driver);
//#ifndef _MSC_VER
//#warning needs to be reimplemented
//#endif
//#if 0
// String video_drivers = ProjectSettings::get_singleton()->get_custom_property_info()["rendering/driver/driver_name"].hint_string;
// String current_video_driver = OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver());
// video_driver_current = 0;
// for (int i = 0; i < video_drivers.get_slice_count(","); i++) {
// String driver = video_drivers.get_slice(",", i);
// video_driver->add_item(driver);
// video_driver->set_item_metadata(i, driver);
rendering_driver = memnew(OptionButton);
// Hide the renderer selection dropdown until OpenGL support is more mature.
// The renderer can still be changed in the project settings or using `--rendering-driver opengl3`.
rendering_driver->set_visible(false);
rendering_driver->set_flat(true);
rendering_driver->set_focus_mode(Control::FOCUS_NONE);
rendering_driver->connect("item_selected", callable_mp(this, &EditorNode::_rendering_driver_selected));
@ -6649,23 +6633,23 @@ EditorNode::EditorNode() {
right_menu_hb->add_child(rendering_driver);
// only display the render drivers that are available for this display driver
// Only display the render drivers that are available for this display driver.
int display_driver_idx = OS::get_singleton()->get_display_driver_id();
Vector<String> render_drivers = DisplayServer::get_create_function_rendering_drivers(display_driver_idx);
String current_rendering_driver = OS::get_singleton()->get_current_rendering_driver_name();
// as we are doing string comparisons, keep in standard case to prevent problems with capitals
// 'vulkan' in particular uses lower case v in the code, and upper case in the UI .
// As we are doing string comparisons, keep in standard case to prevent problems with capitals
// "vulkan" in particular uses lowercase "v" in the code, and uppercase in the UI.
current_rendering_driver = current_rendering_driver.to_lower();
for (int i = 0; i < render_drivers.size(); i++) {
String driver = render_drivers[i];
// add the driver to the user interface
// Add the driver to the UI.
rendering_driver->add_item(driver);
rendering_driver->set_item_metadata(i, driver);
// lower case for standard comparison
// Lowercase for standard comparison.
driver = driver.to_lower();
if (current_rendering_driver == driver) {
@ -6673,29 +6657,6 @@ EditorNode::EditorNode() {
rendering_driver_current = i;
}
}
#if 0
// commented out old version, gets the driver list from the project settings
// just in case we decide to revert to this method
String rendering_drivers = ProjectSettings::get_singleton()->get_custom_property_info()["rendering/driver/driver_name"].hint_string;
String current_rendering_driver = OS::get_singleton()->get_current_rendering_driver_name();
current_rendering_driver = current_rendering_driver.to_lower();
print_line("current_rendering_driver " + current_rendering_driver);
rendering_driver_current = 0;
for (int i = 0; i < rendering_drivers.get_slice_count(","); i++) {
String driver = rendering_drivers.get_slice(",", i);
rendering_driver->add_item(driver);
rendering_driver->set_item_metadata(i, driver);
driver = driver.to_lower();
print_line("\tdriver " + driver);
if (current_rendering_driver == driver) {
rendering_driver->select(i);
rendering_driver_current = i;
}
}
#endif
_update_rendering_driver_color();
video_restart_dialog = memnew(ConfirmationDialog);

View file

@ -1246,7 +1246,7 @@ void VisualShaderEditor::_update_options_menu() {
Color unsupported_color = get_theme_color(SNAME("error_color"), SNAME("Editor"));
Color supported_color = get_theme_color(SNAME("warning_color"), SNAME("Editor"));
static bool low_driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name") == "opengl";
static bool low_driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name") == "opengl3";
Map<String, TreeItem *> folders;

View file

@ -478,7 +478,7 @@ private:
if (rasterizer_button_group->get_pressed_button()->get_meta("driver_name") == "Vulkan") {
initial_settings["rendering/driver/driver_name"] = "Vulkan";
} else {
initial_settings["rendering/driver/driver_name"] = "OpenGL";
initial_settings["rendering/driver/driver_name"] = "OpenGL3";
initial_settings["rendering/textures/vram_compression/import_etc2"] = false;
initial_settings["rendering/textures/vram_compression/import_etc"] = true;
}

View file

@ -519,11 +519,9 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs):
fd.close()
def build_opengl_headers(target, source, env):
def build_gles3_headers(target, source, env):
for x in source:
build_legacygl_header(
str(x), include="drivers/opengl/shader_opengl.h", class_suffix="OpenGL", output_attribs=True
)
build_legacygl_header(str(x), include="drivers/gles3/shader_gles3.h", class_suffix="GLES3", output_attribs=True)
if __name__ == "__main__":

View file

@ -1573,8 +1573,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
String display_driver = DisplayServer::get_create_function_name(display_driver_idx);
// rendering_driver now held in static global String in main and initialized in setup()
print_line("creating display driver : " + display_driver);
print_line("creating rendering driver : " + rendering_driver);
Error err;
display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_vsync_mode, window_flags, window_size, err);
if (err != OK || display_server == nullptr) {

View file

@ -344,8 +344,8 @@ void DisplayServerAndroid::process_events() {
Vector<String> DisplayServerAndroid::get_rendering_drivers_func() {
Vector<String> drivers;
#ifdef OPENGL_ENABLED
drivers.push_back("opengl");
#ifdef GLES3_ENABLED
drivers.push_back("opengl3");
#endif
#ifdef VULKAN_ENABLED
drivers.push_back("vulkan");
@ -407,13 +407,13 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
keep_screen_on = GLOBAL_GET("display/window/energy_saving/keep_screen_on");
#if defined(OPENGL_ENABLED)
if (rendering_driver == "opengl") {
#if defined(GLES3_ENABLED)
if (rendering_driver == "opengl3") {
bool gl_initialization_error = false;
if (RasterizerOpenGLis_viable() == OK) {
RasterizerOpenGLregister_config();
RasterizerOpenGLmake_current();
if (RasterizerGLES3::is_viable() == OK) {
RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
} else {
gl_initialization_error = true;
}

File diff suppressed because it is too large Load diff

View file

@ -1612,7 +1612,7 @@ Vector<String> EditorExportPlatformAndroid::get_enabled_abis(const Ref<EditorExp
void EditorExportPlatformAndroid::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name");
if (driver == "OpenGL") {
if (driver == "OpenGL3") {
r_features->push_back("etc");
}
// FIXME: Review what texture formats are used for Vulkan.

View file

@ -74,51 +74,6 @@ Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_
// Creates strings.xml files inside the gradle project for different locales.
Error _create_project_name_strings_files(const Ref<EditorExportPreset> &p_preset, const String &project_name);
//Error _create_project_name_strings_files(const Ref<EditorExportPreset> &p_preset, const String &project_name) {
// // Stores the string into the default values directory.
// String processed_default_xml_string = vformat(godot_project_name_xml_string, project_name.xml_escape(true));
// store_string_at_path("res://android/build/res/values/godot_project_name_string.xml", processed_default_xml_string);
// // Searches the Gradle project res/ directory to find all supported locales
// DirAccessRef da = DirAccess::open("res://android/build/res");
// if (!da) {
// return ERR_CANT_OPEN;
// }
// da->list_dir_begin();
// while (true) {
// String file = da->get_next();
// if (file == "") {
// break;
// }
// if (!file.begins_with("values-")) {
// // NOTE: This assumes all directories that start with "values-" are for localization.
// continue;
// }
// String locale = file.replace("values-", "").replace("-r", "_");
// String property_name = "application/config/name_" + locale;
// String locale_directory = "res://android/build/res/" + file + "/godot_project_name_string.xml";
// if (ProjectSettings::get_singleton()->has_setting(property_name)) {
// String locale_project_name = ProjectSettings::get_singleton()->get(property_name);
// String processed_xml_string = vformat(godot_project_name_xml_string, locale_project_name.xml_escape(true));
// store_string_at_path(locale_directory, processed_xml_string);
// } else {
// // TODO: Once the legacy build system is deprecated we don't need to have xml files for this else branch
// store_string_at_path(locale_directory, processed_default_xml_string);
// }
// }
// da->list_dir_end();
// return OK;
//}
//String bool_to_string(bool v) {
// return v ? "true" : "false";
//}
//String _get_gles_tag() {
// bool min_gles3 = ProjectSettings::get_singleton()->get("rendering/driver/driver_name") == "GLES3" &&
// !ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2");
// return min_gles3 ? " <uses-feature android:glEsVersion=\"0x00030000\" android:required=\"true\" />\n" : "";
//}
String bool_to_string(bool v);

View file

@ -262,14 +262,14 @@ Size2i OS_Android::get_display_size() const {
}
void OS_Android::set_context_is_16_bits(bool p_is_16) {
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
//if (rasterizer)
// rasterizer->set_force_16_bits_fbo(p_is_16);
#endif
}
void OS_Android::set_opengl_extensions(const char *p_gl_extensions) {
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
ERR_FAIL_COND(!p_gl_extensions);
gl_extensions = p_gl_extensions;
#endif
@ -321,7 +321,7 @@ OS_Android::OS_Android(GodotJavaWrapper *p_godot_java, GodotIOJavaWrapper *p_god
main_loop = nullptr;
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
gl_extensions = nullptr;
use_gl2 = false;
#endif

View file

@ -47,7 +47,7 @@ private:
bool use_apk_expansion;
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
const char *gl_extensions;
#endif

View file

@ -34,7 +34,7 @@
// FIXME: Add support for both OpenGL and Vulkan when OpenGL is implemented again,
// so it can't be done with compilation time branching.
//#if defined(OPENGL_ENABLED)
//#if defined(GLES3_ENABLED)
//@interface AppDelegate : NSObject <UIApplicationDelegate, GLViewDelegate> {
//#endif
//#if defined(VULKAN_ENABLED)

View file

@ -89,7 +89,7 @@
// FIXME: Add Vulkan support via MoltenVK. Add fallback code back?
// Create GL ES 2 context
if (GLOBAL_GET("rendering/driver/driver_name") == "opengl") {
if (GLOBAL_GET("rendering/driver/driver_name") == "opengl3") {
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
NSLog(@"Setting up an OpenGL ES 2.0 context.");
if (!context) {

View file

@ -51,7 +51,7 @@ DisplayServerIPhone *DisplayServerIPhone::get_singleton() {
DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
rendering_driver = p_rendering_driver;
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
// FIXME: Add support for both OpenGL and Vulkan when OpenGL is implemented
// again,
@ -60,9 +60,9 @@ DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, Windo
// FIXME: Add Vulkan support via MoltenVK. Add fallback code back?
if (RasterizerOpenGLis_viable() == OK) {
RasterizerOpenGLregister_config();
RasterizerOpenGLmake_current();
if (RasterizerGLES3::is_viable() == OK) {
RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
} else {
gl_initialization_error = true;
}
@ -83,7 +83,7 @@ DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, Windo
// reset this to what it should be, it will have been set to 0 after
// rendering_server->init() is called
// RasterizerStorageOpenGLsystem_fbo = gl_view_base_fb;
// RasterizerStorageGLES3system_fbo = gl_view_base_fb;
}
#endif
@ -157,7 +157,7 @@ Vector<String> DisplayServerIPhone::get_rendering_drivers_func() {
#if defined(VULKAN_ENABLED)
drivers.push_back("vulkan");
#endif
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
drivers.push_back("opengl_es");
#endif

File diff suppressed because it is too large Load diff

View file

@ -691,10 +691,10 @@ DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_drive
bool gl_initialization_error = false;
if (RasterizerOpenGLis_viable() == OK) {
if (RasterizerGLES3::is_viable() == OK) {
attributes.majorVersion = 1;
RasterizerOpenGLregister_config();
RasterizerOpenGLmake_current();
RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
} else {
gl_initialization_error = true;
}

View file

@ -32,678 +32,6 @@
#include "export_plugin.h"
/*
class EditorHTTPServer : public Reference {
private:
Ref<TCP_Server> server;
Ref<StreamPeerTCP> connection;
uint64_t time = 0;
uint8_t req_buf[4096];
int req_pos = 0;
void _clear_client() {
connection = Ref<StreamPeerTCP>();
memset(req_buf, 0, sizeof(req_buf));
time = 0;
req_pos = 0;
}
public:
EditorHTTPServer() {
server.instance();
stop();
}
void stop() {
server->stop();
_clear_client();
}
Error listen(int p_port, IP_Address p_address) {
return server->listen(p_port, p_address);
}
bool is_listening() const {
return server->is_listening();
}
void _send_response() {
Vector<String> psa = String((char *)req_buf).split("\r\n");
int len = psa.size();
ERR_FAIL_COND_MSG(len < 4, "Not enough response headers, got: " + itos(len) + ", expected >= 4.");
Vector<String> req = psa[0].split(" ", false);
ERR_FAIL_COND_MSG(req.size() < 2, "Invalid protocol or status code.");
// Wrong protocol
ERR_FAIL_COND_MSG(req[0] != "GET" || req[2] != "HTTP/1.1", "Invalid method or HTTP version.");
const String cache_path = EditorSettings::get_singleton()->get_cache_dir();
const String basereq = "/tmp_js_export";
String filepath;
String ctype;
if (req[1] == basereq + ".html") {
filepath = cache_path.plus_file(req[1].get_file());
ctype = "text/html";
} else if (req[1] == basereq + ".js") {
filepath = cache_path.plus_file(req[1].get_file());
ctype = "application/javascript";
} else if (req[1] == basereq + ".audio.worklet.js") {
filepath = cache_path.plus_file(req[1].get_file());
ctype = "application/javascript";
} else if (req[1] == basereq + ".worker.js") {
filepath = cache_path.plus_file(req[1].get_file());
ctype = "application/javascript";
} else if (req[1] == basereq + ".pck") {
filepath = cache_path.plus_file(req[1].get_file());
ctype = "application/octet-stream";
} else if (req[1] == basereq + ".png" || req[1] == "/favicon.png") {
// Also allow serving the generated favicon for a smoother loading experience.
if (req[1] == "/favicon.png") {
filepath = EditorSettings::get_singleton()->get_cache_dir().plus_file("favicon.png");
} else {
filepath = basereq + ".png";
}
ctype = "image/png";
} else if (req[1] == basereq + ".side.wasm") {
filepath = cache_path.plus_file(req[1].get_file());
ctype = "application/wasm";
} else if (req[1] == basereq + ".wasm") {
filepath = cache_path.plus_file(req[1].get_file());
ctype = "application/wasm";
} else if (req[1].ends_with(".wasm")) {
filepath = cache_path.plus_file(req[1].get_file()); // TODO dangerous?
ctype = "application/wasm";
}
if (filepath.is_empty() || !FileAccess::exists(filepath)) {
String s = "HTTP/1.1 404 Not Found\r\n";
s += "Connection: Close\r\n";
s += "\r\n";
CharString cs = s.utf8();
connection->put_data((const uint8_t *)cs.get_data(), cs.size() - 1);
return;
}
FileAccess *f = FileAccess::open(filepath, FileAccess::READ);
ERR_FAIL_COND(!f);
String s = "HTTP/1.1 200 OK\r\n";
s += "Connection: Close\r\n";
s += "Content-Type: " + ctype + "\r\n";
s += "Access-Control-Allow-Origin: *\r\n";
s += "Cross-Origin-Opener-Policy: same-origin\r\n";
s += "Cross-Origin-Embedder-Policy: require-corp\r\n";
s += "\r\n";
CharString cs = s.utf8();
Error err = connection->put_data((const uint8_t *)cs.get_data(), cs.size() - 1);
if (err != OK) {
memdelete(f);
ERR_FAIL();
}
while (true) {
uint8_t bytes[4096];
int read = f->get_buffer(bytes, 4096);
if (read < 1) {
break;
}
err = connection->put_data(bytes, read);
if (err != OK) {
memdelete(f);
ERR_FAIL();
}
}
memdelete(f);
}
void poll() {
if (!server->is_listening()) {
return;
}
if (connection.is_null()) {
if (!server->is_connection_available()) {
return;
}
connection = server->take_connection();
time = OS::get_singleton()->get_ticks_usec();
}
if (OS::get_singleton()->get_ticks_usec() - time > 1000000) {
_clear_client();
return;
}
if (connection->get_status() != StreamPeerTCP::STATUS_CONNECTED) {
return;
}
while (true) {
char *r = (char *)req_buf;
int l = req_pos - 1;
if (l > 3 && r[l] == '\n' && r[l - 1] == '\r' && r[l - 2] == '\n' && r[l - 3] == '\r') {
_send_response();
_clear_client();
return;
}
int read = 0;
ERR_FAIL_COND(req_pos >= 4096);
Error err = connection->get_partial_data(&req_buf[req_pos], 1, read);
if (err != OK) {
// Got an error
_clear_client();
return;
} else if (read != 1) {
// Busy, wait next poll
return;
}
req_pos += read;
}
}
};
class EditorExportPlatformJavaScript : public EditorExportPlatform {
GDCLASS(EditorExportPlatformJavaScript, EditorExportPlatform);
Ref<ImageTexture> logo;
Ref<ImageTexture> run_icon;
Ref<ImageTexture> stop_icon;
int menu_options = 0;
Ref<EditorHTTPServer> server;
bool server_quit = false;
Mutex server_lock;
Thread *server_thread = nullptr;
enum ExportMode {
EXPORT_MODE_NORMAL = 0,
EXPORT_MODE_THREADS = 1,
EXPORT_MODE_GDNATIVE = 2,
};
String _get_template_name(ExportMode p_mode, bool p_debug) const {
String name = "webassembly";
switch (p_mode) {
case EXPORT_MODE_THREADS:
name += "_threads";
break;
case EXPORT_MODE_GDNATIVE:
name += "_gdnative";
break;
default:
break;
}
if (p_debug) {
name += "_debug.zip";
} else {
name += "_release.zip";
}
return name;
}
void _fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug, int p_flags, const Vector<SharedObject> p_shared_objects);
static void _server_thread_poll(void *data);
public:
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) override;
virtual void get_export_options(List<ExportOption> *r_options) override;
virtual String get_name() const override;
virtual String get_os_name() const override;
virtual Ref<Texture2D> get_logo() const override;
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const override;
virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const override;
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override;
virtual bool poll_export() override;
virtual int get_options_count() const override;
virtual String get_option_label(int p_index) const override { return p_index ? TTR("Stop HTTP Server") : TTR("Run in Browser"); }
virtual String get_option_tooltip(int p_index) const override { return p_index ? TTR("Stop HTTP Server") : TTR("Run exported HTML in the system's default browser."); }
virtual Ref<ImageTexture> get_option_icon(int p_index) const override;
virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_option, int p_debug_flags) override;
virtual Ref<Texture2D> get_run_icon() const override;
virtual void get_platform_features(List<String> *r_features) override {
r_features->push_back("web");
r_features->push_back(get_os_name());
}
virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) override {
}
String get_debug_protocol() const override { return "ws://"; }
EditorExportPlatformJavaScript();
~EditorExportPlatformJavaScript();
};
void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug, int p_flags, const Vector<SharedObject> p_shared_objects) {
String str_template = String::utf8(reinterpret_cast<const char *>(p_html.ptr()), p_html.size());
String str_export;
Vector<String> lines = str_template.split("\n");
Vector<String> flags;
String flags_json;
gen_export_flags(flags, p_flags);
flags_json = JSON::print(flags);
String libs;
for (int i = 0; i < p_shared_objects.size(); i++) {
libs += "\"" + p_shared_objects[i].path.get_file() + "\",";
}
for (int i = 0; i < lines.size(); i++) {
String current_line = lines[i];
current_line = current_line.replace("$GODOT_BASENAME", p_name);
current_line = current_line.replace("$GODOT_PROJECT_NAME", ProjectSettings::get_singleton()->get_setting("application/config/name"));
current_line = current_line.replace("$GODOT_HEAD_INCLUDE", p_preset->get("html/head_include"));
current_line = current_line.replace("$GODOT_FULL_WINDOW", p_preset->get("html/full_window_size") ? "true" : "false");
current_line = current_line.replace("$GODOT_GDNATIVE_LIBS", libs);
current_line = current_line.replace("$GODOT_DEBUG_ENABLED", p_debug ? "true" : "false");
current_line = current_line.replace("$GODOT_ARGS", flags_json);
str_export += current_line + "\n";
}
CharString cs = str_export.utf8();
p_html.resize(cs.length());
for (int i = 0; i < cs.length(); i++) {
p_html.write[i] = cs[i];
}
}
void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
if (p_preset->get("vram_texture_compression/for_desktop")) {
r_features->push_back("s3tc");
}
if (p_preset->get("vram_texture_compression/for_mobile")) {
String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name");
if (driver == "OpenGL") {
r_features->push_back("etc");
} else if (driver == "Vulkan") {
// FIXME: Review if this is correct.
r_features->push_back("etc2");
}
}
ExportMode mode = (ExportMode)(int)p_preset->get("variant/export_type");
if (mode == EXPORT_MODE_THREADS) {
r_features->push_back("threads");
} else if (mode == EXPORT_MODE_GDNATIVE) {
r_features->push_back("wasm32");
}
}
void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_options) {
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "variant/export_type", PROPERTY_HINT_ENUM, "Regular,Threads,GDNative"), 0)); // Export type.
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_desktop"), true)); // S3TC
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_mobile"), false)); // ETC or ETC2, depending on renderer
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/custom_html_shell", PROPERTY_HINT_FILE, "*.html"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/head_include", PROPERTY_HINT_MULTILINE_TEXT), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "html/full_window_size"), true));
}
String EditorExportPlatformJavaScript::get_name() const {
return "HTML5";
}
String EditorExportPlatformJavaScript::get_os_name() const {
return "HTML5";
}
Ref<Texture2D> EditorExportPlatformJavaScript::get_logo() const {
return logo;
}
bool EditorExportPlatformJavaScript::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
String err;
bool valid = false;
ExportMode mode = (ExportMode)(int)p_preset->get("variant/export_type");
// Look for export templates (first official, and if defined custom templates).
bool dvalid = exists_export_template(_get_template_name(mode, true), &err);
bool rvalid = exists_export_template(_get_template_name(mode, false), &err);
if (p_preset->get("custom_template/debug") != "") {
dvalid = FileAccess::exists(p_preset->get("custom_template/debug"));
if (!dvalid) {
err += TTR("Custom debug template not found.") + "\n";
}
}
if (p_preset->get("custom_template/release") != "") {
rvalid = FileAccess::exists(p_preset->get("custom_template/release"));
if (!rvalid) {
err += TTR("Custom release template not found.") + "\n";
}
}
valid = dvalid || rvalid;
r_missing_templates = !valid;
// Validate the rest of the configuration.
if (p_preset->get("vram_texture_compression/for_mobile")) {
String etc_error = test_etc2();
if (etc_error != String()) {
valid = false;
err += etc_error;
}
}
if (!err.is_empty()) {
r_error = err;
}
return valid;
}
List<String> EditorExportPlatformJavaScript::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
List<String> list;
list.push_back("html");
return list;
}
Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags);
String custom_debug = p_preset->get("custom_template/debug");
String custom_release = p_preset->get("custom_template/release");
String custom_html = p_preset->get("html/custom_html_shell");
String template_path = p_debug ? custom_debug : custom_release;
template_path = template_path.strip_edges();
if (template_path == String()) {
ExportMode mode = (ExportMode)(int)p_preset->get("variant/export_type");
template_path = find_export_template(_get_template_name(mode, p_debug));
}
if (!DirAccess::exists(p_path.get_base_dir())) {
return ERR_FILE_BAD_PATH;
}
if (template_path != String() && !FileAccess::exists(template_path)) {
EditorNode::get_singleton()->show_warning(TTR("Template file not found:") + "\n" + template_path);
return ERR_FILE_NOT_FOUND;
}
Vector<SharedObject> shared_objects;
String pck_path = p_path.get_basename() + ".pck";
Error error = save_pack(p_preset, pck_path, &shared_objects);
if (error != OK) {
EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + pck_path);
return error;
}
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
for (int i = 0; i < shared_objects.size(); i++) {
String dst = p_path.get_base_dir().plus_file(shared_objects[i].path.get_file());
error = da->copy(shared_objects[i].path, dst);
if (error != OK) {
EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + shared_objects[i].path.get_file());
memdelete(da);
return error;
}
}
memdelete(da);
FileAccess *src_f = nullptr;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
unzFile pkg = unzOpen2(template_path.utf8().get_data(), &io);
if (!pkg) {
EditorNode::get_singleton()->show_warning(TTR("Could not open template for export:") + "\n" + template_path);
return ERR_FILE_NOT_FOUND;
}
if (unzGoToFirstFile(pkg) != UNZ_OK) {
EditorNode::get_singleton()->show_warning(TTR("Invalid export template:") + "\n" + template_path);
unzClose(pkg);
return ERR_FILE_CORRUPT;
}
do {
//get filename
unz_file_info info;
char fname[16384];
unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0);
String file = fname;
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
//read
unzOpenCurrentFile(pkg);
unzReadCurrentFile(pkg, data.ptrw(), data.size());
unzCloseCurrentFile(pkg);
//write
if (file == "godot.html") {
if (!custom_html.is_empty()) {
continue;
}
_fix_html(data, p_preset, p_path.get_file().get_basename(), p_debug, p_flags, shared_objects);
file = p_path.get_file();
} else if (file == "godot.js") {
file = p_path.get_file().get_basename() + ".js";
} else if (file == "godot.worker.js") {
file = p_path.get_file().get_basename() + ".worker.js";
} else if (file == "godot.side.wasm") {
file = p_path.get_file().get_basename() + ".side.wasm";
} else if (file == "godot.audio.worklet.js") {
file = p_path.get_file().get_basename() + ".audio.worklet.js";
} else if (file == "godot.wasm") {
file = p_path.get_file().get_basename() + ".wasm";
}
String dst = p_path.get_base_dir().plus_file(file);
FileAccess *f = FileAccess::open(dst, FileAccess::WRITE);
if (!f) {
EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + dst);
unzClose(pkg);
return ERR_FILE_CANT_WRITE;
}
f->store_buffer(data.ptr(), data.size());
memdelete(f);
} while (unzGoToNextFile(pkg) == UNZ_OK);
unzClose(pkg);
if (!custom_html.is_empty()) {
FileAccess *f = FileAccess::open(custom_html, FileAccess::READ);
if (!f) {
EditorNode::get_singleton()->show_warning(TTR("Could not read custom HTML shell:") + "\n" + custom_html);
return ERR_FILE_CANT_READ;
}
Vector<uint8_t> buf;
buf.resize(f->get_len());
f->get_buffer(buf.ptrw(), buf.size());
memdelete(f);
_fix_html(buf, p_preset, p_path.get_file().get_basename(), p_debug, p_flags, shared_objects);
f = FileAccess::open(p_path, FileAccess::WRITE);
if (!f) {
EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + p_path);
return ERR_FILE_CANT_WRITE;
}
f->store_buffer(buf.ptr(), buf.size());
memdelete(f);
}
Ref<Image> splash;
const String splash_path = String(GLOBAL_GET("application/boot_splash/image")).strip_edges();
if (!splash_path.is_empty()) {
splash.instance();
const Error err = splash->load(splash_path);
if (err) {
EditorNode::get_singleton()->show_warning(TTR("Could not read boot splash image file:") + "\n" + splash_path + "\n" + TTR("Using default boot splash image."));
splash.unref();
}
}
if (splash.is_null()) {
splash = Ref<Image>(memnew(Image(boot_splash_png)));
}
const String splash_png_path = p_path.get_base_dir().plus_file(p_path.get_file().get_basename() + ".png");
if (splash->save_png(splash_png_path) != OK) {
EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + splash_png_path);
return ERR_FILE_CANT_WRITE;
}
// Save a favicon that can be accessed without waiting for the project to finish loading.
// This way, the favicon can be displayed immediately when loading the page.
Ref<Image> favicon;
const String favicon_path = String(GLOBAL_GET("application/config/icon")).strip_edges();
if (!favicon_path.is_empty()) {
favicon.instance();
const Error err = favicon->load(favicon_path);
if (err) {
favicon.unref();
}
}
if (favicon.is_valid()) {
const String favicon_png_path = p_path.get_base_dir().plus_file("favicon.png");
if (favicon->save_png(favicon_png_path) != OK) {
EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + favicon_png_path);
return ERR_FILE_CANT_WRITE;
}
}
return OK;
}
bool EditorExportPlatformJavaScript::poll_export() {
Ref<EditorExportPreset> preset;
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
Ref<EditorExportPreset> ep = EditorExport::get_singleton()->get_export_preset(i);
if (ep->is_runnable() && ep->get_platform() == this) {
preset = ep;
break;
}
}
int prev = menu_options;
menu_options = preset.is_valid();
if (server->is_listening()) {
if (menu_options == 0) {
MutexLock lock(server_lock);
server->stop();
} else {
menu_options += 1;
}
}
return menu_options != prev;
}
Ref<ImageTexture> EditorExportPlatformJavaScript::get_option_icon(int p_index) const {
return p_index == 1 ? stop_icon : EditorExportPlatform::get_option_icon(p_index);
}
int EditorExportPlatformJavaScript::get_options_count() const {
return menu_options;
}
Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_preset, int p_option, int p_debug_flags) {
if (p_option == 1) {
MutexLock lock(server_lock);
server->stop();
return OK;
}
const String basepath = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_js_export");
Error err = export_project(p_preset, true, basepath + ".html", p_debug_flags);
if (err != OK) {
// Export generates several files, clean them up on failure.
DirAccess::remove_file_or_error(basepath + ".html");
DirAccess::remove_file_or_error(basepath + ".js");
DirAccess::remove_file_or_error(basepath + ".worker.js");
DirAccess::remove_file_or_error(basepath + ".audio.worklet.js");
DirAccess::remove_file_or_error(basepath + ".pck");
DirAccess::remove_file_or_error(basepath + ".png");
DirAccess::remove_file_or_error(basepath + ".side.wasm");
DirAccess::remove_file_or_error(basepath + ".wasm");
DirAccess::remove_file_or_error(EditorSettings::get_singleton()->get_cache_dir().plus_file("favicon.png"));
return err;
}
const uint16_t bind_port = EDITOR_GET("export/web/http_port");
// Resolve host if needed.
const String bind_host = EDITOR_GET("export/web/http_host");
IP_Address bind_ip;
if (bind_host.is_valid_ip_address()) {
bind_ip = bind_host;
} else {
bind_ip = IP::get_singleton()->resolve_hostname(bind_host);
}
ERR_FAIL_COND_V_MSG(!bind_ip.is_valid(), ERR_INVALID_PARAMETER, "Invalid editor setting 'export/web/http_host': '" + bind_host + "'. Try using '127.0.0.1'.");
// Restart server.
{
MutexLock lock(server_lock);
server->stop();
err = server->listen(bind_port, bind_ip);
}
ERR_FAIL_COND_V_MSG(err != OK, err, "Unable to start HTTP server.");
OS::get_singleton()->shell_open(String("http://" + bind_host + ":" + itos(bind_port) + "/tmp_js_export.html"));
// FIXME: Find out how to clean up export files after running the successfully
// exported game. Might not be trivial.
return OK;
}
Ref<Texture2D> EditorExportPlatformJavaScript::get_run_icon() const {
return run_icon;
}
void EditorExportPlatformJavaScript::_server_thread_poll(void *data) {
EditorExportPlatformJavaScript *ej = (EditorExportPlatformJavaScript *)data;
while (!ej->server_quit) {
OS::get_singleton()->delay_usec(1000);
{
MutexLock lock(ej->server_lock);
ej->server->poll();
}
}
}
EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() {
server.instance();
server_thread = Thread::create(_server_thread_poll, this);
Ref<Image> img = memnew(Image(_javascript_logo));
logo.instance();
logo->create_from_image(img);
img = Ref<Image>(memnew(Image(_javascript_run_icon)));
run_icon.instance();
run_icon->create_from_image(img);
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
if (theme.is_valid()) {
stop_icon = theme->get_icon("Stop", "EditorIcons");
} else {
stop_icon.instance();
}
}
EditorExportPlatformJavaScript::~EditorExportPlatformJavaScript() {
server->stop();
server_quit = true;
Thread::wait_to_finish(server_thread);
memdelete(server_thread);
}
*/
void register_javascript_exporter() {
EDITOR_DEF("export/web/http_host", "localhost");
EDITOR_DEF("export/web/http_port", 8060);

View file

@ -300,7 +300,7 @@ void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportP
if (p_preset->get("vram_texture_compression/for_mobile")) {
String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name");
if (driver == "OpenGL") {
if (driver == "OpenGL3") {
r_features->push_back("etc");
} else if (driver == "Vulkan") {
// FIXME: Review if this is correct.

View file

@ -381,7 +381,7 @@ def configure(env):
# No pkgconfig file for glslang so far
env.Append(LIBS=["glslang", "SPIRV"])
env.Append(CPPDEFINES=["OPENGL_ENABLED"])
env.Append(CPPDEFINES=["GLES3_ENABLED"])
env.Append(LIBS=["GL"])
env.Append(LIBS=["pthread"])

View file

@ -29,7 +29,7 @@
/*************************************************************************/
#ifdef X11_ENABLED
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
#include "detect_prime_x11.h"

View file

@ -29,7 +29,7 @@
/*************************************************************************/
#ifdef X11_ENABLED
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
int detect_prime();

View file

@ -44,8 +44,8 @@
#include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
#endif
#if defined(OPENGL_ENABLED)
#include "drivers/opengl/rasterizer_opengl.h"
#if defined(GLES3_ENABLED)
#include "drivers/gles3/rasterizer_gles3.h"
#endif
#include <limits.h>
@ -889,7 +889,7 @@ void DisplayServerX11::delete_sub_window(WindowID p_id) {
context_vulkan->window_destroy(p_id);
}
#endif
#ifdef OPENGL_ENABLED
#ifdef GLES3_ENABLED
if (gl_manager) {
gl_manager->window_destroy(p_id);
}
@ -1064,7 +1064,7 @@ int DisplayServerX11::window_get_current_screen(WindowID p_window) const {
}
void DisplayServerX11::gl_window_make_current(DisplayServer::WindowID p_window_id) {
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (gl_manager)
gl_manager->window_make_current(p_window_id);
#endif
@ -2666,7 +2666,7 @@ void DisplayServerX11::_window_changed(XEvent *event) {
context_vulkan->window_resize(window_id, wd.size.width, wd.size.height);
}
#endif
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (gl_manager) {
gl_manager->window_resize(window_id, wd.size.width, wd.size.height);
}
@ -3547,19 +3547,19 @@ void DisplayServerX11::process_events() {
}
void DisplayServerX11::release_rendering_thread() {
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
// gl_manager->release_current();
#endif
}
void DisplayServerX11::make_rendering_thread() {
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
// gl_manager->make_current();
#endif
}
void DisplayServerX11::swap_buffers() {
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (gl_manager) {
gl_manager->swap_buffers();
}
@ -3710,7 +3710,7 @@ void DisplayServerX11::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mo
}
#endif
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (gl_manager) {
gl_manager->set_use_vsync(p_vsync_mode == DisplayServer::VSYNC_ENABLED);
}
@ -3724,7 +3724,7 @@ DisplayServer::VSyncMode DisplayServerX11::window_get_vsync_mode(WindowID p_wind
return context_vulkan->get_vsync_mode(p_window);
}
#endif
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (gl_manager) {
return gl_manager->is_using_vsync() ? DisplayServer::VSYNC_ENABLED : DisplayServer::VSYNC_DISABLED;
}
@ -3738,8 +3738,8 @@ Vector<String> DisplayServerX11::get_rendering_drivers_func() {
#ifdef VULKAN_ENABLED
drivers.push_back("vulkan");
#endif
#ifdef OPENGL_ENABLED
drivers.push_back("opengl");
#ifdef GLES3_ENABLED
drivers.push_back("opengl3");
#endif
return drivers;
@ -3924,8 +3924,7 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, V
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create a Vulkan window");
}
#endif
#ifdef OPENGL_ENABLED
print_line("rendering_driver " + rendering_driver);
#ifdef GLES3_ENABLED
if (gl_manager) {
Error err = gl_manager->window_create(id, wd.x11_window, x11_display, p_rect.size.width, p_rect.size.height);
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create an OpenGL window");
@ -4115,11 +4114,6 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
//TODO - do Vulkan and OpenGL support checks, driver selection and fallback
rendering_driver = p_rendering_driver;
#ifndef _MSC_VER
//#warning Forcing vulkan rendering driver because OpenGL not implemented yet
//#warning Forcing opengl rendering driver because selecting properly is too much effort
#endif
bool driver_found = false;
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
@ -4133,10 +4127,9 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
driver_found = true;
}
#endif
// Init context and rendering device
#if defined(OPENGL_ENABLED)
print_line("rendering_driver " + rendering_driver);
if (rendering_driver == "opengl") {
// Initialize context and rendering device.
#if defined(GLES3_ENABLED)
if (rendering_driver == "opengl3") {
if (getenv("DRI_PRIME") == nullptr) {
int use_prime = -1;
@ -4193,9 +4186,9 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
// gl_manager->set_use_vsync(current_videomode.use_vsync);
if (true) {
// if (RasterizerOpenGL::is_viable() == OK) {
// RasterizerOpenGL::register_config();
RasterizerOpenGL::make_current();
// if (RasterizerGLES3::is_viable() == OK) {
// RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
} else {
memdelete(gl_manager);
gl_manager = nullptr;
@ -4411,8 +4404,8 @@ DisplayServerX11::~DisplayServerX11() {
context_vulkan->window_destroy(E.key);
}
#endif
#ifdef OPENGL_ENABLED
if (rendering_driver == "opengl") {
#ifdef GLES3_ENABLED
if (rendering_driver == "opengl3") {
gl_manager->window_destroy(E.key);
}
#endif
@ -4440,7 +4433,7 @@ DisplayServerX11::~DisplayServerX11() {
}
#endif
#ifdef OPENGL_ENABLED
#ifdef GLES3_ENABLED
if (gl_manager) {
memdelete(gl_manager);
gl_manager = nullptr;

View file

@ -31,7 +31,7 @@
#ifndef DISPLAY_SERVER_X11_H
#define DISPLAY_SERVER_X11_H
#include "drivers/opengl/rasterizer_platforms.h"
#include "drivers/gles3/rasterizer_platforms.h"
#ifdef X11_ENABLED
@ -48,7 +48,7 @@
#include "servers/rendering/renderer_compositor.h"
#include "servers/rendering_server.h"
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
#include "gl_manager_x11.h"
#endif
@ -101,7 +101,7 @@ class DisplayServerX11 : public DisplayServer {
Atom requested;
int xdnd_version;
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
GLManager_X11 *gl_manager = nullptr;
#endif
#if defined(VULKAN_ENABLED)

View file

@ -31,7 +31,7 @@
#include "gl_manager_x11.h"
#ifdef X11_ENABLED
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
#include <stdio.h>
#include <stdlib.h>
@ -175,12 +175,10 @@ Error GLManager_X11::_create_context(GLDisplay &gl_display) {
switch (context_type) {
case GLES_3_0_COMPATIBLE: {
// FIXME: Use `GLX_CONTEXT_CORE_PROFILE_BIT_ARB` instead of compatibility profile
// once deprecated API usages are fixed.
static int context_attribs[] = {
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 3,
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*|GLX_CONTEXT_DEBUG_BIT_ARB*/,
None
};
@ -207,8 +205,6 @@ Error GLManager_X11::_create_context(GLDisplay &gl_display) {
}
Error GLManager_X11::window_create(DisplayServer::WindowID p_window_id, ::Window p_window, Display *p_display, int p_width, int p_height) {
print_line("window_create window id " + itos(p_window_id));
// make sure vector is big enough...
// we can mirror the external vector, it is simpler
// to keep the IDs identical for fast lookup

View file

@ -33,9 +33,9 @@
#ifdef X11_ENABLED
#include "drivers/opengl/rasterizer_platforms.h"
#include "drivers/gles3/rasterizer_platforms.h"
#ifdef OPENGL_ENABLED
#ifdef GLES3_ENABLED
#include "core/os/os.h"
#include "core/templates/local_vector.h"
@ -124,7 +124,7 @@ public:
~GLManager_X11();
};
#endif // OPENGL_ENABLED
#endif // GLES3_ENABLED
#endif // X11_ENABLED
#endif // GL_MANAGER_X11_H

View file

@ -31,7 +31,7 @@
#ifndef CONTEXT_GL_OSX_H
#define CONTEXT_GL_OSX_H
#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED)
#if defined(GLES3_ENABLED) || defined(GLES_ENABLED)
#include "core/error/error_list.h"
#include "core/os/os.h"
@ -41,7 +41,7 @@
#include <CoreVideo/CoreVideo.h>
class ContextGL_OSX {
bool opengl_3_context;
bool gles3_context;
bool use_vsync;
void *framework;
@ -66,7 +66,7 @@ public:
void set_use_vsync(bool p_use);
bool is_using_vsync() const;
ContextGL_OSX(id p_view, bool p_opengl_3_context);
ContextGL_OSX(id p_view, bool p_gles3_context);
~ContextGL_OSX();
};

View file

@ -30,7 +30,7 @@
#include "context_gl_osx.h"
#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED)
#if defined(GLES3_ENABLED) || defined(GLES_ENABLED)
void ContextGL_OSX::release_current() {
[NSOpenGLContext clearCurrentContext];
@ -98,7 +98,7 @@ Error ContextGL_OSX::initialize() {
ADD_ATTR(NSOpenGLPFADoubleBuffer);
ADD_ATTR(NSOpenGLPFAClosestPolicy);
if (!opengl_3_context) {
if (!gles3_context) {
ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersionLegacy);
} else {
//we now need OpenGL 3 or better, maybe even change this to 3_3Core ?
@ -150,8 +150,8 @@ Error ContextGL_OSX::initialize() {
return OK;
}
ContextGL_OSX::ContextGL_OSX(id p_view, bool p_opengl_3_context) {
opengl_3_context = p_opengl_3_context;
ContextGL_OSX::ContextGL_OSX(id p_view, bool p_gles3_context) {
gles3_context = p_gles3_context;
window_view = p_view;
use_vsync = false;
}

View file

@ -189,4 +189,4 @@ def configure(env):
if not env["use_volk"]:
env.Append(LINKFLAGS=["-L$VULKAN_SDK_PATH/MoltenVK/MoltenVK.xcframework/macos-arm64_x86_64/", "-lMoltenVK"])
# env.Append(CPPDEFINES=['GLES_ENABLED', 'OPENGL_ENABLED'])
# env.Append(CPPDEFINES=['GLES_ENABLED', 'GLES3_ENABLED'])

View file

@ -36,7 +36,7 @@
#include "core/input/input.h"
#include "servers/display_server.h"
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
#include "context_gl_osx.h"
//TODO - reimplement OpenGLES
#endif
@ -64,7 +64,7 @@ public:
NSMenu *_get_dock_menu() const;
void _menu_callback(id p_sender);
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
ContextGL_OSX *context_gles2;
#endif
#if defined(VULKAN_ENABLED)
@ -109,7 +109,7 @@ public:
Vector<Vector2> mpath;
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
ContextGL_OSX *context_gles2 = nullptr;
#endif
Point2i mouse_pos;

View file

@ -45,7 +45,7 @@
#include <IOKit/hid/IOHIDKeys.h>
#include <IOKit/hid/IOHIDLib.h>
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
//TODO - reimplement OpenGLES
#import <AppKit/NSOpenGLView.h>
@ -166,7 +166,7 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
[pwd.window_object makeKeyAndOrderFront:nil]; // Move focus back to main window if there is no parent or other windows left.
}
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (DS_OSX->rendering_driver == "opengl_es") {
//TODO - reimplement OpenGLES
}
@ -271,7 +271,7 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
layer.contentsScale = scale;
}
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (DS_OSX->rendering_driver == "opengl_es") {
//TODO - reimplement OpenGLES
}
@ -405,7 +405,7 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
}
- (CALayer *)makeBackingLayer {
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (DS_OSX->rendering_driver == "opengl_es") {
CALayer *layer = [[NSOpenGLLayer class] layer];
return layer;
@ -421,7 +421,7 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
}
- (void)updateLayer {
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (DS_OSX->rendering_driver == "opengl_es") {
[super updateLayer];
//TODO - reimplement OpenGLES
@ -2586,7 +2586,7 @@ void DisplayServerOSX::_set_window_per_pixel_transparency_enabled(bool p_enabled
//TODO - implement transparency for Vulkan
}
#endif
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (rendering_driver == "opengl_es") {
//TODO - reimplement OpenGLES
}
@ -2605,14 +2605,14 @@ void DisplayServerOSX::_set_window_per_pixel_transparency_enabled(bool p_enabled
//TODO - implement transparency for Vulkan
}
#endif
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (rendering_driver == "opengl_es") {
//TODO - reimplement OpenGLES
}
#endif
wd.layered_window = false;
}
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (rendering_driver == "opengl_es") {
//TODO - reimplement OpenGLES
}
@ -3475,7 +3475,7 @@ Vector<String> DisplayServerOSX::get_rendering_drivers_func() {
#if defined(VULKAN_ENABLED)
drivers.push_back("vulkan");
#endif
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
drivers.push_back("opengl_es");
#endif
@ -3579,7 +3579,7 @@ DisplayServerOSX::WindowID DisplayServerOSX::_create_window(WindowMode p_mode, V
}
}
#endif
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (rendering_driver == "opengl_es") {
//TODO - reimplement OpenGLES
}
@ -3600,7 +3600,7 @@ DisplayServerOSX::WindowID DisplayServerOSX::_create_window(WindowMode p_mode, V
layer.contentsScale = scale;
}
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (rendering_driver == "opengl_es") {
//TODO - reimplement OpenGLES
}
@ -3758,7 +3758,7 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode
#endif
rendering_driver = "vulkan";
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (rendering_driver == "opengl_es") {
//TODO - reimplement OpenGLES
}
@ -3787,7 +3787,7 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode
}
show_window(MAIN_WINDOW_ID);
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (rendering_driver == "opengl_es") {
//TODO - reimplement OpenGLES
}
@ -3820,7 +3820,7 @@ DisplayServerOSX::~DisplayServerOSX() {
}
//destroy drivers
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (rendering_driver == "opengl_es") {
//TODO - reimplement OpenGLES
}

View file

@ -175,9 +175,9 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
}
if (opengl_api_type == ContextEGL_UWP::GLES_2_0) {
if (RasterizerOpenGLis_viable() == OK) {
RasterizerOpenGLregister_config();
RasterizerOpenGLmake_current();
if (RasterizerGLES3::is_viable() == OK) {
RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
} else {
gl_initialization_error = true;
}
@ -319,7 +319,7 @@ void OS_UWP::finalize() {
rendering_server->finish();
memdelete(rendering_server);
#ifdef OPENGL_ENABLED
#ifdef GLES3_ENABLED
if (gl_context)
memdelete(gl_context);
#endif

View file

@ -1,186 +0,0 @@
/*************************************************************************/
/* context_gl_windows.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED)
// Author: Juan Linietsky <reduzio@gmail.com>, (C) 2008
#include "context_gl_windows.h"
#include <dwmapi.h>
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
#define WGL_CONTEXT_FLAGS_ARB 0x2094
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
#if defined(__GNUC__)
// Workaround GCC warning from -Wcast-function-type.
#define wglGetProcAddress (void *)wglGetProcAddress
#endif
typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int *);
void ContextGL_Windows::release_current() {
wglMakeCurrent(hDC, nullptr);
}
void ContextGL_Windows::make_current() {
wglMakeCurrent(hDC, hRC);
}
int ContextGL_Windows::get_window_width() {
return OS::get_singleton()->get_video_mode().width;
}
int ContextGL_Windows::get_window_height() {
return OS::get_singleton()->get_video_mode().height;
}
void ContextGL_Windows::swap_buffers() {
SwapBuffers(hDC);
}
void ContextGL_Windows::set_use_vsync(bool p_use) {
if (wglSwapIntervalEXT) {
int swap_interval = p_use ? 1 : 0;
wglSwapIntervalEXT(swap_interval);
}
use_vsync = p_use;
}
bool ContextGL_Windows::is_using_vsync() const {
return use_vsync;
}
#define _WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
Error ContextGL_Windows::initialize() {
static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1,
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER,
(BYTE)PFD_TYPE_RGBA,
(BYTE)(OS::get_singleton()->is_layered_allowed() ? 32 : 24),
(BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, // Color Bits Ignored
(BYTE)(OS::get_singleton()->is_layered_allowed() ? 8 : 0), // Alpha Buffer
(BYTE)0, // Shift Bit Ignored
(BYTE)0, // No Accumulation Buffer
(BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, // Accumulation Bits Ignored
(BYTE)24, // 24Bit Z-Buffer (Depth Buffer)
(BYTE)0, // No Stencil Buffer
(BYTE)0, // No Auxiliary Buffer
(BYTE)PFD_MAIN_PLANE, // Main Drawing Layer
(BYTE)0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
hDC = GetDC(hWnd);
if (!hDC) {
return ERR_CANT_CREATE; // Return FALSE
}
pixel_format = ChoosePixelFormat(hDC, &pfd);
if (!pixel_format) // Did Windows Find A Matching Pixel Format?
{
return ERR_CANT_CREATE; // Return FALSE
}
BOOL ret = SetPixelFormat(hDC, pixel_format, &pfd);
if (!ret) // Are We Able To Set The Pixel Format?
{
return ERR_CANT_CREATE; // Return FALSE
}
hRC = wglCreateContext(hDC);
if (!hRC) // Are We Able To Get A Rendering Context?
{
return ERR_CANT_CREATE; // Return FALSE
}
wglMakeCurrent(hDC, hRC);
if (opengl_3_context) {
int attribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, 3, //we want a 3.3 context
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
//and it shall be forward compatible so that we can only use up to date functionality
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*| _WGL_CONTEXT_DEBUG_BIT_ARB*/,
0
}; //zero indicates the end of the array
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr; //pointer to the method
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
if (wglCreateContextAttribsARB == nullptr) //OpenGL 3.0 is not supported
{
wglDeleteContext(hRC);
return ERR_CANT_CREATE;
}
HGLRC new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs);
if (!new_hRC) {
wglDeleteContext(hRC);
return ERR_CANT_CREATE; // Return false
}
wglMakeCurrent(hDC, nullptr);
wglDeleteContext(hRC);
hRC = new_hRC;
if (!wglMakeCurrent(hDC, hRC)) // Try To Activate The Rendering Context
{
return ERR_CANT_CREATE; // Return FALSE
}
}
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress("wglGetSwapIntervalEXT");
//glWrapperInit(wrapper_get_proc_address);
return OK;
}
ContextGL_Windows::ContextGL_Windows(HWND hwnd, bool p_opengl_3_context) {
opengl_3_context = p_opengl_3_context;
hWnd = hwnd;
use_vsync = false;
pixel_format = 0;
}
ContextGL_Windows::~ContextGL_Windows() {
}
#endif

View file

@ -279,7 +279,7 @@ def configure_msvc(env, manual_msvc_config):
if not env["use_volk"]:
LIBS += ["vulkan"]
env.AppendUnique(CPPDEFINES=["OPENGL_ENABLED"])
env.AppendUnique(CPPDEFINES=["GLES3_ENABLED"])
LIBS += ["opengl32"]
env.Append(LINKFLAGS=[p + env["LIBSUFFIX"] for p in LIBS])
@ -453,7 +453,7 @@ def configure_mingw(env):
if not env["use_volk"]:
env.Append(LIBS=["vulkan"])
env.Append(CPPDEFINES=["OPENGL_ENABLED"])
env.Append(CPPDEFINES=["GLES3_ENABLED"])
env.Append(LIBS=["opengl32"])
env.Append(CPPDEFINES=["MINGW_ENABLED", ("MINGW_HAS_SECURE_API", 1)])

View file

@ -38,8 +38,8 @@
#include <avrt.h>
#if defined(OPENGL_ENABLED)
#include "drivers/opengl/rasterizer_opengl.h"
#if defined(GLES3_ENABLED)
#include "drivers/gles3/rasterizer_gles3.h"
#endif
static String format_error_message(DWORD id) {
@ -537,8 +537,8 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) {
context_vulkan->window_destroy(p_window);
}
#endif
#ifdef OPENGL_ENABLED
if (rendering_driver == "opengl") {
#ifdef GLES3_ENABLED
if (rendering_driver == "opengl3") {
gl_manager->window_destroy(p_window);
}
#endif
@ -552,7 +552,7 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) {
}
void DisplayServerWindows::gl_window_make_current(DisplayServer::WindowID p_window_id) {
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
gl_manager->window_make_current(p_window_id);
#endif
}
@ -827,8 +827,8 @@ void DisplayServerWindows::window_set_size(const Size2i p_size, WindowID p_windo
context_vulkan->window_resize(p_window, w, h);
}
#endif
#if defined(OPENGL_ENABLED)
if (rendering_driver == "opengl") {
#if defined(GLES3_ENABLED)
if (rendering_driver == "opengl3") {
gl_manager->window_resize(p_window, w, h);
}
#endif
@ -1611,7 +1611,7 @@ void DisplayServerWindows::make_rendering_thread() {
}
void DisplayServerWindows::swap_buffers() {
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
gl_manager->swap_buffers();
#endif
}
@ -3110,9 +3110,8 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
}
#endif
#ifdef OPENGL_ENABLED
print_line("rendering_driver " + rendering_driver);
if (rendering_driver == "opengl") {
#ifdef GLES3_ENABLED
if (rendering_driver == "opengl3") {
Error err = gl_manager->window_create(id, wd.hWnd, hInstance, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top);
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Failed to create an OpenGL window.");
}
@ -3326,8 +3325,6 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
use_raw_input = false;
}
print_line("rendering_driver " + rendering_driver);
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
context_vulkan = memnew(VulkanContextWindows);
@ -3340,9 +3337,9 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
}
#endif
// Init context and rendering device
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
if (rendering_driver == "opengl") {
if (rendering_driver == "opengl3") {
GLManager_Windows::ContextType opengl_api_type = GLManager_Windows::GLES_3_0_COMPATIBLE;
gl_manager = memnew(GLManager_Windows(opengl_api_type));
@ -3355,42 +3352,10 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
}
// gl_manager->set_use_vsync(current_videomode.use_vsync);
if (true) {
RasterizerOpenGL::make_current();
} else {
memdelete(gl_manager);
gl_manager = nullptr;
r_error = ERR_UNAVAILABLE;
return;
}
RasterizerGLES3::make_current();
}
#endif
/*
#if defined(OPENGL_ENABLED)
if (rendering_driver_index == VIDEO_DRIVER_GLES2) {
context_gles2 = memnew(ContextGL_Windows(hWnd, false));
if (context_gles2->initialize() != OK) {
memdelete(context_gles2);
context_gles2 = nullptr;
ERR_FAIL_V(ERR_UNAVAILABLE);
}
context_gles2->set_use_vsync(video_mode.use_vsync);
if (RasterizerOpenGL::is_viable() == OK) {
RasterizerOpenGL::register_config();
RasterizerOpenGL::make_current();
} else {
memdelete(context_gles2);
context_gles2 = nullptr;
ERR_FAIL_V(ERR_UNAVAILABLE);
}
}
#endif
*/
Point2i window_position(
(screen_get_size(0).width - p_resolution.width) / 2,
(screen_get_size(0).height - p_resolution.height) / 2);
@ -3448,8 +3413,8 @@ Vector<String> DisplayServerWindows::get_rendering_drivers_func() {
#ifdef VULKAN_ENABLED
drivers.push_back("vulkan");
#endif
#ifdef OPENGL_ENABLED
drivers.push_back("opengl");
#ifdef GLES3_ENABLED
drivers.push_back("opengl3");
#endif
return drivers;
@ -3479,7 +3444,7 @@ DisplayServerWindows::~DisplayServerWindows() {
SetWindowLongPtr(windows[MAIN_WINDOW_ID].hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc);
};
#ifdef OPENGL_ENABLED
#ifdef GLES3_ENABLED
// destroy windows .. NYI?
#endif
@ -3511,7 +3476,7 @@ DisplayServerWindows::~DisplayServerWindows() {
if (restore_mouse_trails > 1) {
SystemParametersInfoA(SPI_SETMOUSETRAILS, restore_mouse_trails, 0, 0);
}
#ifdef OPENGL_ENABLED
#ifdef GLES3_ENABLED
if (gl_manager) {
memdelete(gl_manager);
gl_manager = nullptr;

View file

@ -56,7 +56,7 @@
#include "platform/windows/vulkan_context_win.h"
#endif
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
#include "gl_manager_windows.h"
#endif
@ -304,7 +304,7 @@ class DisplayServerWindows : public DisplayServer {
int old_x, old_y;
Point2i center;
#if defined(OPENGL_ENABLED)
#if defined(GLES3_ENABLED)
GLManager_Windows *gl_manager;
#endif

View file

@ -31,7 +31,7 @@
#include "gl_manager_windows.h"
#ifdef WINDOWS_ENABLED
#ifdef OPENGL_ENABLED
#ifdef GLES3_ENABLED
#include <stdio.h>
#include <stdlib.h>
@ -129,50 +129,46 @@ Error GLManager_Windows::_create_context(GLWindow &win, GLDisplay &gl_display) {
wglMakeCurrent(hDC, gl_display.hRC);
if (opengl_3_context) {
int attribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, 3, //we want a 3.3 context
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
//and it shall be forward compatible so that we can only use up to date functionality
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*| _WGL_CONTEXT_DEBUG_BIT_ARB*/,
0
}; //zero indicates the end of the array
int attribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, 3, //we want a 3.3 context
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
//and it shall be forward compatible so that we can only use up to date functionality
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*| _WGL_CONTEXT_DEBUG_BIT_ARB*/,
0
}; //zero indicates the end of the array
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr; //pointer to the method
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr; //pointer to the method
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
if (wglCreateContextAttribsARB == nullptr) //OpenGL 3.0 is not supported
{
wglDeleteContext(gl_display.hRC);
gl_display.hRC = 0;
return ERR_CANT_CREATE;
}
HGLRC new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs);
if (!new_hRC) {
wglDeleteContext(gl_display.hRC);
gl_display.hRC = 0;
return ERR_CANT_CREATE; // Return false
}
wglMakeCurrent(hDC, nullptr);
if (wglCreateContextAttribsARB == nullptr) //OpenGL 3.0 is not supported
{
wglDeleteContext(gl_display.hRC);
gl_display.hRC = new_hRC;
gl_display.hRC = 0;
return ERR_CANT_CREATE;
}
if (!wglMakeCurrent(hDC, gl_display.hRC)) // Try To Activate The Rendering Context
{
wglDeleteContext(gl_display.hRC);
gl_display.hRC = 0;
return ERR_CANT_CREATE; // Return FALSE
}
HGLRC new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs);
if (!new_hRC) {
wglDeleteContext(gl_display.hRC);
gl_display.hRC = 0;
return ERR_CANT_CREATE; // Return false
}
wglMakeCurrent(hDC, nullptr);
wglDeleteContext(gl_display.hRC);
gl_display.hRC = new_hRC;
if (!wglMakeCurrent(hDC, gl_display.hRC)) // Try To Activate The Rendering Context
{
wglDeleteContext(gl_display.hRC);
gl_display.hRC = 0;
return ERR_CANT_CREATE; // Return FALSE
}
return OK;
}
Error GLManager_Windows::window_create(DisplayServer::WindowID p_window_id, HWND p_hwnd, HINSTANCE p_hinstance, int p_width, int p_height) {
print_line("window_create window id " + itos(p_window_id));
HDC hdc = GetDC(p_hwnd);
if (!hdc) {
return ERR_CANT_CREATE; // Return FALSE
@ -349,5 +345,5 @@ GLManager_Windows::~GLManager_Windows() {
release_current();
}
#endif // OPENGL_ENABLED
#endif // GLES3_ENABLED
#endif // WINDOWS

View file

@ -31,7 +31,7 @@
#ifndef GL_MANAGER_WINDOWS_H
#define GL_MANAGER_WINDOWS_H
#if defined(WINDOWS_ENABLED) && defined(OPENGL_ENABLED)
#if defined(WINDOWS_ENABLED) && defined(GLES3_ENABLED)
#include "core/error/error_list.h"
#include "core/os/os.h"
@ -76,7 +76,6 @@ private:
LocalVector<GLDisplay> _displays;
GLWindow *_current_window;
bool opengl_3_context = false;
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT;
@ -123,6 +122,6 @@ public:
~GLManager_Windows();
};
#endif // defined(WINDOWS_ENABLED) && defined(OPENGL_ENABLED)
#endif // defined(WINDOWS_ENABLED) && defined(GLES3_ENABLED)
#endif // GL_MANAGER_WINDOWS_H

View file

@ -2722,7 +2722,7 @@ void RenderForwardClustered::_geometry_instance_update(GeometryInstance *p_geome
} break;
#if 0
case RS::INSTANCE_IMMEDIATE: {
RasterizerStorageOpenGL::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base);
RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base);
ERR_CONTINUE(!immediate);
_add_geometry(immediate, inst, nullptr, -1, p_depth_pass, p_shadow_pass);

View file

@ -2440,7 +2440,7 @@ void RenderForwardMobile::_geometry_instance_update(GeometryInstance *p_geometry
} break;
#if 0
case RS::INSTANCE_IMMEDIATE: {
RasterizerStorageOpenGL::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base);
RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base);
ERR_CONTINUE(!immediate);
_add_geometry(immediate, inst, nullptr, -1, p_depth_pass, p_shadow_pass);

View file

@ -129,7 +129,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
timestamp_vp_map[rt_id] = p_viewport->self;
}
if (OS::get_singleton()->get_current_rendering_driver_name() == "opengl") {
if (OS::get_singleton()->get_current_rendering_driver_name() == "opengl3") {
// This is currently needed for GLES to keep the current window being rendered to up to date
DisplayServer::get_singleton()->gl_window_make_current(p_viewport->viewport_to_screen);
}

View file

@ -2957,6 +2957,43 @@ RenderingServer::RenderingServer() {
ProjectSettings::get_singleton()->set_custom_property_info("rendering/limits/cluster_builder/max_clustered_elements", PropertyInfo(Variant::FLOAT, "rendering/limits/cluster_builder/max_clustered_elements", PROPERTY_HINT_RANGE, "32,8192,1"));
GLOBAL_DEF_RST("rendering/xr/enabled", false);
GLOBAL_DEF_RST("rendering/2d/options/use_software_skinning", true);
GLOBAL_DEF_RST("rendering/2d/options/ninepatch_mode", 1);
ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/options/ninepatch_mode", PropertyInfo(Variant::INT, "rendering/2d/options/ninepatch_mode", PROPERTY_HINT_ENUM, "Fixed,Scaling"));
GLOBAL_DEF_RST("rendering/2d/opengl/batching_send_null", 0);
ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/batching_send_null", PropertyInfo(Variant::INT, "rendering/2d/opengl/batching_send_null", PROPERTY_HINT_ENUM, "Default (On),Off,On"));
GLOBAL_DEF_RST("rendering/2d/opengl/batching_stream", 0);
ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/batching_stream", PropertyInfo(Variant::INT, "rendering/2d/opengl/batching_stream", PROPERTY_HINT_ENUM, "Default (Off),Off,On"));
GLOBAL_DEF_RST("rendering/2d/opengl/legacy_orphan_buffers", 0);
ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/legacy_orphan_buffers", PropertyInfo(Variant::INT, "rendering/2d/opengl/legacy_orphan_buffers", PROPERTY_HINT_ENUM, "Default (On),Off,On"));
GLOBAL_DEF_RST("rendering/2d/opengl/legacy_stream", 0);
ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/legacy_stream", PropertyInfo(Variant::INT, "rendering/2d/opengl/legacy_stream", PROPERTY_HINT_ENUM, "Default (On),Off,On"));
GLOBAL_DEF("rendering/batching/options/use_batching", false);
GLOBAL_DEF_RST("rendering/batching/options/use_batching_in_editor", false);
GLOBAL_DEF("rendering/batching/options/single_rect_fallback", false);
GLOBAL_DEF("rendering/batching/parameters/max_join_item_commands", 16);
GLOBAL_DEF("rendering/batching/parameters/colored_vertex_format_threshold", 0.25f);
GLOBAL_DEF("rendering/batching/lights/scissor_area_threshold", 1.0f);
GLOBAL_DEF("rendering/batching/lights/max_join_items", 32);
GLOBAL_DEF("rendering/batching/parameters/batch_buffer_size", 16384);
GLOBAL_DEF("rendering/batching/parameters/item_reordering_lookahead", 4);
GLOBAL_DEF("rendering/batching/debug/flash_batching", false);
GLOBAL_DEF("rendering/batching/debug/diagnose_frame", false);
GLOBAL_DEF("rendering/gles2/compatibility/disable_half_float", false);
GLOBAL_DEF("rendering/gles2/compatibility/enable_high_float.Android", false);
GLOBAL_DEF("rendering/batching/precision/uv_contract", false);
GLOBAL_DEF("rendering/batching/precision/uv_contract_amount", 100);
ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/max_join_item_commands", PropertyInfo(Variant::INT, "rendering/batching/parameters/max_join_item_commands", PROPERTY_HINT_RANGE, "0,65535"));
ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/colored_vertex_format_threshold", PropertyInfo(Variant::FLOAT, "rendering/batching/parameters/colored_vertex_format_threshold", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"));
ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/batch_buffer_size", PropertyInfo(Variant::INT, "rendering/batching/parameters/batch_buffer_size", PROPERTY_HINT_RANGE, "1024,65535,1024"));
ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/lights/scissor_area_threshold", PropertyInfo(Variant::FLOAT, "rendering/batching/lights/scissor_area_threshold", PROPERTY_HINT_RANGE, "0.0,1.0"));
ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/lights/max_join_items", PropertyInfo(Variant::INT, "rendering/batching/lights/max_join_items", PROPERTY_HINT_RANGE, "0,512"));
ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/item_reordering_lookahead", PropertyInfo(Variant::INT, "rendering/batching/parameters/item_reordering_lookahead", PROPERTY_HINT_RANGE, "0,256"));
ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/precision/uv_contract_amount", PropertyInfo(Variant::INT, "rendering/batching/precision/uv_contract_amount", PROPERTY_HINT_RANGE, "0,10000"));
}
RenderingServer::~RenderingServer() {