Hyperspace.

This commit is contained in:
Artem Kharytoniuk 2017-05-21 23:22:40 +03:00
parent 12368a634f
commit 724dd15526
3 changed files with 33 additions and 30 deletions

View File

@ -375,16 +375,14 @@ A player has predicted a teleport, but hasn't arrived yet
================ ================
*/ */
static void RB_Hyperspace( void ) { static void RB_Hyperspace( void ) {
float c; float c = ( backEnd.refdef.time & 255 ) / 255.0f;
if ( !backEnd.isHyperspace ) {
// do initialization shit
}
c = ( backEnd.refdef.time & 255 ) / 255.0f;
qglClearColor( c, c, c, 1 ); qglClearColor( c, c, c, 1 );
qglClear( GL_COLOR_BUFFER_BIT ); qglClear( GL_COLOR_BUFFER_BIT );
// VULKAN
float color[4] = { c, c, c, 1 };
vk_clear_attachments(false, true, color);
backEnd.isHyperspace = qtrue; backEnd.isHyperspace = qtrue;
} }
@ -410,8 +408,6 @@ to actually render the visible surfaces for this view
================= =================
*/ */
void RB_BeginDrawingView (void) { void RB_BeginDrawingView (void) {
int clearBits = 0;
// we will need to change the projection matrix before drawing // we will need to change the projection matrix before drawing
// 2D images again // 2D images again
backEnd.projection2D = qfalse; backEnd.projection2D = qfalse;
@ -424,7 +420,7 @@ void RB_BeginDrawingView (void) {
// ensures that depth writes are enabled for the depth clear // ensures that depth writes are enabled for the depth clear
GL_State( GLS_DEFAULT ); GL_State( GLS_DEFAULT );
// clear relevant buffers // clear relevant buffers
clearBits = GL_DEPTH_BUFFER_BIT; int clearBits = GL_DEPTH_BUFFER_BIT;
bool clear_stencil = (r_shadows->integer == 2); bool clear_stencil = (r_shadows->integer == 2);
if ( clear_stencil ) if ( clear_stencil )
@ -442,7 +438,7 @@ void RB_BeginDrawingView (void) {
qglClear( clearBits ); qglClear( clearBits );
// VULKAN // VULKAN
vk_clear_attachments(clear_stencil, fast_sky); vk_clear_attachments(vk_resources.dirty_attachments, fast_sky, fast_sky_color);
if ( ( backEnd.refdef.rdflags & RDF_HYPERSPACE ) ) if ( ( backEnd.refdef.rdflags & RDF_HYPERSPACE ) )
{ {

View File

@ -1922,27 +1922,32 @@ VkPipeline vk_find_pipeline(const Vk_Pipeline_Def& def) {
return pipeline; return pipeline;
} }
void vk_clear_attachments(bool clear_stencil, bool fast_sky) { void vk_clear_attachments(bool clear_depth_stencil, bool clear_color, vec4_t color) {
if (!vk.active) if (!vk.active)
return; return;
if (!vk_resources.dirty_attachments && !fast_sky) if (!clear_depth_stencil && !clear_color)
return; return;
VkClearAttachment attachments[2]; VkClearAttachment attachments[2];
uint32_t attachment_count = fast_sky ? 2 : 1; uint32_t attachment_count = 0;
if (clear_depth_stencil) {
attachments[0].aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; attachments[0].aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
attachments[0].clearValue.depthStencil.depth = 1.0f; attachments[0].clearValue.depthStencil.depth = 1.0f;
if (clear_stencil) { if (r_shadows->integer == 2) {
attachments[0].aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT; attachments[0].aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
attachments[0].clearValue.depthStencil.stencil = 0; attachments[0].clearValue.depthStencil.stencil = 0;
} }
if (fast_sky) { attachment_count = 1;
attachments[1].aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; }
attachments[1].colorAttachment = 0;
attachments[1].clearValue.color = { fast_sky_color[0], fast_sky_color[1], fast_sky_color[2], fast_sky_color[3] }; if (clear_color) {
attachments[attachment_count].aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
attachments[attachment_count].colorAttachment = 0;
attachments[attachment_count].clearValue.color = { color[0], color[1], color[2], color[3] };
attachment_count++;
} }
VkClearRect clear_rect[2]; VkClearRect clear_rect[2];
@ -1956,7 +1961,9 @@ void vk_clear_attachments(bool clear_stencil, bool fast_sky) {
// "vkCmdClearAttachments() issued on command buffer object XXX prior to any Draw Cmds. // "vkCmdClearAttachments() issued on command buffer object XXX prior to any Draw Cmds.
// It is recommended you use RenderPass LOAD_OP_CLEAR on Attachments prior to any Draw." // It is recommended you use RenderPass LOAD_OP_CLEAR on Attachments prior to any Draw."
// //
if (fast_sky) { // NOTE: we don't use LOAD_OP_CLEAR for color attachment when we begin renderpass
// since at that point we don't know whether we need collor buffer clear (usually we don't).
if (clear_color) {
uint32_t h = clear_rect[0].rect.extent.height / 2; uint32_t h = clear_rect[0].rect.extent.height / 2;
clear_rect[0].rect.extent.height = h; clear_rect[0].rect.extent.height = h;
clear_rect[1] = clear_rect[0]; clear_rect[1] = clear_rect[0];

View File

@ -95,7 +95,7 @@ VkPipeline vk_find_pipeline(const Vk_Pipeline_Def& def);
// Rendering setup. // Rendering setup.
// //
VkRect2D vk_get_scissor_rect(); VkRect2D vk_get_scissor_rect();
void vk_clear_attachments(bool clear_stencil, bool fast_sky); void vk_clear_attachments(bool clear_depth_stencil, bool clear_color, vec4_t color);
void vk_bind_resources_shared_between_stages(); void vk_bind_resources_shared_between_stages();
void vk_bind_stage_specific_resources(VkPipeline pipeline, bool multitexture, Vk_Depth_Range depth_range); void vk_bind_stage_specific_resources(VkPipeline pipeline, bool multitexture, Vk_Depth_Range depth_range);
void vk_begin_frame(); void vk_begin_frame();