You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Fixes RenderingDevice::get_driver_resource will crash or give incorrect result with certain resources
This commit is contained in:
@@ -5224,8 +5224,12 @@ uint64_t RenderingDevice::get_driver_resource(DriverResource p_resource, RID p_r
|
|||||||
case DRIVER_RESOURCE_LOGICAL_DEVICE:
|
case DRIVER_RESOURCE_LOGICAL_DEVICE:
|
||||||
case DRIVER_RESOURCE_PHYSICAL_DEVICE:
|
case DRIVER_RESOURCE_PHYSICAL_DEVICE:
|
||||||
case DRIVER_RESOURCE_TOPMOST_OBJECT:
|
case DRIVER_RESOURCE_TOPMOST_OBJECT:
|
||||||
|
break;
|
||||||
case DRIVER_RESOURCE_COMMAND_QUEUE:
|
case DRIVER_RESOURCE_COMMAND_QUEUE:
|
||||||
|
driver_id = main_queue.id;
|
||||||
|
break;
|
||||||
case DRIVER_RESOURCE_QUEUE_FAMILY:
|
case DRIVER_RESOURCE_QUEUE_FAMILY:
|
||||||
|
driver_id = main_queue_family.id;
|
||||||
break;
|
break;
|
||||||
case DRIVER_RESOURCE_TEXTURE:
|
case DRIVER_RESOURCE_TEXTURE:
|
||||||
case DRIVER_RESOURCE_TEXTURE_VIEW:
|
case DRIVER_RESOURCE_TEXTURE_VIEW:
|
||||||
@@ -5233,19 +5237,19 @@ uint64_t RenderingDevice::get_driver_resource(DriverResource p_resource, RID p_r
|
|||||||
Texture *tex = texture_owner.get_or_null(p_rid);
|
Texture *tex = texture_owner.get_or_null(p_rid);
|
||||||
ERR_FAIL_NULL_V(tex, 0);
|
ERR_FAIL_NULL_V(tex, 0);
|
||||||
|
|
||||||
driver_id = tex->driver_id;
|
driver_id = tex->driver_id.id;
|
||||||
} break;
|
} break;
|
||||||
case DRIVER_RESOURCE_SAMPLER: {
|
case DRIVER_RESOURCE_SAMPLER: {
|
||||||
RDD::SamplerID *sampler_driver_id = sampler_owner.get_or_null(p_rid);
|
RDD::SamplerID *sampler_driver_id = sampler_owner.get_or_null(p_rid);
|
||||||
ERR_FAIL_NULL_V(sampler_driver_id, 0);
|
ERR_FAIL_NULL_V(sampler_driver_id, 0);
|
||||||
|
|
||||||
driver_id = *sampler_driver_id;
|
driver_id = (*sampler_driver_id).id;
|
||||||
} break;
|
} break;
|
||||||
case DRIVER_RESOURCE_UNIFORM_SET: {
|
case DRIVER_RESOURCE_UNIFORM_SET: {
|
||||||
UniformSet *uniform_set = uniform_set_owner.get_or_null(p_rid);
|
UniformSet *uniform_set = uniform_set_owner.get_or_null(p_rid);
|
||||||
ERR_FAIL_NULL_V(uniform_set, 0);
|
ERR_FAIL_NULL_V(uniform_set, 0);
|
||||||
|
|
||||||
driver_id = uniform_set->driver_id;
|
driver_id = uniform_set->driver_id.id;
|
||||||
} break;
|
} break;
|
||||||
case DRIVER_RESOURCE_BUFFER: {
|
case DRIVER_RESOURCE_BUFFER: {
|
||||||
Buffer *buffer = nullptr;
|
Buffer *buffer = nullptr;
|
||||||
@@ -5262,19 +5266,19 @@ uint64_t RenderingDevice::get_driver_resource(DriverResource p_resource, RID p_r
|
|||||||
}
|
}
|
||||||
ERR_FAIL_NULL_V(buffer, 0);
|
ERR_FAIL_NULL_V(buffer, 0);
|
||||||
|
|
||||||
driver_id = buffer->driver_id;
|
driver_id = buffer->driver_id.id;
|
||||||
} break;
|
} break;
|
||||||
case DRIVER_RESOURCE_COMPUTE_PIPELINE: {
|
case DRIVER_RESOURCE_COMPUTE_PIPELINE: {
|
||||||
ComputePipeline *compute_pipeline = compute_pipeline_owner.get_or_null(p_rid);
|
ComputePipeline *compute_pipeline = compute_pipeline_owner.get_or_null(p_rid);
|
||||||
ERR_FAIL_NULL_V(compute_pipeline, 0);
|
ERR_FAIL_NULL_V(compute_pipeline, 0);
|
||||||
|
|
||||||
driver_id = compute_pipeline->driver_id;
|
driver_id = compute_pipeline->driver_id.id;
|
||||||
} break;
|
} break;
|
||||||
case DRIVER_RESOURCE_RENDER_PIPELINE: {
|
case DRIVER_RESOURCE_RENDER_PIPELINE: {
|
||||||
RenderPipeline *render_pipeline = render_pipeline_owner.get_or_null(p_rid);
|
RenderPipeline *render_pipeline = render_pipeline_owner.get_or_null(p_rid);
|
||||||
ERR_FAIL_NULL_V(render_pipeline, 0);
|
ERR_FAIL_NULL_V(render_pipeline, 0);
|
||||||
|
|
||||||
driver_id = render_pipeline->driver_id;
|
driver_id = render_pipeline->driver_id.id;
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
ERR_FAIL_V(0);
|
ERR_FAIL_V(0);
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ public:
|
|||||||
|
|
||||||
#define DEFINE_ID(m_name) \
|
#define DEFINE_ID(m_name) \
|
||||||
struct m_name##ID : public ID { \
|
struct m_name##ID : public ID { \
|
||||||
_ALWAYS_INLINE_ operator bool() const { return id != 0; } \
|
_ALWAYS_INLINE_ explicit operator bool() const { return id != 0; } \
|
||||||
_ALWAYS_INLINE_ m_name##ID &operator=(m_name##ID p_other) { \
|
_ALWAYS_INLINE_ m_name##ID &operator=(m_name##ID p_other) { \
|
||||||
id = p_other.id; \
|
id = p_other.id; \
|
||||||
return *this; \
|
return *this; \
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ void RenderingDeviceGraph::_add_command_to_graph(ResourceTracker **p_resource_tr
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (resource_tracker->parent->usage == RESOURCE_USAGE_NONE) {
|
if (resource_tracker->parent->usage == RESOURCE_USAGE_NONE) {
|
||||||
if (resource_tracker->parent->texture_driver_id != 0) {
|
if (resource_tracker->parent->texture_driver_id.id != 0) {
|
||||||
// If the resource is a texture, we transition it entirely to the layout determined by the first slice that uses it.
|
// If the resource is a texture, we transition it entirely to the layout determined by the first slice that uses it.
|
||||||
_add_texture_barrier_to_command(resource_tracker->parent->texture_driver_id, RDD::BarrierAccessBits(0), new_usage_access, RDG::RESOURCE_USAGE_NONE, new_resource_usage, resource_tracker->parent->texture_subresources, command_normalization_barriers, r_command->normalization_barrier_index, r_command->normalization_barrier_count);
|
_add_texture_barrier_to_command(resource_tracker->parent->texture_driver_id, RDD::BarrierAccessBits(0), new_usage_access, RDG::RESOURCE_USAGE_NONE, new_resource_usage, resource_tracker->parent->texture_subresources, command_normalization_barriers, r_command->normalization_barrier_index, r_command->normalization_barrier_count);
|
||||||
}
|
}
|
||||||
@@ -324,7 +324,7 @@ void RenderingDeviceGraph::_add_command_to_graph(ResourceTracker **p_resource_tr
|
|||||||
ERR_FAIL_MSG("Texture slices that overlap can't be used in the same command.");
|
ERR_FAIL_MSG("Texture slices that overlap can't be used in the same command.");
|
||||||
} else {
|
} else {
|
||||||
// Delete the slice from the dirty list and revert it to the usage of the parent.
|
// Delete the slice from the dirty list and revert it to the usage of the parent.
|
||||||
if (current_tracker->texture_driver_id != 0) {
|
if (current_tracker->texture_driver_id.id != 0) {
|
||||||
_add_texture_barrier_to_command(current_tracker->texture_driver_id, current_tracker->usage_access, new_usage_access, current_tracker->usage, resource_tracker->parent->usage, current_tracker->texture_subresources, command_normalization_barriers, r_command->normalization_barrier_index, r_command->normalization_barrier_count);
|
_add_texture_barrier_to_command(current_tracker->texture_driver_id, current_tracker->usage_access, new_usage_access, current_tracker->usage, resource_tracker->parent->usage, current_tracker->texture_subresources, command_normalization_barriers, r_command->normalization_barrier_index, r_command->normalization_barrier_count);
|
||||||
|
|
||||||
// Merge the area of the slice with the current tracking area of the command and indicate it's a write usage as well.
|
// Merge the area of the slice with the current tracking area of the command and indicate it's a write usage as well.
|
||||||
@@ -383,7 +383,7 @@ void RenderingDeviceGraph::_add_command_to_graph(ResourceTracker **p_resource_tr
|
|||||||
while (current_tracker != nullptr) {
|
while (current_tracker != nullptr) {
|
||||||
current_tracker->reset_if_outdated(tracking_frame);
|
current_tracker->reset_if_outdated(tracking_frame);
|
||||||
|
|
||||||
if (current_tracker->texture_driver_id != 0) {
|
if (current_tracker->texture_driver_id.id != 0) {
|
||||||
// Transition all slices to the layout of the parent resource.
|
// Transition all slices to the layout of the parent resource.
|
||||||
_add_texture_barrier_to_command(current_tracker->texture_driver_id, current_tracker->usage_access, new_usage_access, current_tracker->usage, resource_tracker->usage, current_tracker->texture_subresources, command_normalization_barriers, r_command->normalization_barrier_index, r_command->normalization_barrier_count);
|
_add_texture_barrier_to_command(current_tracker->texture_driver_id, current_tracker->usage_access, new_usage_access, current_tracker->usage, resource_tracker->usage, current_tracker->texture_subresources, command_normalization_barriers, r_command->normalization_barrier_index, r_command->normalization_barrier_count);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user