diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/gles3/storage/mesh_storage.cpp | 9 | ||||
| -rw-r--r-- | drivers/gles3/storage/texture_storage.h | 31 | ||||
| -rw-r--r-- | drivers/vulkan/rendering_device_vulkan.cpp | 12 |
3 files changed, 39 insertions, 13 deletions
diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp index ad4bdae272..381cf1a7c6 100644 --- a/drivers/gles3/storage/mesh_storage.cpp +++ b/drivers/gles3/storage/mesh_storage.cpp @@ -1075,6 +1075,7 @@ void MeshStorage::update_mesh_instances() { } glEnable(GL_RASTERIZER_DISCARD); + glBindFramebuffer(GL_FRAMEBUFFER, 0); // Process skeletons and blend shapes using transform feedback while (dirty_mesh_instance_arrays.first()) { MeshInstance *mi = dirty_mesh_instance_arrays.first()->self(); @@ -1284,13 +1285,17 @@ void MeshStorage::multimesh_allocate_data(RID p_multimesh, int p_instances, RS:: multimesh->data_cache_used_dirty_regions = 0; } + // If we have either color or custom data, reserve space for both to make data handling logic simpler. + // This way we can always treat them both as a single, compressed uvec4. + int color_and_custom_strides = (p_use_colors || p_use_custom_data) ? 2 : 0; + multimesh->instances = p_instances; multimesh->xform_format = p_transform_format; multimesh->uses_colors = p_use_colors; multimesh->color_offset_cache = p_transform_format == RS::MULTIMESH_TRANSFORM_2D ? 8 : 12; multimesh->uses_custom_data = p_use_custom_data; - multimesh->custom_data_offset_cache = multimesh->color_offset_cache + (p_use_colors ? 2 : 0); - multimesh->stride_cache = multimesh->custom_data_offset_cache + (p_use_custom_data ? 2 : 0); + multimesh->custom_data_offset_cache = multimesh->color_offset_cache + color_and_custom_strides; + multimesh->stride_cache = multimesh->custom_data_offset_cache + color_and_custom_strides; multimesh->buffer_set = false; multimesh->data_cache = Vector<float>(); diff --git a/drivers/gles3/storage/texture_storage.h b/drivers/gles3/storage/texture_storage.h index fefcd56570..37d3a4fb44 100644 --- a/drivers/gles3/storage/texture_storage.h +++ b/drivers/gles3/storage/texture_storage.h @@ -252,10 +252,10 @@ struct Texture { } Config *config = Config::get_singleton(); state_filter = p_filter; - GLenum pmin = GL_NEAREST; // param min - GLenum pmag = GL_NEAREST; // param mag - GLint max_lod = 1000; - bool use_anisotropy = false; + GLenum pmin = GL_NEAREST; + GLenum pmag = GL_NEAREST; + GLint max_lod = 0; + GLfloat anisotropy = 1.0f; switch (state_filter) { case RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST: { pmin = GL_NEAREST; @@ -268,7 +268,7 @@ struct Texture { max_lod = 0; } break; case RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC: { - use_anisotropy = true; + anisotropy = config->anisotropic_level; }; [[fallthrough]]; case RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: { @@ -278,12 +278,14 @@ struct Texture { max_lod = 0; } else if (config->use_nearest_mip_filter) { pmin = GL_NEAREST_MIPMAP_NEAREST; + max_lod = 1000; } else { pmin = GL_NEAREST_MIPMAP_LINEAR; + max_lod = 1000; } } break; case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC: { - use_anisotropy = true; + anisotropy = config->anisotropic_level; }; [[fallthrough]]; case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: { @@ -293,19 +295,22 @@ struct Texture { max_lod = 0; } else if (config->use_nearest_mip_filter) { pmin = GL_LINEAR_MIPMAP_NEAREST; + max_lod = 1000; } else { pmin = GL_LINEAR_MIPMAP_LINEAR; + max_lod = 1000; } } break; default: { + return; } break; } glTexParameteri(target, GL_TEXTURE_MIN_FILTER, pmin); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, pmag); glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, max_lod); - if (config->support_anisotropic_filter && use_anisotropy) { - glTexParameterf(target, _GL_TEXTURE_MAX_ANISOTROPY_EXT, config->anisotropic_level); + if (config->support_anisotropic_filter) { + glTexParameterf(target, _GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy); } } void gl_set_repeat(RS::CanvasItemTextureRepeat p_repeat) { @@ -313,8 +318,11 @@ struct Texture { return; } state_repeat = p_repeat; - GLenum prep = GL_CLAMP_TO_EDGE; // parameter repeat + GLenum prep = GL_CLAMP_TO_EDGE; switch (state_repeat) { + case RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: { + prep = GL_CLAMP_TO_EDGE; + } break; case RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: { prep = GL_REPEAT; } break; @@ -322,6 +330,7 @@ struct Texture { prep = GL_MIRRORED_REPEAT; } break; default: { + return; } break; } glTexParameteri(target, GL_TEXTURE_WRAP_T, prep); @@ -330,8 +339,8 @@ struct Texture { } private: - RS::CanvasItemTextureFilter state_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR; - RS::CanvasItemTextureRepeat state_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; + RS::CanvasItemTextureFilter state_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_MAX; + RS::CanvasItemTextureRepeat state_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX; }; struct RenderTarget { diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 6cf8f2dfac..a88ddd6b5a 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -7780,6 +7780,8 @@ RenderingDevice::ComputeListID RenderingDeviceVulkan::compute_list_begin(bool p_ } void RenderingDeviceVulkan::compute_list_bind_compute_pipeline(ComputeListID p_list, RID p_compute_pipeline) { + // Must be called within a compute list, the class mutex is locked during that time + ERR_FAIL_COND(p_list != ID_TYPE_COMPUTE_LIST); ERR_FAIL_COND(!compute_list); @@ -7844,6 +7846,8 @@ void RenderingDeviceVulkan::compute_list_bind_compute_pipeline(ComputeListID p_l } void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list, RID p_uniform_set, uint32_t p_index) { + // Must be called within a compute list, the class mutex is locked during that time + ERR_FAIL_COND(p_list != ID_TYPE_COMPUTE_LIST); ERR_FAIL_COND(!compute_list); @@ -8018,6 +8022,8 @@ void RenderingDeviceVulkan::compute_list_set_push_constant(ComputeListID p_list, } void RenderingDeviceVulkan::compute_list_dispatch(ComputeListID p_list, uint32_t p_x_groups, uint32_t p_y_groups, uint32_t p_z_groups) { + // Must be called within a compute list, the class mutex is locked during that time + ERR_FAIL_COND(p_list != ID_TYPE_COMPUTE_LIST); ERR_FAIL_COND(!compute_list); @@ -8161,6 +8167,8 @@ void RenderingDeviceVulkan::compute_list_dispatch_indirect(ComputeListID p_list, } void RenderingDeviceVulkan::compute_list_add_barrier(ComputeListID p_list) { + // Must be called within a compute list, the class mutex is locked during that time + uint32_t barrier_flags = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; uint32_t access_flags = VK_ACCESS_SHADER_READ_BIT; _compute_list_add_barrier(BARRIER_MASK_COMPUTE, barrier_flags, access_flags); @@ -8649,6 +8657,8 @@ void RenderingDeviceVulkan::swap_buffers() { } void RenderingDeviceVulkan::submit() { + _THREAD_SAFE_METHOD_ + ERR_FAIL_COND_MSG(local_device.is_null(), "Only local devices can submit and sync."); ERR_FAIL_COND_MSG(local_device_processing, "device already submitted, call sync to wait until done."); @@ -8660,6 +8670,8 @@ void RenderingDeviceVulkan::submit() { } void RenderingDeviceVulkan::sync() { + _THREAD_SAFE_METHOD_ + ERR_FAIL_COND_MSG(local_device.is_null(), "Only local devices can submit and sync."); ERR_FAIL_COND_MSG(!local_device_processing, "sync can only be called after a submit"); |
