mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-22 15:01:31 +11:00
Implement vkGetImageMemoryRequirements
This commit is contained in:
parent
468c42a3a2
commit
bc7a8107e6
|
@ -51,31 +51,31 @@ fn image_features_from_hal(features: format::ImageFeature) -> VkFormatFeatureFla
|
||||||
let mut flags = 0;
|
let mut flags = 0;
|
||||||
|
|
||||||
if features.contains(format::ImageFeature::SAMPLED) {
|
if features.contains(format::ImageFeature::SAMPLED) {
|
||||||
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT as _;
|
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT as u32;
|
||||||
}
|
}
|
||||||
if features.contains(format::ImageFeature::STORAGE) {
|
if features.contains(format::ImageFeature::STORAGE) {
|
||||||
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT as _;
|
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT as u32;
|
||||||
}
|
}
|
||||||
if features.contains(format::ImageFeature::STORAGE_ATOMIC) {
|
if features.contains(format::ImageFeature::STORAGE_ATOMIC) {
|
||||||
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT as _;
|
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT as u32;
|
||||||
}
|
}
|
||||||
if features.contains(format::ImageFeature::COLOR_ATTACHMENT) {
|
if features.contains(format::ImageFeature::COLOR_ATTACHMENT) {
|
||||||
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT as _;
|
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT as u32;
|
||||||
}
|
}
|
||||||
if features.contains(format::ImageFeature::COLOR_ATTACHMENT_BLEND) {
|
if features.contains(format::ImageFeature::COLOR_ATTACHMENT_BLEND) {
|
||||||
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT as _;
|
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT as u32;
|
||||||
}
|
}
|
||||||
if features.contains(format::ImageFeature::DEPTH_STENCIL_ATTACHMENT) {
|
if features.contains(format::ImageFeature::DEPTH_STENCIL_ATTACHMENT) {
|
||||||
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT as _;
|
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT as u32;
|
||||||
}
|
}
|
||||||
if features.contains(format::ImageFeature::BLIT_SRC) {
|
if features.contains(format::ImageFeature::BLIT_SRC) {
|
||||||
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_BLIT_SRC_BIT as _;
|
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_BLIT_SRC_BIT as u32;
|
||||||
}
|
}
|
||||||
if features.contains(format::ImageFeature::BLIT_DST) {
|
if features.contains(format::ImageFeature::BLIT_DST) {
|
||||||
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_BLIT_DST_BIT as _;
|
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_BLIT_DST_BIT as u32;
|
||||||
}
|
}
|
||||||
if features.contains(format::ImageFeature::SAMPLED_LINEAR) {
|
if features.contains(format::ImageFeature::SAMPLED_LINEAR) {
|
||||||
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT as _;
|
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT as u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags
|
flags
|
||||||
|
@ -85,16 +85,16 @@ fn buffer_features_from_hal(features: format::BufferFeature) -> VkFormatFeatureF
|
||||||
let mut flags = 0;
|
let mut flags = 0;
|
||||||
|
|
||||||
if features.contains(format::BufferFeature::UNIFORM_TEXEL) {
|
if features.contains(format::BufferFeature::UNIFORM_TEXEL) {
|
||||||
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT as _;
|
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT as u32;
|
||||||
}
|
}
|
||||||
if features.contains(format::BufferFeature::STORAGE_TEXEL) {
|
if features.contains(format::BufferFeature::STORAGE_TEXEL) {
|
||||||
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT as _;
|
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT as u32;
|
||||||
}
|
}
|
||||||
if features.contains(format::BufferFeature::STORAGE_TEXEL_ATOMIC) {
|
if features.contains(format::BufferFeature::STORAGE_TEXEL_ATOMIC) {
|
||||||
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT as _;
|
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT as u32;
|
||||||
}
|
}
|
||||||
if features.contains(format::BufferFeature::VERTEX) {
|
if features.contains(format::BufferFeature::VERTEX) {
|
||||||
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT as _;
|
flags |= VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT as u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags
|
flags
|
||||||
|
|
|
@ -288,11 +288,25 @@ extern "C" {
|
||||||
pMemoryRequirements:
|
pMemoryRequirements:
|
||||||
*mut VkMemoryRequirements);
|
*mut VkMemoryRequirements);
|
||||||
}
|
}
|
||||||
extern "C" {
|
#[inline]
|
||||||
pub fn vkGetImageMemoryRequirements(device: VkDevice, image: VkImage,
|
pub extern fn gfxGetImageMemoryRequirements(
|
||||||
pMemoryRequirements:
|
gpu: VkDevice,
|
||||||
*mut VkMemoryRequirements);
|
image: VkImage,
|
||||||
|
pMemoryRequirements: *mut VkMemoryRequirements,
|
||||||
|
) {
|
||||||
|
let req = match *image.deref() {
|
||||||
|
Image::Image(ref image) => unimplemented!(),
|
||||||
|
Image::Unbound(ref image) => {
|
||||||
|
gpu.device.get_image_requirements(image)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let memory_requirements = unsafe { &mut *pMemoryRequirements };
|
||||||
|
memory_requirements.size = req.size;
|
||||||
|
memory_requirements.alignment = req.alignment;
|
||||||
|
memory_requirements.memoryTypeBits = req.type_mask as _;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn vkGetImageSparseMemoryRequirements(device: VkDevice,
|
pub fn vkGetImageSparseMemoryRequirements(device: VkDevice,
|
||||||
image: VkImage,
|
image: VkImage,
|
||||||
|
|
|
@ -75,6 +75,14 @@ pub extern fn vkCreateImageView(
|
||||||
gfxCreateImageView(device, pCreateInfo, pAllocator, pView)
|
gfxCreateImageView(device, pCreateInfo, pAllocator, pView)
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
pub extern fn vkGetImageMemoryRequirements(
|
||||||
|
device: VkDevice,
|
||||||
|
image: VkImage,
|
||||||
|
pMemoryRequirements: *mut VkMemoryRequirements,
|
||||||
|
) {
|
||||||
|
gfxGetImageMemoryRequirements(device, image, pMemoryRequirements)
|
||||||
|
}
|
||||||
|
#[no_mangle]
|
||||||
pub extern fn vkDestroyImageView(
|
pub extern fn vkDestroyImageView(
|
||||||
device: VkDevice,
|
device: VkDevice,
|
||||||
imageView: VkImageView,
|
imageView: VkImageView,
|
||||||
|
|
|
@ -268,6 +268,16 @@ int main() {
|
||||||
printf("\tvkCreateImage: res=%d\n", res);
|
printf("\tvkCreateImage: res=%d\n", res);
|
||||||
assert(!res);
|
assert(!res);
|
||||||
|
|
||||||
|
vkGetImageMemoryRequirements(device, depth_image, &mem_reqs);
|
||||||
|
printf("\tvkGetImageMemoryRequirements\n");
|
||||||
|
printf(
|
||||||
|
"\t\tsize: %llx\n"
|
||||||
|
"\t\talignment: %llx\n"
|
||||||
|
"\t\tmemoryTypeBits: %x\n",
|
||||||
|
mem_reqs.size,
|
||||||
|
mem_reqs.alignment,
|
||||||
|
mem_reqs.memoryTypeBits);
|
||||||
|
|
||||||
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