Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan: A list of low hang extensions toward Vulkan 1.1 support #2485

Merged
merged 1 commit into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions gapil/template/constant_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ func buildConstantSets(api *semantic.API, mappings *semantic.Mappings) *Constant
if !ok {
panic(fmt.Sprintf("Unsupported enum number type: %v", e.NumberType))
}
if l, ok := labels[value]; ok {
panic(fmt.Sprintf("Enum %v has multiple labels for value %v: %v, %v",
e.Named, value, l, entry.Named))
}
// In cases a constant value has multiple labels (multiple
// labels defining the same constant value in the same enum),
// the last label will be adopted as the name of the constant
// value.
labels[value] = string(entry.Named)
}
constsets[e] = b.addLabels(labels, e.IsBitfield)
Expand Down
5 changes: 5 additions & 0 deletions gapis/api/vulkan/api/bitfields.api
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ bitfield VkFormatFeatureFlagBits {
VK_FORMAT_FEATURE_BLIT_DST_BIT = 0x00000800, /// Format can be used as the destination image of blits with vkCommandBlitImage
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT = 0x00001000,
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG = 0x00002000,
//@extension("VK_KHR_maintenance1")
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR = 0x00004000,
VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR = 0x00008000,
// Vulkan 1.1 core
Expand Down Expand Up @@ -94,6 +95,10 @@ bitfield VkImageCreateFlagBits {
VK_IMAGE_CREATE_SPARSE_ALIASED_BIT = 0x00000004, /// Image should support constent data access to physical memory blocks mapped into multiple locations of sparse images
VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT = 0x00000008, /// Allows image views to have different format than the base image
VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT = 0x00000010, /// Allows creating image views with cube type from the created image

//@extension("VK_KHR_maintenance1")
VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR = 0x00000020,

// Vulkan 1.1 core
VK_IMAGE_CREATE_ALIAS_BIT = 0x00000400,
VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT = 0x00000040,
Expand Down
79 changes: 68 additions & 11 deletions gapis/api/vulkan/api/buffer.api
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
@untracked @unused ref!QueueObject LastBoundQueue
@unused ref!VulkanDebugMarkerInfo DebugInfo
VkMemoryRequirements MemoryRequirements
// Vulkan 1.1 promoted from extension: VK_KHR_dedicated_allocation
ref!DedicatedRequirements DedicatedRequirements
}

Expand Down Expand Up @@ -238,24 +239,80 @@ cmd void vkDestroyBufferView(
}
}

sub void BindBufferMemory(
VkBuffer buffer,
VkDeviceMemory memory,
VkDeviceSize memoryOffset) {
if !(memory in DeviceMemories) {
vkErrorInvalidDeviceMemory(memory)
} else {
if !(buffer in Buffers) {
vkErrorInvalidBuffer(buffer)
} else {
Buffers[buffer].Memory = DeviceMemories[memory]
Buffers[buffer].MemoryOffset = memoryOffset
DeviceMemories[memory].BoundObjects[as!u64(buffer)] = memoryOffset
if (Buffers[buffer].Info.DedicatedAllocationNV != null) && (DeviceMemories[memory].DedicatedAllocationNV == null) {
vkErrorExpectNVDedicatedlyAllocatedHandle("VkBuffer", as!u64(buffer))
}
if (Buffers[buffer].Info.DedicatedAllocationNV == null) && (DeviceMemories[memory].DedicatedAllocationNV != null) {
vkErrorExpectNVDedicatedlyAllocatedHandle("VkDeviceMemory", as!u64(memory))
}
}
}
}

@indirect("VkDevice")
cmd VkResult vkBindBufferMemory(
VkDevice device,
VkBuffer buffer,
VkDeviceMemory memory,
VkDeviceSize memoryOffset) {
if !(device in Devices) { vkErrorInvalidDevice(device) }
if !(memory in DeviceMemories) { vkErrorInvalidDeviceMemory(memory) }
if !(buffer in Buffers) { vkErrorInvalidBuffer(buffer) }
Buffers[buffer].Memory = DeviceMemories[memory]
Buffers[buffer].MemoryOffset = memoryOffset
DeviceMemories[memory].BoundObjects[as!u64(buffer)] = memoryOffset
if (Buffers[buffer].Info.DedicatedAllocationNV != null) && (DeviceMemories[memory].DedicatedAllocationNV == null) {
vkErrorExpectNVDedicatedlyAllocatedHandle("VkBuffer", as!u64(buffer))
}
if (Buffers[buffer].Info.DedicatedAllocationNV == null) && (DeviceMemories[memory].DedicatedAllocationNV != null) {
vkErrorExpectNVDedicatedlyAllocatedHandle("VkDeviceMemory", as!u64(memory))
}
BindBufferMemory(buffer, memory, memoryOffset)
return ?
}

// ----------------------------------------------------------------------------
// Vulkan 1.1 Commands
// ----------------------------------------------------------------------------

////////////
// Buffer //
////////////

