summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2019-07-12 16:18:30 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2020-02-11 11:57:34 +0100
commitb456bfad5cee3922f55621bf7c133cc67337636a (patch)
treed3c77c49894591ea67dac3ad1551e9f36206b9c1 /drivers
parenteb48be51dbe97aa4fbbbe0d0ebd8a98bee6b263e (diff)
Add runtime GLES2 / Vulkan context selection.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp17
-rw-r--r--drivers/vulkan/rendering_device_vulkan.h11
2 files changed, 25 insertions, 3 deletions
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp
index 4ca44283a3..77f4a294fa 100644
--- a/drivers/vulkan/rendering_device_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_vulkan.cpp
@@ -4905,7 +4905,9 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin_for_screen(in
VkCommandBuffer command_buffer = frames[frame].draw_command_buffer;
draw_list = memnew(DrawList);
draw_list->command_buffer = command_buffer;
+#ifdef DEBUG_ENABLED
draw_list->validation.framebuffer_format = screen_get_framebuffer_format();
+#endif
draw_list_count = 0;
draw_list_split = false;
@@ -5101,7 +5103,9 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebu
draw_list = memnew(DrawList);
draw_list->command_buffer = command_buffer;
+#ifdef DEBUG_ENABLED
draw_list->validation.framebuffer_format = framebuffer->format_id;
+#endif
draw_list_count = 0;
draw_list_split = false;
@@ -5246,7 +5250,9 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
}
draw_list[i].command_buffer = command_buffer;
+#ifdef DEBUG_ENABLED
draw_list[i].validation.framebuffer_format = framebuffer->format_id;
+#endif
VkViewport viewport;
viewport.x = viewport_offset.x;
@@ -5430,9 +5436,9 @@ void RenderingDeviceVulkan::draw_list_bind_vertex_array(DrawListID p_list, RID p
#ifdef DEBUG_ENABLED
dl->validation.vertex_format = vertex_array->description;
- dl->validation.vertex_array_size = vertex_array->vertex_count;
dl->validation.vertex_max_instances_allowed = vertex_array->max_instances_allowed;
#endif
+ dl->validation.vertex_array_size = vertex_array->vertex_count;
vkCmdBindVertexBuffers(dl->command_buffer, 0, vertex_array->buffers.size(), vertex_array->buffers.ptr(), vertex_array->offsets.ptr());
}
void RenderingDeviceVulkan::draw_list_bind_index_array(DrawListID p_list, RID p_index_array) {
@@ -5452,10 +5458,11 @@ void RenderingDeviceVulkan::draw_list_bind_index_array(DrawListID p_list, RID p_
dl->state.index_array = p_index_array;
#ifdef DEBUG_ENABLED
- dl->validation.index_array_size = index_array->indices;
dl->validation.index_array_max_index = index_array->max_index;
- dl->validation.index_array_offset = index_array->offset;
#endif
+ dl->validation.index_array_size = index_array->indices;
+ dl->validation.index_array_offset = index_array->offset;
+
vkCmdBindIndexBuffer(dl->command_buffer, index_array->buffer, index_array->offset, index_array->index_type);
}
@@ -5463,7 +5470,9 @@ void RenderingDeviceVulkan::draw_list_set_line_width(DrawListID p_list, float p_
DrawList *dl = _get_draw_list_ptr(p_list);
ERR_FAIL_COND(!dl);
+#ifdef DEBUG_ENABLED
ERR_FAIL_COND_MSG(!dl->validation.active, "Submitted Draw Lists can no longer be modified.");
+#endif
vkCmdSetLineWidth(dl->command_buffer, p_width);
}
@@ -5481,7 +5490,9 @@ void RenderingDeviceVulkan::draw_list_set_push_constant(DrawListID p_list, void
"This render pipeline requires (" + itos(dl->validation.pipeline_push_constant_size) + ") bytes of push constant data, supplied: (" + itos(p_data_size) + ")");
#endif
vkCmdPushConstants(dl->command_buffer, dl->state.pipeline_layout, dl->state.pipeline_push_constant_stages, 0, p_data_size, p_data);
+#ifdef DEBUG_ENABLED
dl->validation.pipeline_push_constant_suppplied = true;
+#endif
}
void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices, uint32_t p_instances) {
diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h
index 547734a6bb..690abeb0b3 100644
--- a/drivers/vulkan/rendering_device_vulkan.h
+++ b/drivers/vulkan/rendering_device_vulkan.h
@@ -767,6 +767,17 @@ class RenderingDeviceVulkan : public RenderingDevice {
pipeline_push_constant_suppplied = false;
}
} validation;
+#else
+ struct Validation {
+ uint32_t vertex_array_size; //0 if not set
+ uint32_t index_array_size; //0 if index buffer not set
+ uint32_t index_array_offset;
+
+ Validation() {
+ vertex_array_size = 0;
+ index_array_size = 0; //not sent
+ }
+ } validation;
#endif
};