mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-26 08:51:31 +11:00
Implement vkCmdSetViewports, gfxCmdBindPipeline, gfxCmdSetScissor, gfxCmdBindDescriptorSets, gfxCmdDraw, gfxQueuePresentKhr and fix graphics pipeline creation
This commit is contained in:
parent
ea0714cf39
commit
31aa84a06e
|
@ -346,7 +346,7 @@ pub fn map_stage_flags(stages: VkShaderStageFlags) -> pso::ShaderStageFlags {
|
||||||
pub fn map_pipeline_stage_flags(stages: VkPipelineStageFlags) -> pso::PipelineStage {
|
pub fn map_pipeline_stage_flags(stages: VkPipelineStageFlags) -> pso::PipelineStage {
|
||||||
let max_flag = VkPipelineStageFlagBits::VK_PIPELINE_STAGE_HOST_BIT as u32;
|
let max_flag = VkPipelineStageFlagBits::VK_PIPELINE_STAGE_HOST_BIT as u32;
|
||||||
|
|
||||||
if (stages & 1 << (max_flag + 1) - 1) == 0 {
|
if (stages & !((max_flag << 1) - 1)) == 0 {
|
||||||
// HAL flags have the same numeric representation as Vulkan flags
|
// HAL flags have the same numeric representation as Vulkan flags
|
||||||
unsafe { mem::transmute(stages) }
|
unsafe { mem::transmute(stages) }
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -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::{ClearValueRaw, RawCommandBuffer, Rect};
|
use hal::command::{ClearValueRaw, RawCommandBuffer, Rect, Viewport};
|
||||||
use hal::queue::RawCommandQueue;
|
use hal::queue::RawCommandQueue;
|
||||||
|
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
|
@ -919,7 +919,10 @@ pub extern "C" fn gfxCreatePipelineCache(
|
||||||
pAllocator: *const VkAllocationCallbacks,
|
pAllocator: *const VkAllocationCallbacks,
|
||||||
pPipelineCache: *mut VkPipelineCache,
|
pPipelineCache: *mut VkPipelineCache,
|
||||||
) -> VkResult {
|
) -> VkResult {
|
||||||
unimplemented!()
|
// unimplemented!()
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
VkResult::VK_SUCCESS
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxDestroyPipelineCache(
|
pub extern "C" fn gfxDestroyPipelineCache(
|
||||||
|
@ -1275,15 +1278,16 @@ pub extern "C" fn gfxCreateGraphicsPipelines(
|
||||||
|
|
||||||
let pipelines = gpu.device.create_graphics_pipelines(&descs);
|
let pipelines = gpu.device.create_graphics_pipelines(&descs);
|
||||||
|
|
||||||
unsafe {
|
let pipelines = unsafe {
|
||||||
slice::from_raw_parts_mut(pPipelines, descs.len())
|
slice::from_raw_parts_mut(pPipelines, descs.len())
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.zip(pipelines.into_iter())
|
.zip(pipelines.into_iter())
|
||||||
.map(|(pipeline, raw)| {
|
};
|
||||||
|
|
||||||
|
for (pipeline, raw) in pipelines {
|
||||||
if let Ok(raw) = raw {
|
if let Ok(raw) = raw {
|
||||||
*pipeline = Handle::new(Pipeline::Graphics(raw));
|
*pipeline = Handle::new(Pipeline::Graphics(raw));
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult::VK_SUCCESS
|
VkResult::VK_SUCCESS
|
||||||
|
@ -1930,29 +1934,65 @@ pub extern "C" fn gfxResetCommandBuffer(
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxCmdBindPipeline(
|
pub extern "C" fn gfxCmdBindPipeline(
|
||||||
commandBuffer: VkCommandBuffer,
|
mut commandBuffer: VkCommandBuffer,
|
||||||
pipelineBindPoint: VkPipelineBindPoint,
|
_pipelineBindPoint: VkPipelineBindPoint, // ignore, needs to match by spec
|
||||||
pipeline: VkPipeline,
|
pipeline: VkPipeline,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
match *pipeline {
|
||||||
|
Pipeline::Graphics(ref pipeline) => commandBuffer.bind_graphics_pipeline(pipeline),
|
||||||
|
Pipeline::Compute(ref pipeline) => commandBuffer.bind_compute_pipeline(pipeline),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxCmdSetViewport(
|
pub extern "C" fn gfxCmdSetViewport(
|
||||||
commandBuffer: VkCommandBuffer,
|
mut commandBuffer: VkCommandBuffer,
|
||||||
firstViewport: u32,
|
firstViewport: u32,
|
||||||
viewportCount: u32,
|
viewportCount: u32,
|
||||||
pViewports: *const VkViewport,
|
pViewports: *const VkViewport,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
assert_eq!(firstViewport, 0); // TODO
|
||||||
|
|
||||||
|
let viewports = unsafe {
|
||||||
|
slice::from_raw_parts(pViewports, viewportCount as _)
|
||||||
|
.into_iter()
|
||||||
|
.map(|viewport| {
|
||||||
|
Viewport {
|
||||||
|
rect: Rect {
|
||||||
|
x: viewport.x as _,
|
||||||
|
y: viewport.y as _,
|
||||||
|
w: viewport.width as _,
|
||||||
|
h: viewport.height as _,
|
||||||
|
},
|
||||||
|
depth: viewport.minDepth .. viewport.maxDepth,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
commandBuffer.set_viewports(viewports);
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxCmdSetScissor(
|
pub extern "C" fn gfxCmdSetScissor(
|
||||||
commandBuffer: VkCommandBuffer,
|
mut commandBuffer: VkCommandBuffer,
|
||||||
firstScissor: u32,
|
firstScissor: u32,
|
||||||
scissorCount: u32,
|
scissorCount: u32,
|
||||||
pScissors: *const VkRect2D,
|
pScissors: *const VkRect2D,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
assert_eq!(firstScissor, 0); // TODO
|
||||||
|
|
||||||
|
let scissors = unsafe {
|
||||||
|
slice::from_raw_parts(pScissors, scissorCount as _)
|
||||||
|
.into_iter()
|
||||||
|
.map(|scissor| {
|
||||||
|
Rect {
|
||||||
|
x: scissor.offset.x as _,
|
||||||
|
y: scissor.offset.y as _,
|
||||||
|
w: scissor.extent.width as _,
|
||||||
|
h: scissor.extent.height as _,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
commandBuffer.set_scissors(scissors);
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxCmdSetLineWidth(commandBuffer: VkCommandBuffer, lineWidth: f32) {
|
pub extern "C" fn gfxCmdSetLineWidth(commandBuffer: VkCommandBuffer, lineWidth: f32) {
|
||||||
|
@ -2008,7 +2048,7 @@ pub extern "C" fn gfxCmdSetStencilReference(
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxCmdBindDescriptorSets(
|
pub extern "C" fn gfxCmdBindDescriptorSets(
|
||||||
commandBuffer: VkCommandBuffer,
|
mut commandBuffer: VkCommandBuffer,
|
||||||
pipelineBindPoint: VkPipelineBindPoint,
|
pipelineBindPoint: VkPipelineBindPoint,
|
||||||
layout: VkPipelineLayout,
|
layout: VkPipelineLayout,
|
||||||
firstSet: u32,
|
firstSet: u32,
|
||||||
|
@ -2017,7 +2057,31 @@ pub extern "C" fn gfxCmdBindDescriptorSets(
|
||||||
dynamicOffsetCount: u32,
|
dynamicOffsetCount: u32,
|
||||||
pDynamicOffsets: *const u32,
|
pDynamicOffsets: *const u32,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
assert_eq!(dynamicOffsetCount, 0); // TODO
|
||||||
|
|
||||||
|
let descriptor_sets = unsafe {
|
||||||
|
slice::from_raw_parts(pDescriptorSets, descriptorSetCount as _)
|
||||||
|
.into_iter()
|
||||||
|
.map(|set| set.deref())
|
||||||
|
};
|
||||||
|
|
||||||
|
match pipelineBindPoint {
|
||||||
|
VkPipelineBindPoint::VK_PIPELINE_BIND_POINT_GRAPHICS => {
|
||||||
|
commandBuffer.bind_graphics_descriptor_sets(
|
||||||
|
layout.deref(),
|
||||||
|
firstSet as _,
|
||||||
|
descriptor_sets,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
VkPipelineBindPoint::VK_PIPELINE_BIND_POINT_COMPUTE => {
|
||||||
|
commandBuffer.bind_compute_descriptor_sets(
|
||||||
|
layout.deref(),
|
||||||
|
firstSet as _,
|
||||||
|
descriptor_sets,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_ => panic!("Unexpected pipeline bind point: {:?}", pipelineBindPoint),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxCmdBindIndexBuffer(
|
pub extern "C" fn gfxCmdBindIndexBuffer(
|
||||||
|
@ -2063,13 +2127,16 @@ pub extern "C" fn gfxCmdBindVertexBuffers(
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxCmdDraw(
|
pub extern "C" fn gfxCmdDraw(
|
||||||
commandBuffer: VkCommandBuffer,
|
mut commandBuffer: VkCommandBuffer,
|
||||||
vertexCount: u32,
|
vertexCount: u32,
|
||||||
instanceCount: u32,
|
instanceCount: u32,
|
||||||
firstVertex: u32,
|
firstVertex: u32,
|
||||||
firstInstance: u32,
|
firstInstance: u32,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
commandBuffer.draw(
|
||||||
|
firstVertex .. firstVertex + vertexCount,
|
||||||
|
firstInstance .. firstInstance + instanceCount,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxCmdDrawIndexed(
|
pub extern "C" fn gfxCmdDrawIndexed(
|
||||||
|
@ -2784,8 +2851,23 @@ pub extern "C" fn gfxAcquireNextImageKHR(
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxQueuePresentKHR(
|
pub extern "C" fn gfxQueuePresentKHR(
|
||||||
queue: VkQueue,
|
mut queue: VkQueue,
|
||||||
pPresentInfo: *const VkPresentInfoKHR,
|
pPresentInfo: *const VkPresentInfoKHR,
|
||||||
) -> VkResult {
|
) -> VkResult {
|
||||||
unimplemented!()
|
let info = unsafe { &*pPresentInfo };
|
||||||
|
|
||||||
|
let swapchains = unsafe {
|
||||||
|
slice::from_raw_parts_mut(info.pSwapchains as *mut VkSwapchainKHR, info.swapchainCount as _)
|
||||||
|
.into_iter()
|
||||||
|
.map(|swapchain| &mut swapchain.raw)
|
||||||
|
};
|
||||||
|
let wait_semaphores = unsafe {
|
||||||
|
slice::from_raw_parts(info.pWaitSemaphores, info.waitSemaphoreCount as _)
|
||||||
|
.into_iter()
|
||||||
|
.map(|semaphore| semaphore.deref())
|
||||||
|
};
|
||||||
|
|
||||||
|
queue.present(swapchains, wait_semaphores);
|
||||||
|
|
||||||
|
VkResult::VK_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
|
@ -906,7 +906,7 @@ pub extern "C" fn vkResetCommandBuffer(
|
||||||
commandBuffer: VkCommandBuffer,
|
commandBuffer: VkCommandBuffer,
|
||||||
flags: VkCommandBufferResetFlags,
|
flags: VkCommandBufferResetFlags,
|
||||||
) -> VkResult {
|
) -> VkResult {
|
||||||
unimplemented!()
|
gfxResetCommandBuffer(commandBuffer, flags)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkCmdBindPipeline(
|
pub extern "C" fn vkCmdBindPipeline(
|
||||||
|
@ -914,7 +914,7 @@ pub extern "C" fn vkCmdBindPipeline(
|
||||||
pipelineBindPoint: VkPipelineBindPoint,
|
pipelineBindPoint: VkPipelineBindPoint,
|
||||||
pipeline: VkPipeline,
|
pipeline: VkPipeline,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
gfxCmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkCmdSetViewport(
|
pub extern "C" fn vkCmdSetViewport(
|
||||||
|
@ -923,7 +923,7 @@ pub extern "C" fn vkCmdSetViewport(
|
||||||
viewportCount: u32,
|
viewportCount: u32,
|
||||||
pViewports: *const VkViewport,
|
pViewports: *const VkViewport,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
gfxCmdSetViewport(commandBuffer, firstViewport, viewportCount, pViewports)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkCmdSetScissor(
|
pub extern "C" fn vkCmdSetScissor(
|
||||||
|
@ -932,11 +932,11 @@ pub extern "C" fn vkCmdSetScissor(
|
||||||
scissorCount: u32,
|
scissorCount: u32,
|
||||||
pScissors: *const VkRect2D,
|
pScissors: *const VkRect2D,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
gfxCmdSetScissor(commandBuffer, firstScissor, scissorCount, pScissors)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkCmdSetLineWidth(commandBuffer: VkCommandBuffer, lineWidth: f32) {
|
pub extern "C" fn vkCmdSetLineWidth(commandBuffer: VkCommandBuffer, lineWidth: f32) {
|
||||||
unimplemented!()
|
gfxCmdSetLineWidth(commandBuffer, lineWidth)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkCmdSetDepthBias(
|
pub extern "C" fn vkCmdSetDepthBias(
|
||||||
|
@ -945,14 +945,19 @@ pub extern "C" fn vkCmdSetDepthBias(
|
||||||
depthBiasClamp: f32,
|
depthBiasClamp: f32,
|
||||||
depthBiasSlopeFactor: f32,
|
depthBiasSlopeFactor: f32,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
gfxCmdSetDepthBias(
|
||||||
|
commandBuffer,
|
||||||
|
depthBiasConstantFactor,
|
||||||
|
depthBiasClamp,
|
||||||
|
depthBiasSlopeFactor,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkCmdSetBlendConstants(
|
pub extern "C" fn vkCmdSetBlendConstants(
|
||||||
commandBuffer: VkCommandBuffer,
|
commandBuffer: VkCommandBuffer,
|
||||||
blendConstants: *const f32,
|
blendConstants: *const f32,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
gfxCmdSetBlendConstants(commandBuffer, blendConstants)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkCmdSetDepthBounds(
|
pub extern "C" fn vkCmdSetDepthBounds(
|
||||||
|
@ -960,7 +965,7 @@ pub extern "C" fn vkCmdSetDepthBounds(
|
||||||
minDepthBounds: f32,
|
minDepthBounds: f32,
|
||||||
maxDepthBounds: f32,
|
maxDepthBounds: f32,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
gfxCmdSetDepthBounds(commandBuffer, minDepthBounds, maxDepthBounds)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkCmdSetStencilCompareMask(
|
pub extern "C" fn vkCmdSetStencilCompareMask(
|
||||||
|
@ -968,7 +973,7 @@ pub extern "C" fn vkCmdSetStencilCompareMask(
|
||||||
faceMask: VkStencilFaceFlags,
|
faceMask: VkStencilFaceFlags,
|
||||||
compareMask: u32,
|
compareMask: u32,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
gfxCmdSetStencilCompareMask(commandBuffer, faceMask, compareMask)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkCmdSetStencilWriteMask(
|
pub extern "C" fn vkCmdSetStencilWriteMask(
|
||||||
|
@ -997,7 +1002,16 @@ pub extern "C" fn vkCmdBindDescriptorSets(
|
||||||
dynamicOffsetCount: u32,
|
dynamicOffsetCount: u32,
|
||||||
pDynamicOffsets: *const u32,
|
pDynamicOffsets: *const u32,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
gfxCmdBindDescriptorSets(
|
||||||
|
commandBuffer,
|
||||||
|
pipelineBindPoint,
|
||||||
|
layout,
|
||||||
|
firstSet,
|
||||||
|
descriptorSetCount,
|
||||||
|
pDescriptorSets,
|
||||||
|
dynamicOffsetCount,
|
||||||
|
pDynamicOffsets,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkCmdBindIndexBuffer(
|
pub extern "C" fn vkCmdBindIndexBuffer(
|
||||||
|
@ -1006,7 +1020,7 @@ pub extern "C" fn vkCmdBindIndexBuffer(
|
||||||
offset: VkDeviceSize,
|
offset: VkDeviceSize,
|
||||||
indexType: VkIndexType,
|
indexType: VkIndexType,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
gfxCmdBindIndexBuffer(commandBuffer, buffer, offset, indexType)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkCmdBindVertexBuffers(
|
pub extern "C" fn vkCmdBindVertexBuffers(
|
||||||
|
@ -1032,7 +1046,7 @@ pub extern "C" fn vkCmdDraw(
|
||||||
firstVertex: u32,
|
firstVertex: u32,
|
||||||
firstInstance: u32,
|
firstInstance: u32,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
gfxCmdDraw(commandBuffer, vertexCount, instanceCount, firstVertex, firstInstance)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkCmdDrawIndexed(
|
pub extern "C" fn vkCmdDrawIndexed(
|
||||||
|
@ -1043,7 +1057,14 @@ pub extern "C" fn vkCmdDrawIndexed(
|
||||||
vertexOffset: i32,
|
vertexOffset: i32,
|
||||||
firstInstance: u32,
|
firstInstance: u32,
|
||||||
) {
|
) {
|
||||||
unimplemented!()
|
gfxCmdDrawIndexed(
|
||||||
|
commandBuffer,
|
||||||
|
indexCount,
|
||||||
|
instanceCount,
|
||||||
|
firstIndex,
|
||||||
|
vertexOffset,
|
||||||
|
firstInstance,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkCmdDrawIndirect(
|
pub extern "C" fn vkCmdDrawIndirect(
|
||||||
|
@ -1365,7 +1386,7 @@ pub extern "C" fn vkQueuePresentKHR(
|
||||||
queue: VkQueue,
|
queue: VkQueue,
|
||||||
pPresentInfo: *const VkPresentInfoKHR,
|
pPresentInfo: *const VkPresentInfoKHR,
|
||||||
) -> VkResult {
|
) -> VkResult {
|
||||||
unimplemented!()
|
gfxQueuePresentKHR(queue, pPresentInfo)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkEnumerateInstanceExtensionProperties(
|
pub extern "C" fn vkEnumerateInstanceExtensionProperties(
|
||||||
|
|
Loading…
Reference in a new issue