Commit 38ff8304 by Alexis Hetu Committed by Alexis Hétu

Buffer, BufferView and DeviceMemory

This cl adds Buffer, BufferView and DeviceMemory. - DeviceMemory contains the appropriate logic to allocate and map device memory. - Buffer simply wraps a DeviceMemory and an offset for now. - BufferView wraps a Buffer with a memory region and a Format. Bug b/118383648 Change-Id: I6d53b9f0728d4cdec2696339cc6aa8ce2e05ca49 Reviewed-on: https://swiftshader-review.googlesource.com/c/21728Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent fde88d96
// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "VkBuffer.hpp"
#include "VkConfig.h"
#include "VkDeviceMemory.hpp"
#include <memory.h>
namespace vk
{
Buffer::Buffer(const VkBufferCreateInfo* pCreateInfo, void* mem) :
flags(pCreateInfo->flags), size(pCreateInfo->size), usage(pCreateInfo->usage),
sharingMode(pCreateInfo->sharingMode), queueFamilyIndexCount(pCreateInfo->queueFamilyIndexCount),
queueFamilyIndices(reinterpret_cast<uint32_t*>(mem))
{
size_t queueFamilyIndicesSize = sizeof(uint32_t) * queueFamilyIndexCount;
memcpy(queueFamilyIndices, pCreateInfo->pQueueFamilyIndices, queueFamilyIndicesSize);
}
void Buffer::destroy(const VkAllocationCallbacks* pAllocator)
{
vk::deallocate(queueFamilyIndices, pAllocator);
}
size_t Buffer::ComputeRequiredAllocationSize(const VkBufferCreateInfo* pCreateInfo)
{
return sizeof(uint32_t) * pCreateInfo->queueFamilyIndexCount;
}
const VkMemoryRequirements Buffer::getMemoryRequirements() const
{
VkMemoryRequirements memoryRequirements = {};
memoryRequirements.alignment = vk::REQUIRED_MEMORY_ALIGNMENT;
memoryRequirements.memoryTypeBits = vk::REQUIRED_MEMORY_TYPE_BITS;
memoryRequirements.size = size; // TODO: also reserve space for a header containing
// the size of the buffer (for robust buffer access)
return memoryRequirements;
}
void Buffer::bind(VkDeviceMemory pDeviceMemory, VkDeviceSize pMemoryOffset)
{
memory = Cast(pDeviceMemory)->getOffsetPointer(pMemoryOffset);
}
} // namespace vk
// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef VK_BUFFER_HPP_
#define VK_BUFFER_HPP_
#include "VkObject.hpp"
namespace vk
{
class Buffer : public Object<Buffer, VkBuffer>
{
public:
Buffer(const VkBufferCreateInfo* pCreateInfo, void* mem);
~Buffer() = delete;
void destroy(const VkAllocationCallbacks* pAllocator);
static size_t ComputeRequiredAllocationSize(const VkBufferCreateInfo* pCreateInfo);
const VkMemoryRequirements getMemoryRequirements() const;
void bind(VkDeviceMemory pDeviceMemory, VkDeviceSize pMemoryOffset);
private:
void* memory = nullptr;
VkBufferCreateFlags flags = 0;
VkDeviceSize size = 0;
VkBufferUsageFlags usage = 0;
VkSharingMode sharingMode = VK_SHARING_MODE_EXCLUSIVE;
uint32_t queueFamilyIndexCount = 0;
uint32_t* queueFamilyIndices = nullptr;
};
static inline Buffer* Cast(VkBuffer object)
{
return reinterpret_cast<Buffer*>(object);
}
} // namespace vk
#endif // VK_BUFFER_HPP_
// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef VK_BUFFER_VIEW_HPP_
#define VK_BUFFER_VIEW_HPP_
#include "VkObject.hpp"
namespace vk
{
class BufferView : public Object<BufferView, VkBufferView>
{
public:
BufferView(const VkBufferViewCreateInfo* pCreateInfo, void* mem) :
buffer(pCreateInfo->buffer), format(pCreateInfo->format), offset(pCreateInfo->offset), range(pCreateInfo->range)
{
}
~BufferView() = delete;
static size_t ComputeRequiredAllocationSize(const VkBufferViewCreateInfo* pCreateInfo)
{
return 0;
}
private:
VkBuffer buffer;
VkFormat format;
VkDeviceSize offset;
VkDeviceSize range;
};
static inline BufferView* Cast(VkBufferView object)
{
return reinterpret_cast<BufferView*>(object);
}
} // namespace vk
#endif // VK_BUFFER_VIEW_HPP_
...@@ -12,8 +12,11 @@ ...@@ -12,8 +12,11 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "VkBuffer.hpp"
#include "VkBufferView.hpp"
#include "VkCommandBuffer.hpp" #include "VkCommandBuffer.hpp"
#include "VkDevice.hpp" #include "VkDevice.hpp"
#include "VkDeviceMemory.hpp"
#include "VkEvent.hpp" #include "VkEvent.hpp"
#include "VkFence.hpp" #include "VkFence.hpp"
#include "VkInstance.hpp" #include "VkInstance.hpp"
......
...@@ -45,6 +45,7 @@ public: ...@@ -45,6 +45,7 @@ public:
VkPeerMemoryFeatureFlags* pPeerMemoryFeatures) const; VkPeerMemoryFeatureFlags* pPeerMemoryFeatures) const;
void getDescriptorSetLayoutSupport(const VkDescriptorSetLayoutCreateInfo* pCreateInfo, void getDescriptorSetLayoutSupport(const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
VkDescriptorSetLayoutSupport* pSupport) const; VkDescriptorSetLayoutSupport* pSupport) const;
VkPhysicalDevice getPhysicalDevice() const { return physicalDevice; }
private: private:
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE; VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
......
// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "VkConfig.h"
#include "VkDeviceMemory.hpp"
namespace vk
{
DeviceMemory::DeviceMemory(const VkMemoryAllocateInfo* pCreateInfo, void* mem) :
size(pCreateInfo->allocationSize), buffer(nullptr), memoryTypeIndex(pCreateInfo->memoryTypeIndex)
{
ASSERT(size);
}
void DeviceMemory::destroy(const VkAllocationCallbacks* pAllocator)
{
vk::deallocate(buffer, DEVICE_MEMORY);
}
size_t DeviceMemory::ComputeRequiredAllocationSize(const VkMemoryAllocateInfo* pCreateInfo)
{
// buffer is "GPU memory", so we use device memory for it
return 0;
}
VkResult DeviceMemory::allocate()
{
if(!buffer)
{
buffer = vk::allocate(size, REQUIRED_MEMORY_ALIGNMENT, DEVICE_MEMORY);
}
if(!buffer)
{
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
}
return VK_SUCCESS;
}
VkResult DeviceMemory::map(VkDeviceSize pOffset, VkDeviceSize pSize, void** ppData)
{
*ppData = getOffsetPointer(pOffset);
return VK_SUCCESS;
}
VkDeviceSize DeviceMemory::getCommittedMemoryInBytes() const
{
return size;
}
void* DeviceMemory::getOffsetPointer(VkDeviceSize pOffset)
{
ASSERT(buffer);
return reinterpret_cast<char*>(buffer) + pOffset;
}
} // namespace vk
// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef VK_DEVICE_MEMORY_HPP_
#define VK_DEVICE_MEMORY_HPP_
#include "VkObject.hpp"
namespace vk
{
class DeviceMemory : public Object<DeviceMemory, VkDeviceMemory>
{
public:
DeviceMemory(const VkMemoryAllocateInfo* pCreateInfo, void* mem);
~DeviceMemory() = delete;
static size_t ComputeRequiredAllocationSize(const VkMemoryAllocateInfo* pCreateInfo);
void destroy(const VkAllocationCallbacks* pAllocator);
VkResult allocate();
VkResult map(VkDeviceSize offset, VkDeviceSize size, void** ppData);
VkDeviceSize getCommittedMemoryInBytes() const;
void* getOffsetPointer(VkDeviceSize pOffset);
uint32_t getMemoryTypeIndex() const { return memoryTypeIndex; }
private:
void* buffer = nullptr;
VkDeviceSize size = 0;
uint32_t memoryTypeIndex = 0;
};
static inline DeviceMemory* Cast(VkDeviceMemory object)
{
return reinterpret_cast<DeviceMemory*>(object);
}
} // namespace vk
#endif // VK_DEVICE_MEMORY_HPP_
...@@ -12,11 +12,14 @@ ...@@ -12,11 +12,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "VkBuffer.hpp"
#include "VkBufferView.hpp"
#include "VkConfig.h" #include "VkConfig.h"
#include "VkCommandBuffer.hpp" #include "VkCommandBuffer.hpp"
#include "VkDebug.hpp" #include "VkDebug.hpp"
#include "VkDestroy.h" #include "VkDestroy.h"
#include "VkDevice.hpp" #include "VkDevice.hpp"
#include "VkDeviceMemory.hpp"
#include "VkEvent.hpp" #include "VkEvent.hpp"
#include "VkFence.hpp" #include "VkFence.hpp"
#include "VkGetProcAddress.h" #include "VkGetProcAddress.h"
...@@ -377,9 +380,26 @@ VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory(VkDevice device, const VkMemoryA ...@@ -377,9 +380,26 @@ VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory(VkDevice device, const VkMemoryA
TRACE("(VkDevice device = 0x%X, const VkMemoryAllocateInfo* pAllocateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkDeviceMemory* pMemory = 0x%X)", TRACE("(VkDevice device = 0x%X, const VkMemoryAllocateInfo* pAllocateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkDeviceMemory* pMemory = 0x%X)",
device, pAllocateInfo, pAllocator, pMemory); device, pAllocateInfo, pAllocator, pMemory);
if(pAllocateInfo->pNext)
{
UNIMPLEMENTED(); UNIMPLEMENTED();
}
return VK_SUCCESS; VkResult result = vk::DeviceMemory::Create(pAllocator, pAllocateInfo, pMemory);
if(result != VK_SUCCESS)
{
return result;
}
// Make sure the memory allocation is done now so that OOM errors can be checked now
result = vk::Cast(*pMemory)->allocate();
if(result != VK_SUCCESS)
{
vk::destroy(*pMemory, pAllocator);
*pMemory = VK_NULL_HANDLE;
}
return result;
} }
VKAPI_ATTR void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks* pAllocator) VKAPI_ATTR void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks* pAllocator)
...@@ -387,7 +407,7 @@ VKAPI_ATTR void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory memory, ...@@ -387,7 +407,7 @@ VKAPI_ATTR void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory memory,
TRACE("(VkDevice device = 0x%X, VkDeviceMemory memory = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)", TRACE("(VkDevice device = 0x%X, VkDeviceMemory memory = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
device, memory, pAllocator); device, memory, pAllocator);
UNIMPLEMENTED(); vk::destroy(memory, pAllocator);
} }
VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData) VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData)
...@@ -395,16 +415,14 @@ VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(VkDevice device, VkDeviceMemory memor ...@@ -395,16 +415,14 @@ VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(VkDevice device, VkDeviceMemory memor
TRACE("(VkDevice device = 0x%X, VkDeviceMemory memory = 0x%X, VkDeviceSize offset = %d, VkDeviceSize size = %d, VkMemoryMapFlags flags = 0x%X, void** ppData = 0x%X)", TRACE("(VkDevice device = 0x%X, VkDeviceMemory memory = 0x%X, VkDeviceSize offset = %d, VkDeviceSize size = %d, VkMemoryMapFlags flags = 0x%X, void** ppData = 0x%X)",
device, memory, offset, size, flags, ppData); device, memory, offset, size, flags, ppData);
UNIMPLEMENTED(); return vk::Cast(memory)->map(offset, size, ppData);
return VK_SUCCESS;
} }
VKAPI_ATTR void VKAPI_CALL vkUnmapMemory(VkDevice device, VkDeviceMemory memory) VKAPI_ATTR void VKAPI_CALL vkUnmapMemory(VkDevice device, VkDeviceMemory memory)
{ {
TRACE("(VkDevice device = 0x%X, VkDeviceMemory memory = 0x%X)", device, memory); TRACE("(VkDevice device = 0x%X, VkDeviceMemory memory = 0x%X)", device, memory);
UNIMPLEMENTED(); // Noop, memory will be released when the DeviceMemory object is released
} }
VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges) VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges)
...@@ -412,7 +430,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges(VkDevice device, uint32 ...@@ -412,7 +430,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges(VkDevice device, uint32
TRACE("(VkDevice device = 0x%X, uint32_t memoryRangeCount = %d, const VkMappedMemoryRange* pMemoryRanges = 0x%X)", TRACE("(VkDevice device = 0x%X, uint32_t memoryRangeCount = %d, const VkMappedMemoryRange* pMemoryRanges = 0x%X)",
device, memoryRangeCount, pMemoryRanges); device, memoryRangeCount, pMemoryRanges);
UNIMPLEMENTED(); // Noop, host and device memory are the same to SwiftShader
return VK_SUCCESS; return VK_SUCCESS;
} }
...@@ -422,15 +440,26 @@ VKAPI_ATTR VkResult VKAPI_CALL vkInvalidateMappedMemoryRanges(VkDevice device, u ...@@ -422,15 +440,26 @@ VKAPI_ATTR VkResult VKAPI_CALL vkInvalidateMappedMemoryRanges(VkDevice device, u
TRACE("(VkDevice device = 0x%X, uint32_t memoryRangeCount = %d, const VkMappedMemoryRange* pMemoryRanges = 0x%X)", TRACE("(VkDevice device = 0x%X, uint32_t memoryRangeCount = %d, const VkMappedMemoryRange* pMemoryRanges = 0x%X)",
device, memoryRangeCount, pMemoryRanges); device, memoryRangeCount, pMemoryRanges);
UNIMPLEMENTED(); // Noop, host and device memory are the same to SwiftShader
return VK_SUCCESS; return VK_SUCCESS;
} }
VKAPI_ATTR void VKAPI_CALL vkGetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes) VKAPI_ATTR void VKAPI_CALL vkGetDeviceMemoryCommitment(VkDevice pDevice, VkDeviceMemory pMemory, VkDeviceSize* pCommittedMemoryInBytes)
{ {
TRACE("()"); TRACE("(VkDevice device = 0x%X, VkDeviceMemory memory = 0x%X, VkDeviceSize* pCommittedMemoryInBytes = 0x%X)",
UNIMPLEMENTED(); pDevice, pMemory, pCommittedMemoryInBytes);
auto memory = vk::Cast(pMemory);
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
const auto& memoryProperties = vk::Cast(vk::Cast(pDevice)->getPhysicalDevice())->getMemoryProperties();
uint32_t typeIndex = memory->getMemoryTypeIndex();
ASSERT(typeIndex < memoryProperties.memoryTypeCount);
ASSERT(memoryProperties.memoryTypes[typeIndex].propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT);
#endif
*pCommittedMemoryInBytes = memory->getCommittedMemoryInBytes();
} }
VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset) VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset)
...@@ -438,7 +467,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, VkBuffer buff ...@@ -438,7 +467,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, VkBuffer buff
TRACE("(VkDevice device = 0x%X, VkBuffer buffer = 0x%X, VkDeviceMemory memory = 0x%X, VkDeviceSize memoryOffset = %d)", TRACE("(VkDevice device = 0x%X, VkBuffer buffer = 0x%X, VkDeviceMemory memory = 0x%X, VkDeviceSize memoryOffset = %d)",
device, buffer, memory, memoryOffset); device, buffer, memory, memoryOffset);
UNIMPLEMENTED(); vk::Cast(buffer)->bind(memory, memoryOffset);
return VK_SUCCESS; return VK_SUCCESS;
} }
...@@ -458,7 +487,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements(VkDevice device, VkBuff ...@@ -458,7 +487,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements(VkDevice device, VkBuff
TRACE("(VkDevice device = 0x%X, VkBuffer buffer = 0x%X, VkMemoryRequirements* pMemoryRequirements = 0x%X)", TRACE("(VkDevice device = 0x%X, VkBuffer buffer = 0x%X, VkMemoryRequirements* pMemoryRequirements = 0x%X)",
device, buffer, pMemoryRequirements); device, buffer, pMemoryRequirements);
UNIMPLEMENTED(); *pMemoryRequirements = vk::Cast(buffer)->getMemoryRequirements();
} }
VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements* pMemoryRequirements) VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements* pMemoryRequirements)
...@@ -631,9 +660,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer(VkDevice device, const VkBufferCre ...@@ -631,9 +660,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer(VkDevice device, const VkBufferCre
TRACE("(VkDevice device = 0x%X, const VkBufferCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkBuffer* pBuffer = 0x%X)", TRACE("(VkDevice device = 0x%X, const VkBufferCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkBuffer* pBuffer = 0x%X)",
device, pCreateInfo, pAllocator, pBuffer); device, pCreateInfo, pAllocator, pBuffer);
if(pCreateInfo->pNext)
{
UNIMPLEMENTED(); UNIMPLEMENTED();
}
return VK_SUCCESS; return vk::Buffer::Create(pAllocator, pCreateInfo, pBuffer);
} }
VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator) VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator)
...@@ -641,20 +673,28 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer(VkDevice device, VkBuffer buffer, con ...@@ -641,20 +673,28 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer(VkDevice device, VkBuffer buffer, con
TRACE("(VkDevice device = 0x%X, VkBuffer buffer = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)", TRACE("(VkDevice device = 0x%X, VkBuffer buffer = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
device, buffer, pAllocator); device, buffer, pAllocator);
UNIMPLEMENTED(); vk::destroy(buffer, pAllocator);
} }
VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView) VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView)
{ {
TRACE("()"); TRACE("(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView)",
device, pCreateInfo, pAllocator, pView);
if(pCreateInfo->pNext || pCreateInfo->flags)
{
UNIMPLEMENTED(); UNIMPLEMENTED();
return VK_SUCCESS; }
return vk::BufferView::Create(pAllocator, pCreateInfo, pView);
} }
VKAPI_ATTR void VKAPI_CALL vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator) VKAPI_ATTR void VKAPI_CALL vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator)
{ {
TRACE("()"); TRACE("(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator)",
UNIMPLEMENTED(); device, bufferView, pAllocator);
vk::destroy(bufferView, pAllocator);
} }
VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImage* pImage) VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImage* pImage)
...@@ -1340,8 +1380,19 @@ VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceVersion(uint32_t* pApiVersion) ...@@ -1340,8 +1380,19 @@ VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceVersion(uint32_t* pApiVersion)
VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo* pBindInfos) VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo* pBindInfos)
{ {
TRACE("()"); TRACE("(VkDevice device = 0x%X, uint32_t bindInfoCount = %d, const VkBindBufferMemoryInfo* pBindInfos = 0x%X)",
device, bindInfoCount, pBindInfos);
for(uint32_t i = 0; i < bindInfoCount; i++)
{
if(pBindInfos[i].pNext)
{
UNIMPLEMENTED(); UNIMPLEMENTED();
}
vk::Cast(pBindInfos[i].buffer)->bind(pBindInfos[i].memory, pBindInfos[i].memoryOffset);
}
return VK_SUCCESS; return VK_SUCCESS;
} }
......
...@@ -98,9 +98,11 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor ...@@ -98,9 +98,11 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor
<ItemGroup> <ItemGroup>
<ClCompile Include="libVulkan.cpp" /> <ClCompile Include="libVulkan.cpp" />
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
<ClCompile Include="VkBuffer.cpp" />
<ClCompile Include="VkCommandBuffer.cpp" /> <ClCompile Include="VkCommandBuffer.cpp" />
<ClCompile Include="VkDebug.cpp" /> <ClCompile Include="VkDebug.cpp" />
<ClCompile Include="VkDevice.cpp" /> <ClCompile Include="VkDevice.cpp" />
<ClCompile Include="VkDeviceMemory.cpp" />
<ClCompile Include="VkGetProcAddress.cpp" /> <ClCompile Include="VkGetProcAddress.cpp" />
<ClCompile Include="VkInstance.cpp" /> <ClCompile Include="VkInstance.cpp" />
<ClCompile Include="VkMemory.cpp" /> <ClCompile Include="VkMemory.cpp" />
...@@ -180,11 +182,14 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor ...@@ -180,11 +182,14 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
<ClInclude Include="VkBuffer.hpp" />
<ClInclude Include="VkBufferView.hpp" />
<ClInclude Include="VkCommandBuffer.hpp" /> <ClInclude Include="VkCommandBuffer.hpp" />
<ClInclude Include="VkConfig.h" /> <ClInclude Include="VkConfig.h" />
<ClInclude Include="VkDebug.hpp" /> <ClInclude Include="VkDebug.hpp" />
<ClInclude Include="VkDestroy.h" /> <ClInclude Include="VkDestroy.h" />
<ClInclude Include="VkDevice.hpp" /> <ClInclude Include="VkDevice.hpp" />
<ClInclude Include="VkDeviceMemory.hpp" />
<ClInclude Include="VkEvent.hpp" /> <ClInclude Include="VkEvent.hpp" />
<ClInclude Include="VkFence.hpp" /> <ClInclude Include="VkFence.hpp" />
<ClInclude Include="VkGetProcAddress.h" /> <ClInclude Include="VkGetProcAddress.h" />
......
...@@ -207,6 +207,9 @@ ...@@ -207,6 +207,9 @@
<ClCompile Include="main.cpp"> <ClCompile Include="main.cpp">
<Filter>Source Files\Vulkan</Filter> <Filter>Source Files\Vulkan</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="VkBuffer.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="VkCommandBuffer.cpp"> <ClCompile Include="VkCommandBuffer.cpp">
<Filter>Source Files\Vulkan</Filter> <Filter>Source Files\Vulkan</Filter>
</ClCompile> </ClCompile>
...@@ -216,6 +219,9 @@ ...@@ -216,6 +219,9 @@
<ClCompile Include="VkDevice.cpp"> <ClCompile Include="VkDevice.cpp">
<Filter>Source Files\Vulkan</Filter> <Filter>Source Files\Vulkan</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="VkDeviceMemory.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="VkGetProcAddress.cpp"> <ClCompile Include="VkGetProcAddress.cpp">
<Filter>Source Files\Vulkan</Filter> <Filter>Source Files\Vulkan</Filter>
</ClCompile> </ClCompile>
...@@ -239,6 +245,12 @@ ...@@ -239,6 +245,12 @@
<ClInclude Include="resource.h"> <ClInclude Include="resource.h">
<Filter>Header Files\Vulkan</Filter> <Filter>Header Files\Vulkan</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="VkBuffer.hpp">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
<ClInclude Include="VkBufferView.hpp">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
<ClInclude Include="VkCommandBuffer.hpp"> <ClInclude Include="VkCommandBuffer.hpp">
<Filter>Header Files\Vulkan</Filter> <Filter>Header Files\Vulkan</Filter>
</ClInclude> </ClInclude>
...@@ -248,6 +260,9 @@ ...@@ -248,6 +260,9 @@
<ClInclude Include="VkDevice.hpp"> <ClInclude Include="VkDevice.hpp">
<Filter>Header Files\Vulkan</Filter> <Filter>Header Files\Vulkan</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="VkDeviceMemory.hpp">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
<ClInclude Include="VkEvent.hpp"> <ClInclude Include="VkEvent.hpp">
<Filter>Header Files\Vulkan</Filter> <Filter>Header Files\Vulkan</Filter>
</ClInclude> </ClInclude>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment