Skip to content

Commit

Permalink
Fix for vkGet{Buffer,Image}MemoryRequirements2KHR
Browse files Browse the repository at this point in the history
  • Loading branch information
AWoloszyn committed Apr 19, 2018
1 parent 1a4f085 commit 079b7a9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
6 changes: 6 additions & 0 deletions gapil/resolver/inference.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ func lhsToObserved(rv *resolver, lhs semantic.Node) semantic.Expression {
return nil
}
return &semantic.MapIndex{Map: o, Index: lhs.Index, Type: lhs.Type}
case *semantic.Cast:
o := lhsToObserved(rv, lhs.Object)
if o == nil {
return nil
}
return &semantic.Cast{Object: lhs.Object, Type: lhs.Type}
case *semantic.Parameter:
if f := rv.scope.function; f != nil && f.Subroutine && lhs == f.Return {
rv.errorf(lhs, "unknowns cannot be used to infer return values in subroutines")
Expand Down
35 changes: 28 additions & 7 deletions gapis/api/vulkan/vulkan.api
Original file line number Diff line number Diff line change
Expand Up @@ -3191,8 +3191,17 @@ cmd void vkGetImageMemoryRequirements2KHR(
VkMemoryRequirements2KHR* pMemoryRequirements) {
if !(device in Devices) { vkErrorInvalidDevice(device) }
info := pInfo[0]
// TODO: handle pNext for 'info'
memReqs := pMemoryRequirements[0]
if memReqs.pNext != null {
nPNext := numberOfPNext(as!const void*(memReqs.pNext))
next := MutableVoidPtr(as!void*(memReqs.pNext))
for i in (0 .. nPNext) {
_ = as!const VkStructureType*(next.Ptr)[0]
next.Ptr = as!VulkanStructHeader*(next.Ptr)[0].PNext
}
}

// TODO: handle pNext for 'info'
fence

if pMemoryRequirements == null { vkErrorNullPointer("VkMemoryRequirements2KHR") }
Expand All @@ -3208,17 +3217,18 @@ cmd void vkGetImageMemoryRequirements2KHR(
numPNext := numberOfPNext(as!const void*(memReq.pNext))
next := MutableVoidPtr(as!void*(memReq.pNext))
for i in (0 .. numPNext) {
sType := as!const VkStructureType*(next.Ptr)[0:1][0]
sType := as!const VkStructureType*(next.Ptr)[0]
switch sType {
case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR: {
ext := as!VkMemoryDedicatedRequirementsKHR*(next.Ptr)[0:1][0]
ext := as!VkMemoryDedicatedRequirementsKHR(?)
Images[info.image].DedicatedRequirementsKHR = new!DedicatedRequirementsKHR(
PrefersDedicatedAllocation: ext.prefersDedicatedAllocation,
RequiresDedicatedAllocation: ext.requiresDedicatedAllocation,
)
as!VkMemoryDedicatedRequirementsKHR*(next.Ptr)[0] = ext
}
}
next.Ptr = as!VulkanStructHeader*(next.Ptr)[0:1][0].PNext
next.Ptr = as!VulkanStructHeader*(next.Ptr)[0].PNext
}
}
}
Expand All @@ -3233,6 +3243,16 @@ cmd void vkGetBufferMemoryRequirements2KHR(
info := pInfo[0]
// TODO: handle pNext

memReqs := pMemoryRequirements[0]
if memReqs.pNext != null {
nPNext := numberOfPNext(as!const void*(memReqs.pNext))
next := MutableVoidPtr(as!void*(memReqs.pNext))
for i in (0 .. nPNext) {
_ = as!const VkStructureType*(next.Ptr)[0]
next.Ptr = as!VulkanStructHeader*(next.Ptr)[0].PNext
}
}

fence

if pMemoryRequirements == null { vkErrorNullPointer("VkMemoryRequirements2KHR") }
Expand All @@ -3248,17 +3268,18 @@ cmd void vkGetBufferMemoryRequirements2KHR(
numPNext := numberOfPNext(as!const void*(memReq.pNext))
next := MutableVoidPtr(as!void*(memReq.pNext))
for i in (0 .. numPNext) {
sType := as!const VkStructureType*(next.Ptr)[0:1][0]
sType := as!const VkStructureType*(next.Ptr)[0]
switch sType {
case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR: {
ext := as!VkMemoryDedicatedRequirementsKHR*(next.Ptr)[0:1][0]
ext := as!VkMemoryDedicatedRequirementsKHR(?)
Buffers[info.buffer].DedicatedRequirementsKHR = new!DedicatedRequirementsKHR(
PrefersDedicatedAllocation: ext.prefersDedicatedAllocation,
RequiresDedicatedAllocation: ext.requiresDedicatedAllocation,
)
as!VkMemoryDedicatedRequirementsKHR*(next.Ptr)[0] = ext
}
}
next.Ptr = as!VulkanStructHeader*(next.Ptr)[0:1][0].PNext
next.Ptr = as!VulkanStructHeader*(next.Ptr)[0].PNext
}
}
}
Expand Down

0 comments on commit 079b7a9

Please sign in to comment.