1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 20:52:10 +01:00

[dxvk] Implemented image creation

This commit is contained in:
Philip Rebohle 2017-11-27 12:01:35 +01:00
parent 0e5cae826f
commit c572a9c393
3 changed files with 51 additions and 9 deletions

View File

@ -67,7 +67,8 @@ namespace dxvk {
Rc<DxvkImage> DxvkDevice::createImage( Rc<DxvkImage> DxvkDevice::createImage(
const DxvkImageCreateInfo& createInfo, const DxvkImageCreateInfo& createInfo,
VkMemoryPropertyFlags memoryType) { VkMemoryPropertyFlags memoryType) {
// TODO implement return new DxvkImage(m_vkd,
createInfo, *m_memory, memoryType);
} }

View File

@ -2,13 +2,44 @@
namespace dxvk { namespace dxvk {
// DxvkImage::DxvkImage( DxvkImage::DxvkImage(
// const Rc<vk::DeviceFn>& vkd, const Rc<vk::DeviceFn>& vkd,
// const DxvkImageCreateInfo& info, const DxvkImageCreateInfo& createInfo,
// DxvkMemory&& memory) DxvkMemoryAllocator& memAlloc,
// : m_vkd(vkd), m_info(info), m_memory(std::move(memory)) { VkMemoryPropertyFlags memFlags)
// : m_vkd(vkd), m_info(createInfo) {
// }
VkImageCreateInfo info;
info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
info.pNext = nullptr;
// TODO VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT if appropriate
info.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
info.imageType = createInfo.type;
info.format = createInfo.format;
info.extent = createInfo.extent;
info.mipLevels = createInfo.mipLevels;
info.arrayLayers = createInfo.numLayers;
info.samples = createInfo.sampleCount;
info.tiling = createInfo.tiling;
info.usage = createInfo.usage;
info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
info.queueFamilyIndexCount = 0;
info.pQueueFamilyIndices = nullptr;
info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
if (m_vkd->vkCreateImage(m_vkd->device(),
&info, nullptr, &m_image) != VK_SUCCESS)
throw DxvkError("DxvkImage::DxvkImage: Failed to create image");
VkMemoryRequirements memReq;
m_vkd->vkGetImageMemoryRequirements(
m_vkd->device(), m_image, &memReq);
m_memory = memAlloc.alloc(memReq, memFlags);
if (m_vkd->vkBindImageMemory(m_vkd->device(),
m_image, m_memory.memory(), m_memory.offset()) != VK_SUCCESS)
throw DxvkError("DxvkImage::DxvkImage: Failed to bind device memory");
}
DxvkImage::DxvkImage( DxvkImage::DxvkImage(

View File

@ -31,11 +31,21 @@ namespace dxvk {
/** /**
* \brief DXVK image * \brief DXVK image
*
* An image resource consisting of various subresources.
* Cannot be mapped to host memory, the only way to access
* image data is through buffer transfer operations.
*/ */
class DxvkImage : public DxvkResource { class DxvkImage : public DxvkResource {
public: public:
DxvkImage(
const Rc<vk::DeviceFn>& vkd,
const DxvkImageCreateInfo& createInfo,
DxvkMemoryAllocator& memAlloc,
VkMemoryPropertyFlags memFlags);
/** /**
* \brief Creates image object from existing image * \brief Creates image object from existing image
* *
@ -82,7 +92,7 @@ namespace dxvk {
Rc<vk::DeviceFn> m_vkd; Rc<vk::DeviceFn> m_vkd;
DxvkImageCreateInfo m_info; DxvkImageCreateInfo m_info;
DxvkMemory m_memory; DxvkMemory m_memory;
VkImage m_image; VkImage m_image = VK_NULL_HANDLE;
}; };