sub void BindBufferMemory2(
VkDevice device,
u32 bindInfoCount,
const VkBindBufferMemoryInfo* pBindInfos) {
if !(device in Devices) { vkErrorInvalidDevice(device) }
if pBindInfos == null {
vkErrorNullPointer("VkBindBufferMemoryInfo(KHR)")
} else {
infos := pBindInfos[0:bindInfoCount]
for i in (0 .. bindInfoCount) {
info := infos[i]
// handle pNext
if info.pNext != null {
numPNext := numberOfPNext(info.pNext)
next := MutableVoidPtr(as!void*(info.pNext))
for i in (0 .. numPNext) {
sType := as!const VkStructureType*(next.Ptr)[0:1][0]
_ = sType
// TODO: handle extensions for VkBindBufferMemoryInfo
next.Ptr = as!VulkanStructHeader*(next.Ptr)[0:1][0].PNext
}
}
BindBufferMemory(info.buffer, info.memory, info.memoryOffset)
}
}
}

@indirect("VkDevice")
cmd VkResult vkBindBufferMemory2(
VkDevice device,
u32 bindInfoCount,
const VkBindBufferMemoryInfo* pBindInfos) {
BindBufferMemory2(device, bindInfoCount, pBindInfos)
return ?
}
35 changes: 34 additions & 1 deletion gapis/api/vulkan/api/device.api
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
@unused VkPhysicalDeviceFeatures EnabledFeatures
@unused VkDevice VulkanHandle
@unused ref!VulkanDebugMarkerInfo DebugInfo

// Vulkan 1.1
@unused ref!VariablePointerFeatures VariablePointerFeatures
@unused ref!HalfPrecisionStorageFeatures HalfPrecisionStorageFeatures
}

@indirect("VkDevice")
Expand Down Expand Up @@ -135,7 +139,24 @@ sub ref!DeviceObject createDeviceObject(const VkDeviceCreateInfo* data) {
next := MutableVoidPtr(as!void*(info.pNext))
for i in (0 .. numPNext) {
sType := as!const VkStructureType*(next.Ptr)[0:1][0]
_ = sType
switch sType {
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES: {
ext := as!VkPhysicalDeviceVariablePointerFeatures*(next.Ptr)[0]
object.VariablePointerFeatures = new!VariablePointerFeatures(
VariablePointerStorageBuffer: ext.variablePointersStorageBuffer,
VariablePointers: ext.variablePointers)
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES: {
ext := as!VkPhysicalDevice16BitStorageFeatures*(next.Ptr)[0]
object.HalfPrecisionStorageFeatures = new!HalfPrecisionStorageFeatures(StorageBuffer16BitAccess: ext.storageBuffer16BitAccess,
UniformAndStorageBuffer16BitAccess: ext.uniformAndStorageBuffer16BitAccess,
StoragePushConstant16: ext.storagePushConstant16,
StorageInputOutput16: ext.storageInputOutput16)
}
default: {
// do nothing
}
}
// TODO: handle extensions for VkDeviceCreateInfo
next.Ptr = as!VulkanStructHeader*(next.Ptr)[0:1][0].PNext
}
Expand Down Expand Up @@ -185,3 +206,15 @@ sub ref!DeviceObject createDeviceObject(const VkDeviceCreateInfo* data) {

return object
}

@internal class VariablePointerFeatures {
VkBool32 VariablePointerStorageBuffer
VkBool32 VariablePointers
}

@internal class HalfPrecisionStorageFeatures{
VkBool32 StorageBuffer16BitAccess
VkBool32 UniformAndStorageBuffer16BitAccess
VkBool32 StoragePushConstant16
VkBool32 StorageInputOutput16
}
14 changes: 14 additions & 0 deletions gapis/api/vulkan/api/enums.api
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ enum VkResult {
//@extension("VK_EXT_debug_report")
VK_ERROR_VALIDATION_FAILED_EXT = 0xC4650B07, // -1000011001

//@extension("VK_NV_glsl_shader")
VK_ERROR_INVALID_SHADER_NV = 0x3B9AF8E0, // -1000012000

//@extension("VK_KHR_maintenance1")
VK_ERROR_OUT_OF_POOL_MEMORY_KHR = 0xC4642878, // -1000069000

// Vulkan 1.1 core
VK_ERROR_OUT_OF_POOL_MEMORY = 0xC4642878, // -1000069000
VK_ERROR_INVALID_EXTERNAL_HANDLE = 0xC4641CBD, // -1000072003
Expand Down Expand Up @@ -215,6 +219,16 @@ enum VkStructureType {
VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR = 1000119001,
VK_STRUCTURE_TYPE_SURFACE_FORMAT_2_KHR = 1000119002,

//@extension("VK_KHR_bind_memory2")
VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO_KHR = 1000157000,
VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO_KHR = 1000157001,

//@extension("VK_KHR_variable_pointers")
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES_KHR = 1000120000,

//@extension("VK_KHR_16bit_storage")
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR = 1000083000,

// Vulkan 1.1 core
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES = 1000094000,
VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO = 1000157000,
Expand Down
Loading