mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-25 08:21:31 +11:00
Implement vkBindImageMemory and remaining parts of the depth buffer example
This commit is contained in:
parent
458568cad2
commit
7a3a11fafc
|
@ -317,12 +317,26 @@ extern "C" {
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern fn gfxBindImageMemory(
|
pub extern fn gfxBindImageMemory(
|
||||||
device: VkDevice,
|
gpu: VkDevice,
|
||||||
image: VkImage,
|
mut image: VkImage,
|
||||||
memory: VkDeviceMemory,
|
memory: VkDeviceMemory,
|
||||||
memoryOffset: VkDeviceSize,
|
memoryOffset: VkDeviceSize,
|
||||||
) -> VkResult {
|
) -> VkResult {
|
||||||
unimplemented!()
|
let new_img = match *image.unwrap() {
|
||||||
|
Image::Image(_) => panic!("An Image can only be bound once!"),
|
||||||
|
Image::Unbound(unbound) => {
|
||||||
|
gpu.device.bind_image_memory(
|
||||||
|
&memory,
|
||||||
|
memoryOffset,
|
||||||
|
unbound,
|
||||||
|
).unwrap() // TODO
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Replace the unbound image with an actual image under the hood.
|
||||||
|
*image = Image::Image(new_img);
|
||||||
|
|
||||||
|
VkResult::VK_SUCCESS
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn vkGetBufferMemoryRequirements(device: VkDevice, buffer: VkBuffer,
|
pub fn vkGetBufferMemoryRequirements(device: VkDevice, buffer: VkBuffer,
|
||||||
|
|
|
@ -268,26 +268,8 @@ int main() {
|
||||||
mem_alloc.allocationSize = 0;
|
mem_alloc.allocationSize = 0;
|
||||||
mem_alloc.memoryTypeIndex = 0;
|
mem_alloc.memoryTypeIndex = 0;
|
||||||
|
|
||||||
VkImageViewCreateInfo view_info = {};
|
|
||||||
view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
|
||||||
view_info.pNext = NULL;
|
|
||||||
view_info.image = VK_NULL_HANDLE;
|
|
||||||
view_info.format = depth_format;
|
|
||||||
view_info.components.r = VK_COMPONENT_SWIZZLE_R;
|
|
||||||
view_info.components.g = VK_COMPONENT_SWIZZLE_G;
|
|
||||||
view_info.components.b = VK_COMPONENT_SWIZZLE_B;
|
|
||||||
view_info.components.a = VK_COMPONENT_SWIZZLE_A;
|
|
||||||
view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
|
|
||||||
view_info.subresourceRange.baseMipLevel = 0;
|
|
||||||
view_info.subresourceRange.levelCount = 1;
|
|
||||||
view_info.subresourceRange.baseArrayLayer = 0;
|
|
||||||
view_info.subresourceRange.layerCount = 1;
|
|
||||||
view_info.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
|
||||||
view_info.flags = 0;
|
|
||||||
|
|
||||||
VkMemoryRequirements mem_reqs;
|
VkMemoryRequirements mem_reqs;
|
||||||
|
|
||||||
/* Create image */
|
|
||||||
VkImage depth_image = 0;
|
VkImage depth_image = 0;
|
||||||
res = vkCreateImage(device, &image_info, NULL, &depth_image);
|
res = vkCreateImage(device, &image_info, NULL, &depth_image);
|
||||||
printf("\tvkCreateImage: res=%d\n", res);
|
printf("\tvkCreateImage: res=%d\n", res);
|
||||||
|
@ -316,6 +298,32 @@ int main() {
|
||||||
printf("\tvkAllocateMemory: res=%d\n", res);
|
printf("\tvkAllocateMemory: res=%d\n", res);
|
||||||
assert(!res);
|
assert(!res);
|
||||||
|
|
||||||
|
res = vkBindImageMemory(device, depth_image, depth_memory, 0);
|
||||||
|
printf("\tvkBindImageMemory: res=%d\n", res);
|
||||||
|
assert(!res);
|
||||||
|
|
||||||
|
VkImageViewCreateInfo view_info = {};
|
||||||
|
view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||||
|
view_info.pNext = NULL;
|
||||||
|
view_info.image = depth_image;
|
||||||
|
view_info.format = depth_format;
|
||||||
|
view_info.components.r = VK_COMPONENT_SWIZZLE_R;
|
||||||
|
view_info.components.g = VK_COMPONENT_SWIZZLE_G;
|
||||||
|
view_info.components.b = VK_COMPONENT_SWIZZLE_B;
|
||||||
|
view_info.components.a = VK_COMPONENT_SWIZZLE_A;
|
||||||
|
view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||||
|
view_info.subresourceRange.baseMipLevel = 0;
|
||||||
|
view_info.subresourceRange.levelCount = 1;
|
||||||
|
view_info.subresourceRange.baseArrayLayer = 0;
|
||||||
|
view_info.subresourceRange.layerCount = 1;
|
||||||
|
view_info.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
||||||
|
view_info.flags = 0;
|
||||||
|
|
||||||
|
VkImageView depth_view = 0;
|
||||||
|
res = vkCreateImageView(device, &view_info, NULL, &depth_view);
|
||||||
|
printf("\tvkCreateImageView: res=%d\n", res);
|
||||||
|
assert(!res);
|
||||||
|
|
||||||
VkCommandPool cmd_pool = 0;
|
VkCommandPool cmd_pool = 0;
|
||||||
VkCommandPoolCreateInfo cmd_pool_info = {};
|
VkCommandPoolCreateInfo cmd_pool_info = {};
|
||||||
cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||||
|
|
Loading…
Reference in a new issue