fix depth buffer
This commit is contained in:
parent
0c8aaa4b8c
commit
194149f8dd
Binary file not shown.
@ -294,13 +294,11 @@ Cycle(Game* g)
|
|||||||
model = model.next;
|
model = model.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
ImageBarrier(&g.rd);
|
ImageBarrier(&g.rd);
|
||||||
|
|
||||||
Bind(&g.rd, &g.oit_pipeline);
|
Bind(&g.rd, &g.oit_pipeline);
|
||||||
|
|
||||||
Draw(&g.rd, 3, 1);
|
Draw(&g.rd, 3, 1);
|
||||||
*/
|
|
||||||
|
|
||||||
FinishRendering(&g.rd);
|
FinishRendering(&g.rd);
|
||||||
|
|
||||||
@ -337,17 +335,12 @@ Destroy(Game* g)
|
|||||||
Destroy(&g.rd, &g.ui_pipeline);
|
Destroy(&g.rd, &g.ui_pipeline);
|
||||||
Destroy(&g.rd, &g.compute_pipeline);
|
Destroy(&g.rd, &g.compute_pipeline);
|
||||||
|
|
||||||
Node!(Model)* model = g.models.first;
|
Destroy(&g.rd, &g.rock);
|
||||||
for(;;)
|
Destroy(&g.rd, &g.tree);
|
||||||
{
|
Destroy(&g.rd, &g.magic_rock);
|
||||||
if (model == null)
|
Destroy(&g.rd, &g.log);
|
||||||
{
|
Destroy(&g.rd, &g.stump);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Destroy(&g.rd, &model.value);
|
|
||||||
model = model.next;
|
|
||||||
}
|
|
||||||
Destroy(&g.rd);
|
Destroy(&g.rd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -225,39 +225,45 @@ CreateWindow(string name, u16 width, u16 height)
|
|||||||
void
|
void
|
||||||
LockCursor(PlatformWindow* window)
|
LockCursor(PlatformWindow* window)
|
||||||
{
|
{
|
||||||
u32 counter = 0;
|
if (!window.locked_cursor)
|
||||||
for(;;)
|
|
||||||
{
|
{
|
||||||
xcb_generic_error_t *error;
|
u32 counter = 0;
|
||||||
xcb_grab_pointer_cookie_t grab_cookie = xcb_grab_pointer(window.conn, true, window.window, 0, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, window.window, XCB_NONE, XCB_CURRENT_TIME);
|
for(;;)
|
||||||
xcb_grab_pointer_reply_t* grab_reply = xcb_grab_pointer_reply(window.conn, grab_cookie, &error);
|
|
||||||
|
|
||||||
scope(exit)
|
|
||||||
{
|
{
|
||||||
pureFree(error);
|
xcb_generic_error_t *error;
|
||||||
pureFree(grab_reply);
|
xcb_grab_pointer_cookie_t grab_cookie = xcb_grab_pointer(window.conn, true, window.window, 0, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, window.window, XCB_NONE, XCB_CURRENT_TIME);
|
||||||
|
xcb_grab_pointer_reply_t* grab_reply = xcb_grab_pointer_reply(window.conn, grab_cookie, &error);
|
||||||
|
|
||||||
|
scope(exit)
|
||||||
|
{
|
||||||
|
pureFree(error);
|
||||||
|
pureFree(grab_reply);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (grab_reply.status == XCB_GRAB_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(counter < 5, "Unable to grab cursor");
|
||||||
|
counter += 1;
|
||||||
|
Thread.sleep(dur!("msecs")(50));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grab_reply.status == XCB_GRAB_STATUS_SUCCESS)
|
HideCursor(window);
|
||||||
{
|
window.locked_cursor = true;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(counter < 5, "Unable to grab cursor");
|
|
||||||
counter += 1;
|
|
||||||
Thread.sleep(dur!("msecs")(50));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HideCursor(window);
|
|
||||||
window.locked_cursor = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UnlockCursor(PlatformWindow* window)
|
UnlockCursor(PlatformWindow* window)
|
||||||
{
|
{
|
||||||
xcb_ungrab_pointer(window.conn, XCB_CURRENT_TIME);
|
if (window.locked_cursor)
|
||||||
ShowCursor(window);
|
{
|
||||||
window.locked_cursor = false;
|
xcb_ungrab_pointer(window.conn, XCB_CURRENT_TIME);
|
||||||
|
ShowCursor(window);
|
||||||
|
window.locked_cursor = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: improve error handling for show/hide cursor
|
// TODO: improve error handling for show/hide cursor
|
||||||
|
|||||||
@ -677,11 +677,18 @@ BeginRendering(Vulkan* vk)
|
|||||||
VkImage image = CurrentImage(vk);
|
VkImage image = CurrentImage(vk);
|
||||||
Transition(vk.cmds[vk.frame_index], image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
Transition(vk.cmds[vk.frame_index], image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||||
|
|
||||||
VkClearValue clear_color = {
|
VkClearValue[] clear_color = [
|
||||||
color: {
|
{
|
||||||
float32: [0.0, 0.0, 0.0, 1.0],
|
color: {
|
||||||
|
float32: [0.0, 0.0, 0.0, 1.0],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
{
|
||||||
|
color: {
|
||||||
|
float32: [0.0, 0.0, 0.0, 0.0],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
VkRenderPassBeginInfo pass_info = {
|
VkRenderPassBeginInfo pass_info = {
|
||||||
sType: VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
|
sType: VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
|
||||||
@ -697,8 +704,8 @@ BeginRendering(Vulkan* vk)
|
|||||||
height: vk.swapchain_extent.height,
|
height: vk.swapchain_extent.height,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
clearValueCount: 1,
|
clearValueCount: cast(u32)clear_color.length,
|
||||||
pClearValues: &clear_color,
|
pClearValues: clear_color.ptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
vkCmdBeginRenderPass(vk.cmds[vk.frame_index], &pass_info, VK_SUBPASS_CONTENTS_INLINE);
|
vkCmdBeginRenderPass(vk.cmds[vk.frame_index], &pass_info, VK_SUBPASS_CONTENTS_INLINE);
|
||||||
@ -1173,10 +1180,10 @@ ImageBarrier(Vulkan* vk)
|
|||||||
{
|
{
|
||||||
VkMemoryBarrier2 barrier = {
|
VkMemoryBarrier2 barrier = {
|
||||||
sType: VK_STRUCTURE_TYPE_MEMORY_BARRIER_2,
|
sType: VK_STRUCTURE_TYPE_MEMORY_BARRIER_2,
|
||||||
srcStageMask: VK_PIPELINE_STAGE_2_TRANSFER_BIT,
|
srcStageMask: VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
srcAccessMask: VK_ACCESS_2_TRANSFER_WRITE_BIT,
|
srcAccessMask: VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
|
||||||
dstStageMask: VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT,
|
dstStageMask: VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
dstAccessMask: VK_ACCESS_2_SHADER_READ_BIT | VK_ACCESS_2_SHADER_WRITE_BIT,
|
dstAccessMask: VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
|
||||||
};
|
};
|
||||||
|
|
||||||
VkDependencyInfo dependency = {
|
VkDependencyInfo dependency = {
|
||||||
@ -1492,8 +1499,10 @@ InitFramebufferAndRenderPass(Vulkan* vk)
|
|||||||
finalLayout: VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
finalLayout: VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
samples: VK_SAMPLE_COUNT_1_BIT,
|
|
||||||
format: vk.depth_image.format,
|
format: vk.depth_image.format,
|
||||||
|
samples: VK_SAMPLE_COUNT_1_BIT,
|
||||||
|
loadOp: VK_ATTACHMENT_LOAD_OP_CLEAR,
|
||||||
|
storeOp: VK_ATTACHMENT_STORE_OP_STORE,
|
||||||
initialLayout: VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
initialLayout: VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||||
finalLayout: VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
finalLayout: VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -61,7 +61,7 @@ void main()
|
|||||||
FragColor = out_col;
|
FragColor = out_col;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: set up OIT again
|
//TODO: set up OIT again
|
||||||
vec4 srgb_col = out_col;// UnPreMultLinearToSRGB(out_col);
|
vec4 srgb_col = out_col;// UnPreMultLinearToSRGB(out_col);
|
||||||
|
|
||||||
uvec4 store_value = uvec4(packUnorm4x8(srgb_col), floatBitsToUint(gl_FragCoord.z), store_mask, 0);
|
uvec4 store_value = uvec4(packUnorm4x8(srgb_col), floatBitsToUint(gl_FragCoord.z), store_mask, 0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user