Commit 767b41b1 by Alexis Hetu Committed by Alexis Hétu

Vulkan dispatchable objects

Vulkan has a few dispatchable objects: Instance, Device, Physical Device, Command Buffer and Queue. These objects, when loaded through an ICD, are constrained to have a bit of memory allocated at the beginning of these objects to contain loader data. In order to do this, a wrapper class, DispatchableObject, was created to handle pointing directly to the loader data when casting to the associated VK handle and similarly back to a pointer to the internal object. Note that Queue, being allocated within another object, and not directly through the API, simply have the loader data at the beginning of the class, without requiring a wrapper class. Also, since all these object are allocated through a custom placement new operator, they have to be deallocated through an associated destroy() function, so the DispatchableObject destructor is deleted, in order to prevent these objects from being released any other way. Bug b/116336664 Change-Id: Iac749f6adcba0eaf7557f0df876ac0474081d9cc Reviewed-on: https://swiftshader-review.googlesource.com/c/20948Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 71e256ca
// 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 "VkCommandBuffer.hpp"
namespace vk
{
CommandBuffer::CommandBuffer(VkCommandBufferLevel pLevel) : level(pLevel)
{
pipelines[VK_PIPELINE_BIND_POINT_GRAPHICS] = VK_NULL_HANDLE;
pipelines[VK_PIPELINE_BIND_POINT_COMPUTE] = VK_NULL_HANDLE;
}
} // namespace vk
\ No newline at end of file
// 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_COMMAND_BUFFER_HPP_
#define VK_COMMAND_BUFFER_HPP_
#include "VkConfig.h"
#include "VkObject.hpp"
namespace vk
{
class CommandBuffer
{
public:
static constexpr VkSystemAllocationScope GetAllocationScope() { return VK_SYSTEM_ALLOCATION_SCOPE_OBJECT; }
CommandBuffer(VkCommandBufferLevel pLevel);
private:
VkCommandBufferLevel level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
VkPipeline pipelines[VK_PIPELINE_BIND_POINT_RANGE_SIZE];
};
using DispatchableCommandBuffer = DispatchableObject<CommandBuffer, VkCommandBuffer>;
static inline CommandBuffer* Cast(VkCommandBuffer object)
{
return DispatchableCommandBuffer::Cast(object);
}
} // namespace vk
#endif // VK_COMMAND_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_CONFIG_HPP_
#define VK_CONFIG_HPP_
namespace vk
{
// Note: Constant array initialization requires a string literal.
// constexpr char* or char[] does not work for that purpose.
#define SWIFTSHADER_DEVICE_NAME "SwiftShader Device" // Max length: VK_MAX_PHYSICAL_DEVICE_NAME_SIZE
#define SWIFTSHADER_UUID "SwiftShaderUUID" // Max length: VK_UUID_SIZE
enum
{
DRIVER_VERSION = 1,
VENDOR_ID = 0x1AE0, // Google
DEVICE_ID = 0xC0DE, // SwiftShader
};
enum
{
REQUIRED_MEMORY_ALIGNMENT = 8, // For 64 bit formats on ARM64
REQUIRED_MEMORY_TYPE_BITS = 1,
};
enum
{
MAX_IMAGE_LEVELS_1D = 14,
MAX_IMAGE_LEVELS_2D = 14,
MAX_IMAGE_LEVELS_3D = 11,
MAX_IMAGE_LEVELS_CUBE = 14,
MAX_IMAGE_ARRAY_LAYERS = 11,
};
enum {
MaxVertexInputBindings = 16,
};
}
#endif // VK_CONFIG_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.
#include "VkConfig.h"
#include "VkDebug.hpp"
#include "VkDevice.hpp"
#include <new> // Must #include this to use "placement new"
namespace vk
{
Device::Device(const Device::CreateInfo* info, void* mem)
: physicalDevice(info->pPhysicalDevice), queues(reinterpret_cast<Queue*>(mem))
{
const auto* pCreateInfo = info->pCreateInfo;
for(uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++)
{
const VkDeviceQueueCreateInfo& queueCreateInfo = pCreateInfo->pQueueCreateInfos[i];
queueCount += info->pCreateInfo->pQueueCreateInfos[i].queueCount;
}
uint32_t queueID = 0;
for(uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++)
{
const VkDeviceQueueCreateInfo& queueCreateInfo = pCreateInfo->pQueueCreateInfos[i];
for(uint32_t j = 0; j < queueCreateInfo.queueCount; j++, queueID++)
{
new (queues + queueID) Queue(queueCreateInfo.queueFamilyIndex, queueCreateInfo.pQueuePriorities[j]);
}
}
}
void Device::destroy(const VkAllocationCallbacks* pAllocator)
{
vk::deallocate(queues, pAllocator);
}
size_t Device::ComputeRequiredAllocationSize(const Device::CreateInfo* info)
{
uint32_t queueCount = 0;
for(uint32_t i = 0; i < info->pCreateInfo->queueCreateInfoCount; i++)
{
queueCount += info->pCreateInfo->pQueueCreateInfos[i].queueCount;
}
return sizeof(Queue) * queueCount;
}
VkQueue Device::getQueue(uint32_t queueFamilyIndex, uint32_t queueIndex) const
{
ASSERT(queueFamilyIndex == 0);
return queues[queueIndex];
}
} // 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_HPP_
#define VK_DEVICE_HPP_
#include "VkObject.hpp"
#include "VkQueue.hpp"
namespace vk
{
class Device
{
public:
struct CreateInfo
{
const VkDeviceCreateInfo* pCreateInfo;
VkPhysicalDevice pPhysicalDevice;
};
static constexpr VkSystemAllocationScope GetAllocationScope() { return VK_SYSTEM_ALLOCATION_SCOPE_DEVICE; }
Device(const CreateInfo* info, void* mem);
void destroy(const VkAllocationCallbacks* pAllocator);
static size_t ComputeRequiredAllocationSize(const CreateInfo* info);
VkQueue getQueue(uint32_t queueFamilyIndex, uint32_t queueIndex) const;
private:
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
Queue* queues = nullptr;
uint32_t queueCount = 0;
};
using DispatchableDevice = DispatchableObject<Device, VkDevice>;
static inline Device* Cast(VkDevice object)
{
return DispatchableDevice::Cast(object);
}
} // namespace vk
#endif // VK_DEVICE_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.
#include "VkInstance.hpp"
namespace vk
{
Instance::Instance(const CreateInfo* pCreateInfo, void* mem)
{
if(pCreateInfo->pPhysicalDevice)
{
physicalDevice = pCreateInfo->pPhysicalDevice;
physicalDeviceCount = 1;
}
}
void Instance::destroy(const VkAllocationCallbacks* pAllocator)
{
vk::destroy(physicalDevice, pAllocator);
}
uint32_t Instance::getPhysicalDeviceCount() const
{
return physicalDeviceCount;
}
void Instance::getPhysicalDevices(uint32_t pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices) const
{
ASSERT(pPhysicalDeviceCount == 1);
*pPhysicalDevices = physicalDevice;
}
uint32_t Instance::getPhysicalDeviceGroupCount() const
{
return physicalDeviceGroupCount;
}
void Instance::getPhysicalDeviceGroups(uint32_t pPhysicalDeviceGroupCount,
VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties) const
{
ASSERT(pPhysicalDeviceGroupCount == 1);
pPhysicalDeviceGroupProperties->physicalDeviceCount = physicalDeviceCount;
pPhysicalDeviceGroupProperties->physicalDevices[0] = physicalDevice;
pPhysicalDeviceGroupProperties->subsetAllocation = VK_FALSE;
}
} // 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_INSTANCE_HPP_
#define VK_INSTANCE_HPP_
#include "VkPhysicalDevice.hpp"
namespace vk
{
class Instance
{
public:
struct CreateInfo
{
const VkInstanceCreateInfo* pCreateInfo;
VkPhysicalDevice pPhysicalDevice;
};
static constexpr VkSystemAllocationScope GetAllocationScope() { return VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE; }
Instance(const CreateInfo* pCreateInfo, void* mem);
void destroy(const VkAllocationCallbacks* pAllocator);
static size_t ComputeRequiredAllocationSize(const CreateInfo*) { return 0; }
uint32_t getPhysicalDeviceCount() const;
void getPhysicalDevices(uint32_t pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices) const;
uint32_t getPhysicalDeviceGroupCount() const;
void getPhysicalDeviceGroups(uint32_t pPhysicalDeviceGroupCount,
VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties) const;
private:
uint32_t physicalDeviceCount = 0;
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
uint32_t physicalDeviceGroupCount = 1;
};
using DispatchableInstance = DispatchableObject<Instance, VkInstance>;
static inline Instance* Cast(VkInstance object)
{
return DispatchableInstance::Cast(object);
}
} // namespace vk
#endif // VK_INSTANCE_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_OBJECT_HPP_
#define VK_OBJECT_HPP_
#include "VkConfig.h"
#include "VkMemory.h"
namespace vk
{
void* allocate(size_t count, size_t alignment, const VkAllocationCallbacks* pAllocator, VkSystemAllocationScope allocationScope)
{
return pAllocator ?
pAllocator->pfnAllocation(pAllocator->pUserData, count, alignment, allocationScope) :
sw::allocate(count, alignment);
}
void deallocate(void* ptr, const VkAllocationCallbacks* pAllocator)
{
pAllocator ? pAllocator->pfnFree(pAllocator->pUserData, ptr) : sw::deallocate(ptr);
}
} // namespace vk
#endif // VK_OBJECT_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_MEMORY_HPP_
#define VK_MEMORY_HPP_
#include "System/Memory.hpp"
#include <vulkan/vulkan.h>
namespace vk
{
void* allocate(size_t count, size_t alignment, const VkAllocationCallbacks* pAllocator,
VkSystemAllocationScope allocationScope = VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
void deallocate(void* ptr, const VkAllocationCallbacks* pAllocator);
template <typename T>
T* allocate(size_t count, const VkAllocationCallbacks* pAllocator)
{
return reinterpret_cast<T*>(allocate(count, alignof(T), pAllocator, T::GetAllocationScope()));
}
// Because Vulkan uses optional allocation callbacks, we use them in a custom
// placement new operator in the VkObjectBase class for simplicity.
// Unfortunately, since we use a placement new to allocate VkObjectBase derived
// classes objects, the corresponding deletion operator is a placement delete,
// which does nothing. In order to properly dispose of these objects' memory,
// we use this function, which calls the proper T:destroy() function
// prior to releasing the object (by default, VkObjectBase::destroy does nothing).
template<typename VkT>
inline void destroy(VkT vkObject, const VkAllocationCallbacks* pAllocator)
{
auto object = Cast(vkObject);
if(object)
{
object->destroy(pAllocator);
// object may not point to the same pointer as vkObject, for dispatchable objects,
// for example, so make sure to deallocate based on the vkObject pointer, which
// should always point to the beginning of the allocated memory
vk::deallocate(vkObject, pAllocator);
}
}
} // namespace vk
#endif // VK_MEMORY_HPP_
\ No newline at end of file
// 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_OBJECT_HPP_
#define VK_OBJECT_HPP_
#include "VkDebug.hpp"
#include "VkMemory.h"
#include <vulkan/vulkan.h>
#include <vulkan/vk_icd.h>
namespace vk
{
// For use in the placement new to make it verbose that we're allocating an object using device memory
static constexpr VkAllocationCallbacks* DEVICE_MEMORY = nullptr;
template<typename T, typename VkT, typename CreateInfo>
static VkResult Create(const VkAllocationCallbacks* pAllocator, const CreateInfo* pCreateInfo, VkT* outObject)
{
*outObject = VK_NULL_HANDLE;
size_t size = T::ComputeRequiredAllocationSize(pCreateInfo);
void* memory = nullptr;
if(size)
{
memory = vk::allocate(size, REQUIRED_MEMORY_ALIGNMENT, pAllocator, T::GetAllocationScope());
if(!memory)
{
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
}
auto object = new (pAllocator) T(pCreateInfo, memory);
if(!object)
{
vk::deallocate(memory, pAllocator);
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
*outObject = *object;
return VK_SUCCESS;
}
template<typename T, typename VkT>
class ObjectBase
{
public:
using VkType = VkT;
void destroy(const VkAllocationCallbacks* pAllocator) {} // Method defined by objects to delete their content, if necessary
void* operator new(size_t count, const VkAllocationCallbacks* pAllocator)
{
return vk::allocate(count, alignof(T), pAllocator, T::GetAllocationScope());
}
void operator delete(void* ptr, const VkAllocationCallbacks* pAllocator)
{
// Should never happen
ASSERT(false);
}
template<typename CreateInfo>
static VkResult Create(const VkAllocationCallbacks* pAllocator, const CreateInfo* pCreateInfo, VkT* outObject)
{
return vk::Create<T, VkT, CreateInfo>(pAllocator, pCreateInfo, outObject);
}
static constexpr VkSystemAllocationScope GetAllocationScope() { return VK_SYSTEM_ALLOCATION_SCOPE_OBJECT; }
protected:
// All derived classes should have deleted destructors
~ObjectBase() {}
};
template<typename T, typename VkT>
class Object : public ObjectBase<T, VkT>
{
public:
operator VkT()
{
return reinterpret_cast<VkT>(this);
}
};
template<typename T, typename VkT>
class DispatchableObject
{
VK_LOADER_DATA loaderData = { ICD_LOADER_MAGIC };
T object;
public:
static constexpr VkSystemAllocationScope GetAllocationScope() { return T::GetAllocationScope(); }
template<typename ...Args>
DispatchableObject(Args... args) : object(args...)
{
}
~DispatchableObject() = delete;
void destroy(const VkAllocationCallbacks* pAllocator)
{
object.destroy(pAllocator);
}
void* operator new(size_t count, const VkAllocationCallbacks* pAllocator)
{
return vk::allocate(count, alignof(T), pAllocator, T::GetAllocationScope());
}
void operator delete(void* ptr, const VkAllocationCallbacks* pAllocator)
{
// Should never happen
ASSERT(false);
}
template<typename CreateInfo>
static VkResult Create(const VkAllocationCallbacks* pAllocator, const CreateInfo* pCreateInfo, VkT* outObject)
{
return vk::Create<DispatchableObject<T, VkT>, VkT, CreateInfo>(pAllocator, pCreateInfo, outObject);
}
template<typename CreateInfo>
static size_t ComputeRequiredAllocationSize(const CreateInfo* pCreateInfo)
{
return T::ComputeRequiredAllocationSize(pCreateInfo);
}
static inline T* Cast(VkT vkObject)
{
return &(reinterpret_cast<DispatchableObject<T, VkT>*>(vkObject)->object);
}
operator VkT()
{
return reinterpret_cast<VkT>(this);
}
};
} // namespace vk
#endif // VK_OBJECT_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_PHYSICAL_DEVICE_HPP_
#define VK_PHYSICAL_DEVICE_HPP_
#include "VkObject.hpp"
namespace vk
{
class PhysicalDevice
{
public:
static constexpr VkSystemAllocationScope GetAllocationScope() { return VK_SYSTEM_ALLOCATION_SCOPE_DEVICE; }
PhysicalDevice(const void*, void* mem);
void destroy(const VkAllocationCallbacks* pAllocator) {}
static size_t ComputeRequiredAllocationSize(const void*) { return 0; }
const VkPhysicalDeviceFeatures& getFeatures() const;
bool hasFeatures(const VkPhysicalDeviceFeatures& requestedFeatures) const;
const VkPhysicalDeviceProperties& getProperties() const;
void getFormatProperties(VkFormat format, VkFormatProperties* pFormatProperties) const;
void getImageFormatProperties(VkFormat format, VkImageType type, VkImageTiling tiling,
VkImageUsageFlags usage, VkImageCreateFlags flags,
VkImageFormatProperties* pImageFormatProperties) const;
uint32_t getQueueFamilyPropertyCount() const;
void getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount,
VkQueueFamilyProperties* pQueueFamilyProperties) const;
const VkPhysicalDeviceMemoryProperties& getMemoryProperties() const;
private:
const VkPhysicalDeviceLimits& getLimits() const;
VkSampleCountFlags getSampleCounts() const;
};
using DispatchablePhysicalDevice = DispatchableObject<PhysicalDevice, VkPhysicalDevice>;
static inline PhysicalDevice* Cast(VkPhysicalDevice object)
{
return DispatchablePhysicalDevice::Cast(object);
}
} // namespace vk
#endif // VK_PHYSICAL_DEVICE_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.
#include "VkQueue.hpp"
namespace vk
{
Queue::Queue(uint32_t pFamilyIndex, float pPriority) : familyIndex(pFamilyIndex), priority(pPriority)
{
}
} // namespace vk
\ No newline at end of file
// 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_QUEUE_HPP_
#define VK_QUEUE_HPP_
#include "VkObject.hpp"
namespace vk
{
class Queue
{
VK_LOADER_DATA loaderData = { ICD_LOADER_MAGIC };
public:
Queue(uint32_t pFamilyIndex, float pPriority);
~Queue() = delete;
operator VkQueue()
{
return reinterpret_cast<VkQueue>(this);
}
private:
uint32_t familyIndex = 0;
float priority = 0.0f;
};
static inline Queue* Cast(VkQueue object)
{
return reinterpret_cast<Queue*>(object);
}
} // namespace vk
#endif // VK_QUEUE_HPP_
...@@ -171,6 +171,17 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor ...@@ -171,6 +171,17 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="libVulkan.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="VkCommandBuffer.cpp" />
<ClCompile Include="VkDebug.cpp" />
<ClCompile Include="VkDevice.cpp" />
<ClCompile Include="VkGetProcAddress.cpp" />
<ClCompile Include="VkInstance.cpp" />
<ClCompile Include="VkMemory.cpp" />
<ClCompile Include="VkPhysicalDevice.cpp" />
<ClCompile Include="VkPromotedExtensions.cpp" />
<ClCompile Include="VkQueue.cpp" />
<ClCompile Include="..\Device\Blitter.cpp" /> <ClCompile Include="..\Device\Blitter.cpp" />
<ClCompile Include="..\Device\Clipper.cpp" /> <ClCompile Include="..\Device\Clipper.cpp" />
<ClCompile Include="..\Device\Color.cpp" /> <ClCompile Include="..\Device\Color.cpp" />
...@@ -253,13 +264,19 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor ...@@ -253,13 +264,19 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="libVulkan.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="VkDebug.cpp" />
<ClCompile Include="VkGetProcAddress.cpp" />
<ClCompile Include="VkPromotedExtensions.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="resource.h" />
<ClInclude Include="VkCommandBuffer.hpp" />
<ClInclude Include="VkConfig.h" />
<ClInclude Include="VkDebug.hpp" />
<ClInclude Include="VkDevice.hpp" />
<ClInclude Include="VkGetProcAddress.h" />
<ClInclude Include="VkInstance.hpp" />
<ClInclude Include="VkMemory.h" />
<ClInclude Include="VkObject.hpp" />
<ClInclude Include="VkPhysicalDevice.hpp" />
<ClInclude Include="VkQueue.hpp" />
<ClInclude Include="..\Device\Blitter.hpp" /> <ClInclude Include="..\Device\Blitter.hpp" />
<ClInclude Include="..\Device\Clipper.hpp" /> <ClInclude Include="..\Device\Clipper.hpp" />
<ClInclude Include="..\Device\Color.hpp" /> <ClInclude Include="..\Device\Color.hpp" />
...@@ -359,9 +376,6 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor ...@@ -359,9 +376,6 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude> </ClInclude>
<ClInclude Include="VkDebug.hpp" />
<ClInclude Include="resource.h" />
<ClInclude Include="VkGetProcAddress.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\WSI\FrameBufferOSX.mm"> <None Include="..\WSI\FrameBufferOSX.mm">
......
...@@ -22,6 +22,12 @@ ...@@ -22,6 +22,12 @@
<Filter Include="Header Files\Pipeline"> <Filter Include="Header Files\Pipeline">
<UniqueIdentifier>{ab31f9cb-85bf-4ad3-8ee0-1810977a5944}</UniqueIdentifier> <UniqueIdentifier>{ab31f9cb-85bf-4ad3-8ee0-1810977a5944}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Header Files\Vulkan">
<UniqueIdentifier>{eae937f9-88b4-4bd4-ba7b-bb4a4dcdaf52}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Device">
<UniqueIdentifier>{31e80f94-e9d4-42cf-97b1-58bda4d1ab31}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\System"> <Filter Include="Source Files\System">
<UniqueIdentifier>{c9884906-cd72-4adb-9641-d72660051aa3}</UniqueIdentifier> <UniqueIdentifier>{c9884906-cd72-4adb-9641-d72660051aa3}</UniqueIdentifier>
</Filter> </Filter>
...@@ -37,29 +43,8 @@ ...@@ -37,29 +43,8 @@
<Filter Include="Source Files\Device"> <Filter Include="Source Files\Device">
<UniqueIdentifier>{3fd774af-dfbe-40e2-9944-a85206cf00ee}</UniqueIdentifier> <UniqueIdentifier>{3fd774af-dfbe-40e2-9944-a85206cf00ee}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Header Files\Vulkan">
<UniqueIdentifier>{eae937f9-88b4-4bd4-ba7b-bb4a4dcdaf52}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Device">
<UniqueIdentifier>{31e80f94-e9d4-42cf-97b1-58bda4d1ab31}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="libVulkan.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="VkDebug.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="VkGetProcAddress.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="VkPromotedExtensions.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="..\Device\VertexProcessor.cpp"> <ClCompile Include="..\Device\VertexProcessor.cpp">
<Filter>Source Files\Device</Filter> <Filter>Source Files\Device</Filter>
</ClCompile> </ClCompile>
...@@ -216,17 +201,71 @@ ...@@ -216,17 +201,71 @@
<ClCompile Include="..\System\Timer.cpp"> <ClCompile Include="..\System\Timer.cpp">
<Filter>Source Files\System</Filter> <Filter>Source Files\System</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="libVulkan.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="VkCommandBuffer.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="VkDebug.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="VkDevice.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="VkGetProcAddress.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="VkInstance.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="VkMemory.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="VkPhysicalDevice.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="VkPromotedExtensions.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
<ClCompile Include="VkQueue.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="resource.h"> <ClInclude Include="resource.h">
<Filter>Header Files\Vulkan</Filter> <Filter>Header Files\Vulkan</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="VkDebug.hpp"> <ClInclude Include="VkCommandBuffer.hpp">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
<ClInclude Include="VkConfig.h">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
<ClInclude Include="VkDevice.hpp">
<Filter>Header Files\Vulkan</Filter> <Filter>Header Files\Vulkan</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="VkGetProcAddress.h"> <ClInclude Include="VkGetProcAddress.h">
<Filter>Header Files\Vulkan</Filter> <Filter>Header Files\Vulkan</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="VkInstance.hpp">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
<ClInclude Include="VkMemory.h">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
<ClInclude Include="VkObject.hpp">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
<ClInclude Include="VkPhysicalDevice.hpp">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
<ClInclude Include="VkQueue.hpp">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
<ClInclude Include="..\Device\VertexProcessor.hpp"> <ClInclude Include="..\Device\VertexProcessor.hpp">
<Filter>Header Files\Device</Filter> <Filter>Header Files\Device</Filter>
</ClInclude> </ClInclude>
...@@ -419,6 +458,9 @@ ...@@ -419,6 +458,9 @@
<ClInclude Include="..\System\Types.hpp"> <ClInclude Include="..\System\Types.hpp">
<Filter>Header Files\System</Filter> <Filter>Header Files\System</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="VkDebug.hpp">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="swiftshader_icd.def" /> <None Include="swiftshader_icd.def" />
......
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