Implement vkCmdBeginRenderPass

This commit is contained in:
msiglreith 2018-01-12 13:24:01 +01:00
parent 8840b74646
commit 225764fc2d
3 changed files with 53 additions and 10 deletions

View file

@ -1,4 +1,4 @@
use hal::{adapter, buffer, format, image, memory, pass, pso, window}; use hal::{adapter, buffer, command, format, image, memory, pass, pso, window};
use std::mem; use std::mem;
@ -430,3 +430,13 @@ pub fn map_image_acces(access: VkAccessFlags) -> image::Access {
mask mask
} }
pub fn map_subpass_contents(contents: VkSubpassContents) -> command::SubpassContents {
match contents {
VkSubpassContents::VK_SUBPASS_CONTENTS_INLINE => command::SubpassContents::Inline,
VkSubpassContents::VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS =>
command::SubpassContents::SecondaryBuffers,
_ => panic!("Unexpected subpass contents: {:?}", contents),
}
}

View file

@ -5,7 +5,7 @@ use hal::{
}; };
use hal::device::WaitFor; use hal::device::WaitFor;
use hal::pool::RawCommandPool; use hal::pool::RawCommandPool;
use hal::command::RawCommandBuffer; use hal::command::{ClearValueRaw, RawCommandBuffer, Rect};
use hal::queue::RawCommandQueue; use hal::queue::RawCommandQueue;
use std::ffi::CString; use std::ffi::CString;
@ -1990,11 +1990,35 @@ pub extern "C" fn gfxCmdPushConstants(
} }
#[inline] #[inline]
pub extern "C" fn gfxCmdBeginRenderPass( pub extern "C" fn gfxCmdBeginRenderPass(
commandBuffer: VkCommandBuffer, mut commandBuffer: VkCommandBuffer,
pRenderPassBegin: *const VkRenderPassBeginInfo, pRenderPassBegin: *const VkRenderPassBeginInfo,
contents: VkSubpassContents, contents: VkSubpassContents,
) { ) {
unimplemented!() let info = unsafe { &*pRenderPassBegin };
let render_area = Rect {
x: info.renderArea.offset.x as _,
y: info.renderArea.offset.y as _,
w: info.renderArea.extent.width as _,
h: info.renderArea.extent.height as _,
};
let clear_values = unsafe {
slice::from_raw_parts(info.pClearValues, info.clearValueCount as _)
.into_iter()
.map(|cv| {
// HAL and Vulkan clear value union sharing same memory representation
mem::transmute::<_, ClearValueRaw>(*cv)
})
};
let contents = conv::map_subpass_contents(contents);
commandBuffer.begin_renderpass_raw(
&*info.renderPass,
&*info.framebuffer,
render_area,
clear_values,
contents,
);
} }
#[inline] #[inline]
pub extern "C" fn gfxCmdNextSubpass(commandBuffer: VkCommandBuffer, contents: VkSubpassContents) { pub extern "C" fn gfxCmdNextSubpass(commandBuffer: VkCommandBuffer, contents: VkSubpassContents) {

View file

@ -1290,7 +1290,16 @@ pub extern "C" fn vkCmdCopyQueryPoolResults(
stride: VkDeviceSize, stride: VkDeviceSize,
flags: VkQueryResultFlags, flags: VkQueryResultFlags,
) { ) {
unimplemented!() gfxCmdCopyQueryPoolResults(
commandBuffer,
queryPool,
firstQuery,
queryCount,
dstBuffer,
dstOffset,
stride,
flags,
)
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn vkCmdPushConstants( pub extern "C" fn vkCmdPushConstants(
@ -1301,7 +1310,7 @@ pub extern "C" fn vkCmdPushConstants(
size: u32, size: u32,
pValues: *const ::std::os::raw::c_void, pValues: *const ::std::os::raw::c_void,
) { ) {
unimplemented!() gfxCmdPushConstants(commandBuffer, layout, stageFlags, offset, size, pValues)
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn vkCmdBeginRenderPass( pub extern "C" fn vkCmdBeginRenderPass(
@ -1309,15 +1318,15 @@ pub extern "C" fn vkCmdBeginRenderPass(
pRenderPassBegin: *const VkRenderPassBeginInfo, pRenderPassBegin: *const VkRenderPassBeginInfo,
contents: VkSubpassContents, contents: VkSubpassContents,
) { ) {
unimplemented!() gfxCmdBeginRenderPass(commandBuffer, pRenderPassBegin, contents)
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn vkCmdNextSubpass(commandBuffer: VkCommandBuffer, contents: VkSubpassContents) { pub extern "C" fn vkCmdNextSubpass(commandBuffer: VkCommandBuffer, contents: VkSubpassContents) {
unimplemented!() gfxCmdNextSubpass(commandBuffer, contents)
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn vkCmdEndRenderPass(commandBuffer: VkCommandBuffer) { pub extern "C" fn vkCmdEndRenderPass(commandBuffer: VkCommandBuffer) {
unimplemented!() gfxCmdEndRenderPass(commandBuffer)
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn vkCmdExecuteCommands( pub extern "C" fn vkCmdExecuteCommands(
@ -1325,7 +1334,7 @@ pub extern "C" fn vkCmdExecuteCommands(
commandBufferCount: u32, commandBufferCount: u32,
pCommandBuffers: *const VkCommandBuffer, pCommandBuffers: *const VkCommandBuffer,
) { ) {
unimplemented!() gfxCmdExecuteCommands(commandBuffer, commandBufferCount, pCommandBuffers)
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn vkAcquireNextImageKHR( pub extern "C" fn vkAcquireNextImageKHR(