diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/d3d12/SCsub | 6 | ||||
| -rw-r--r-- | drivers/d3d12/dxil_hash.cpp | 2 | ||||
| -rw-r--r-- | drivers/d3d12/rendering_device_driver_d3d12.cpp | 9 | ||||
| -rw-r--r-- | drivers/egl/egl_manager.cpp | 65 | ||||
| -rw-r--r-- | drivers/egl/egl_manager.h | 7 | ||||
| -rw-r--r-- | drivers/gles3/rasterizer_gles3.cpp | 21 | ||||
| -rw-r--r-- | drivers/gles3/rasterizer_gles3.h | 10 | ||||
| -rw-r--r-- | drivers/gles3/storage/mesh_storage.cpp | 6 | ||||
| -rw-r--r-- | drivers/gles3/storage/mesh_storage.h | 2 |
9 files changed, 117 insertions, 11 deletions
diff --git a/drivers/d3d12/SCsub b/drivers/d3d12/SCsub index b6ceed23ac..beeb13398e 100644 --- a/drivers/d3d12/SCsub +++ b/drivers/d3d12/SCsub @@ -4,6 +4,8 @@ from misc.utility.scons_hints import * import os from pathlib import Path +import methods + Import("env") env_d3d12_rdd = env.Clone() @@ -139,6 +141,10 @@ else: extra_defines += [ "HAVE_STRUCT_TIMESPEC", ] + if methods.using_gcc(env) and methods.get_compiler_version(env)["major"] < 13: + # `region` & `endregion` not recognized as valid pragmas. + env_d3d12_rdd.Append(CCFLAGS=["-Wno-unknown-pragmas"]) + env.Append(CCFLAGS=["-Wno-unknown-pragmas"]) # This is needed since rendering_device_d3d12.cpp needs to include some Mesa internals. env_d3d12_rdd.Prepend(CPPPATH=mesa_private_inc_paths) diff --git a/drivers/d3d12/dxil_hash.cpp b/drivers/d3d12/dxil_hash.cpp index f94a4a30df..e08492c9ea 100644 --- a/drivers/d3d12/dxil_hash.cpp +++ b/drivers/d3d12/dxil_hash.cpp @@ -96,7 +96,7 @@ void compute_dxil_hash(const BYTE *pData, UINT byteCount, BYTE *pOutHash) { UINT NextEndState = bTwoRowsPadding ? N - 2 : N - 1; const BYTE *pCurrData = pData; for (UINT i = 0; i < N; i++, offset += 64, pCurrData += 64) { - UINT x[16]; + UINT x[16] = {}; const UINT *pX; if (i == NextEndState) { if (!bTwoRowsPadding && i == N - 1) { diff --git a/drivers/d3d12/rendering_device_driver_d3d12.cpp b/drivers/d3d12/rendering_device_driver_d3d12.cpp index 8271d4b7e3..0ef88e7d52 100644 --- a/drivers/d3d12/rendering_device_driver_d3d12.cpp +++ b/drivers/d3d12/rendering_device_driver_d3d12.cpp @@ -1348,7 +1348,14 @@ RDD::TextureID RenderingDeviceDriverD3D12::texture_create(const TextureFormat &p } tex_info->states_ptr = &tex_info->owner_info.states; tex_info->format = p_format.format; +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif tex_info->desc = *(CD3DX12_RESOURCE_DESC *)&resource_desc; +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif tex_info->base_layer = 0; tex_info->layers = resource_desc.ArraySize(); tex_info->base_mip = 0; @@ -6578,8 +6585,6 @@ static Error create_command_signature(ID3D12Device *device, D3D12_INDIRECT_ARGUM Error RenderingDeviceDriverD3D12::_initialize_frames(uint32_t p_frame_count) { Error err; - D3D12MA::ALLOCATION_DESC allocation_desc = {}; - allocation_desc.HeapType = D3D12_HEAP_TYPE_DEFAULT; //CD3DX12_RESOURCE_DESC resource_desc = CD3DX12_RESOURCE_DESC::Buffer(D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT); uint32_t resource_descriptors_per_frame = GLOBAL_GET("rendering/rendering_device/d3d12/max_resource_descriptors_per_frame"); diff --git a/drivers/egl/egl_manager.cpp b/drivers/egl/egl_manager.cpp index 4477ba7752..603dfadd4b 100644 --- a/drivers/egl/egl_manager.cpp +++ b/drivers/egl/egl_manager.cpp @@ -30,6 +30,8 @@ #include "egl_manager.h" +#include "drivers/gles3/rasterizer_gles3.h" + #ifdef EGL_ENABLED #if defined(EGL_STATIC) @@ -51,6 +53,16 @@ extern "C" EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT(EGLenum platfo #define GLAD_EGL_EXT_platform_base 0 #endif +#ifdef WINDOWS_ENABLED +// Unofficial ANGLE extension: EGL_ANGLE_surface_orientation +#ifndef EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE +#define EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE 0x33A7 +#define EGL_SURFACE_ORIENTATION_ANGLE 0x33A8 +#define EGL_SURFACE_ORIENTATION_INVERT_X_ANGLE 0x0001 +#define EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE 0x0002 +#endif +#endif + // Creates and caches a GLDisplay. Returns -1 on error. int EGLManager::_get_gldisplay_id(void *p_display) { // Look for a cached GLDisplay. @@ -115,6 +127,18 @@ int EGLManager::_get_gldisplay_id(void *p_display) { } #endif +#ifdef WINDOWS_ENABLED + String client_extensions_string = eglQueryString(new_gldisplay.egl_display, EGL_EXTENSIONS); + if (eglGetError() == EGL_SUCCESS) { + Vector<String> egl_extensions = client_extensions_string.split(" "); + + if (egl_extensions.has("EGL_ANGLE_surface_orientation")) { + new_gldisplay.has_EGL_ANGLE_surface_orientation = true; + print_verbose("EGL: EGL_ANGLE_surface_orientation is supported."); + } + } +#endif + displays.push_back(new_gldisplay); // Return the new GLDisplay's ID. @@ -237,8 +261,29 @@ Error EGLManager::window_create(DisplayServer::WindowID p_window_id, void *p_dis GLWindow &glwindow = windows[p_window_id]; glwindow.gldisplay_id = gldisplay_id; + Vector<EGLAttrib> egl_attribs; + +#ifdef WINDOWS_ENABLED + if (gldisplay.has_EGL_ANGLE_surface_orientation) { + EGLint optimal_orientation; + if (eglGetConfigAttrib(gldisplay.egl_display, gldisplay.egl_config, EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, &optimal_orientation)) { + // We only need to support inverting Y for optimizing ANGLE on D3D11. + if (optimal_orientation & EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE && !(optimal_orientation & EGL_SURFACE_ORIENTATION_INVERT_X_ANGLE)) { + egl_attribs.push_back(EGL_SURFACE_ORIENTATION_ANGLE); + egl_attribs.push_back(EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE); + } + } else { + ERR_PRINT(vformat("Failed to get EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, error: 0x%08X", eglGetError())); + } + } + + if (!egl_attribs.is_empty()) { + egl_attribs.push_back(EGL_NONE); + } +#endif + if (GLAD_EGL_VERSION_1_5) { - glwindow.egl_surface = eglCreatePlatformWindowSurface(gldisplay.egl_display, gldisplay.egl_config, p_native_window, nullptr); + glwindow.egl_surface = eglCreatePlatformWindowSurface(gldisplay.egl_display, gldisplay.egl_config, p_native_window, egl_attribs.ptr()); } else { EGLNativeWindowType *native_window_type = (EGLNativeWindowType *)p_native_window; glwindow.egl_surface = eglCreateWindowSurface(gldisplay.egl_display, gldisplay.egl_config, *native_window_type, nullptr); @@ -250,6 +295,20 @@ Error EGLManager::window_create(DisplayServer::WindowID p_window_id, void *p_dis glwindow.initialized = true; +#ifdef WINDOWS_ENABLED + if (gldisplay.has_EGL_ANGLE_surface_orientation) { + EGLint orientation; + if (eglQuerySurface(gldisplay.egl_display, glwindow.egl_surface, EGL_SURFACE_ORIENTATION_ANGLE, &orientation)) { + if (orientation & EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE && !(orientation & EGL_SURFACE_ORIENTATION_INVERT_X_ANGLE)) { + glwindow.flipped_y = true; + print_verbose("EGL: Using optimal surface orientation: Invert Y"); + } + } else { + ERR_PRINT(vformat("Failed to get EGL_SURFACE_ORIENTATION_ANGLE, error: 0x%08X", eglGetError())); + } + } +#endif + window_make_current(p_window_id); return OK; @@ -316,6 +375,10 @@ void EGLManager::window_make_current(DisplayServer::WindowID p_window_id) { GLDisplay ¤t_display = displays[current_window->gldisplay_id]; eglMakeCurrent(current_display.egl_display, current_window->egl_surface, current_window->egl_surface, current_display.egl_context); + +#ifdef WINDOWS_ENABLED + RasterizerGLES3::set_screen_flipped_y(glwindow.flipped_y); +#endif } void EGLManager::set_use_vsync(bool p_use) { diff --git a/drivers/egl/egl_manager.h b/drivers/egl/egl_manager.h index a4502c0687..f1b3dc99b7 100644 --- a/drivers/egl/egl_manager.h +++ b/drivers/egl/egl_manager.h @@ -53,11 +53,18 @@ private: EGLDisplay egl_display = EGL_NO_DISPLAY; EGLContext egl_context = EGL_NO_CONTEXT; EGLConfig egl_config = nullptr; + +#ifdef WINDOWS_ENABLED + bool has_EGL_ANGLE_surface_orientation = false; +#endif }; // EGL specific window data. struct GLWindow { bool initialized = false; +#ifdef WINDOWS_ENABLED + bool flipped_y = false; +#endif // An handle to the GLDisplay associated with this window. int gldisplay_id = -1; diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index e79f1db08d..6e508c6ebf 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -86,6 +86,10 @@ #define strcpy strcpy_s #endif +#ifdef WINDOWS_ENABLED +bool RasterizerGLES3::screen_flipped_y = false; +#endif + bool RasterizerGLES3::gles_over_gl = true; void RasterizerGLES3::begin_frame(double frame_step) { @@ -389,6 +393,12 @@ void RasterizerGLES3::_blit_render_target_to_screen(RID p_render_target, Display flip_y = false; } +#ifdef WINDOWS_ENABLED + if (screen_flipped_y) { + flip_y = !flip_y; + } +#endif + GLuint read_fbo = 0; glGenFramebuffers(1, &read_fbo); glBindFramebuffer(GL_READ_FRAMEBUFFER, read_fbo); @@ -485,9 +495,14 @@ void RasterizerGLES3::set_boot_image(const Ref<Image> &p_image, const Color &p_c screenrect.position += ((Size2(win_size.width, win_size.height) - screenrect.size) / 2.0).floor(); } - // Flip Y. - screenrect.position.y = win_size.y - screenrect.position.y; - screenrect.size.y = -screenrect.size.y; +#ifdef WINDOWS_ENABLED + if (!screen_flipped_y) +#endif + { + // Flip Y. + screenrect.position.y = win_size.y - screenrect.position.y; + screenrect.size.y = -screenrect.size.y; + } // Normalize texture coordinates to window size. screenrect.position /= win_size; diff --git a/drivers/gles3/rasterizer_gles3.h b/drivers/gles3/rasterizer_gles3.h index 92454e014e..6765d8b4d5 100644 --- a/drivers/gles3/rasterizer_gles3.h +++ b/drivers/gles3/rasterizer_gles3.h @@ -58,6 +58,10 @@ private: double time_total = 0.0; bool flip_xy_workaround = false; +#ifdef WINDOWS_ENABLED + static bool screen_flipped_y; +#endif + static bool gles_over_gl; protected: @@ -118,6 +122,12 @@ public: low_end = true; } +#ifdef WINDOWS_ENABLED + static void set_screen_flipped_y(bool p_flipped) { + screen_flipped_y = p_flipped; + } +#endif + _ALWAYS_INLINE_ uint64_t get_frame_number() const { return frame; } _ALWAYS_INLINE_ double get_frame_delta_time() const { return delta; } _ALWAYS_INLINE_ double get_total_time() const { return time_total; } diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp index 5058554659..73d95d75ba 100644 --- a/drivers/gles3/storage/mesh_storage.cpp +++ b/drivers/gles3/storage/mesh_storage.cpp @@ -2201,7 +2201,7 @@ void MeshStorage::skeleton_allocate_data(RID p_skeleton, int p_bones, bool p_2d_ glBindTexture(GL_TEXTURE_2D, 0); GLES3::Utilities::get_singleton()->texture_allocated_data(skeleton->transforms_texture, skeleton->data.size() * sizeof(float), "Skeleton transforms texture"); - memset(skeleton->data.ptrw(), 0, skeleton->data.size() * sizeof(float)); + memset(skeleton->data.ptr(), 0, skeleton->data.size() * sizeof(float)); _skeleton_make_dirty(skeleton); } @@ -2232,7 +2232,7 @@ void MeshStorage::skeleton_bone_set_transform(RID p_skeleton, int p_bone, const ERR_FAIL_INDEX(p_bone, skeleton->size); ERR_FAIL_COND(skeleton->use_2d); - float *dataptr = skeleton->data.ptrw() + p_bone * 12; + float *dataptr = skeleton->data.ptr() + p_bone * 12; dataptr[0] = p_transform.basis.rows[0][0]; dataptr[1] = p_transform.basis.rows[0][1]; @@ -2284,7 +2284,7 @@ void MeshStorage::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, con ERR_FAIL_INDEX(p_bone, skeleton->size); ERR_FAIL_COND(!skeleton->use_2d); - float *dataptr = skeleton->data.ptrw() + p_bone * 8; + float *dataptr = skeleton->data.ptr() + p_bone * 8; dataptr[0] = p_transform.columns[0][0]; dataptr[1] = p_transform.columns[1][0]; diff --git a/drivers/gles3/storage/mesh_storage.h b/drivers/gles3/storage/mesh_storage.h index 31858cd372..8615b89a30 100644 --- a/drivers/gles3/storage/mesh_storage.h +++ b/drivers/gles3/storage/mesh_storage.h @@ -214,7 +214,7 @@ struct Skeleton { bool use_2d = false; int size = 0; int height = 0; - Vector<float> data; + LocalVector<float> data; bool dirty = false; Skeleton *dirty_list = nullptr; |
