Skip to content

Commit

Permalink
Add extensions, fix some const issues and case issues.
Browse files Browse the repository at this point in the history
Based on google#2463
  • Loading branch information
AWoloszyn committed May 31, 2019
1 parent ea07433 commit fd11b07
Show file tree
Hide file tree
Showing 20 changed files with 514 additions and 62 deletions.
4 changes: 2 additions & 2 deletions gapii/cc/vulkan_extras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ bool VulkanSpy::observeFramebuffer(CallObserver* observer, uint32_t* w,
return false;
}
image = mState.LastPresentInfo.mPresentImages[0];
*w = image->mInfo.mExtent.mWidth;
*h = image->mInfo.mExtent.mHeight;
*w = image->mInfo.mExtent.mwidth;
*h = image->mInfo.mExtent.mheight;
// Swapchain images have only one miplevel.
frame_buffer_img_level = 0;
// There might be more than one array layers for swapchain images,
Expand Down
38 changes: 33 additions & 5 deletions gapii/cc/vulkan_extras.inc
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,52 @@ uint32_t SpyOverride_vkCreateSwapchainKHR(VkDevice device,
const VkAllocationCallbacks* pAllocator,
VkSwapchainKHR* pImage);
uint32_t SpyOverride_vkDebugMarkerSetObjectTagEXT(
VkDevice device, VkDebugMarkerObjectTagInfoEXT* pTagInfo) {
VkDevice device, const VkDebugMarkerObjectTagInfoEXT* pTagInfo) {
return VkResult::VK_SUCCESS;
}
uint32_t SpyOverride_RecreateDebugMarkerSetObjectTagEXT(
VkDevice device, VkDebugMarkerObjectTagInfoEXT* pTagInfo) {
VkDevice device, const VkDebugMarkerObjectTagInfoEXT* pTagInfo) {
return VkResult::VK_SUCCESS;
}

uint32_t SpyOverride_vkDebugMarkerSetObjectNameEXT(
VkDevice device, VkDebugMarkerObjectNameInfoEXT* pNameInfo) {
VkDevice device, const VkDebugMarkerObjectNameInfoEXT* pNameInfo) {
return VkResult::VK_SUCCESS;
}

void SpyOverride_vkCmdDebugMarkerBeginEXT(
VkCommandBuffer commandBuffer, VkDebugMarkerMarkerInfoEXT* pMarkerInfo) {}
VkCommandBuffer commandBuffer, const VkDebugMarkerMarkerInfoEXT* pMarkerInfo) {}
void SpyOverride_vkCmdDebugMarkerEndEXT(VkCommandBuffer commandBuffer) {}
void SpyOverride_vkCmdDebugMarkerInsertEXT(
VkCommandBuffer commandBuffer, VkDebugMarkerMarkerInfoEXT* pMarkerInfo) {}
VkCommandBuffer commandBuffer, const VkDebugMarkerMarkerInfoEXT* pMarkerInfo) {}


void SpyOverride_vkCmdBeginDebugUtilsLabelEXT(
VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT* pMarkerInfo) {}
void SpyOverride_vkCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer) {}
void SpyOverride_vkCmdInsertDebugUtilsLabelEXT(
VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT* pMarkerInfo) {}


void SpyOverride_vkQueueBeginDebugUtilsLabelEXT(
VkQueue queue, const VkDebugUtilsLabelEXT* pMarkerInfo) {}
void SpyOverride_vkQueueEndDebugUtilsLabelEXT(VkQueue queue) {}
void SpyOverride_vkQueueInsertDebugUtilsLabelEXT(
VkQueue queue, const VkDebugUtilsLabelEXT* pMarkerInfo) {}


uint32_t SpyOverride_vkSetDebugUtilsObjectNameEXT(
VkDevice device, const VkDebugUtilsObjectNameInfoEXT* pNameInfo) {
return VkResult::VK_SUCCESS;
}
uint32_t SpyOverride_vkSetDebugUtilsObjectTagEXT(
VkDevice device, const VkDebugUtilsObjectTagInfoEXT* pTagInfo) {
return VkResult::VK_SUCCESS;
}

void SpyOverride_vkCmdWriteBufferMarkerAMD(
VkCommandBuffer commandBuffer, uint32_t pipelineStage,
VkBuffer dstBuffer, VkDeviceSize dstOffset, uint32_t marker) {}

bool m_coherent_memory_tracking_enabled = false;

Expand Down
18 changes: 9 additions & 9 deletions gapii/cc/vulkan_mid_execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,10 @@ void VulkanSpy::serializeGPUBuffers(StateSerializer *serializer) {
elementAndTexelBlockSize.mTexelBlockSize.mHeight;

const uint32_t width =
subGetMipSize(nullptr, nullptr, info.mExtent.mWidth, level) /
subGetMipSize(nullptr, nullptr, info.mExtent.mwidth, level) /
divisor.mWidth;
const uint32_t height =
subGetMipSize(nullptr, nullptr, info.mExtent.mHeight, level) /
subGetMipSize(nullptr, nullptr, info.mExtent.mheight, level) /
divisor.mHeight;
const uint32_t width_in_blocks =
subRoundUpTo(nullptr, nullptr, width, texel_width);
Expand Down Expand Up @@ -517,10 +517,10 @@ void VulkanSpy::serializeGPUBuffers(StateSerializer *serializer) {
elementAndTexelBlockSize.mTexelBlockSize.mHeight;

const uint32_t width_in_blocks =
subRoundUpTo(nullptr, nullptr, extent.mWidth, texel_width) /
subRoundUpTo(nullptr, nullptr, extent.mwidth, texel_width) /
divisor.mWidth;
const uint32_t height_in_blocks =
subRoundUpTo(nullptr, nullptr, extent.mHeight, texel_height) /
subRoundUpTo(nullptr, nullptr, extent.mheight, texel_height) /
divisor.mHeight;
const uint32_t element_size = get_element_size(format, aspect_bit, false);

Expand Down Expand Up @@ -560,13 +560,13 @@ void VulkanSpy::serializeGPUBuffers(StateSerializer *serializer) {
const uint32_t texel_height =
elementAndTexelBlockSize.mTexelBlockSize.mHeight;
const uint32_t width =
subGetMipSize(nullptr, nullptr, extent.mWidth, mip_level) /
subGetMipSize(nullptr, nullptr, extent.mwidth, mip_level) /
divisor.mWidth;
const uint32_t height =
subGetMipSize(nullptr, nullptr, extent.mHeight, mip_level) /
subGetMipSize(nullptr, nullptr, extent.mheight, mip_level) /
divisor.mHeight;
const uint32_t depth =
subGetMipSize(nullptr, nullptr, extent.mDepth, mip_level);
subGetMipSize(nullptr, nullptr, extent.mdepth, mip_level);
const uint32_t width_in_blocks =
subRoundUpTo(nullptr, nullptr, width, texel_width);
const uint32_t height_in_blocks =
Expand Down Expand Up @@ -965,9 +965,9 @@ void VulkanSpy::serializeGPUBuffers(StateSerializer *serializer) {
// larger row pitch and depth pitch
pitch ep =
extent_pitch(copy.mimageExtent, img->mInfo.mFormat, aspect_bit);
for (uint32_t zd = 0; zd < copy.mimageExtent.mDepth; zd++) {
for (uint32_t zd = 0; zd < copy.mimageExtent.mdepth; zd++) {
for (uint32_t yd = 0;
yd < subRoundUpTo(nullptr, nullptr, copy.mimageExtent.mHeight,
yd < subRoundUpTo(nullptr, nullptr, copy.mimageExtent.mheight,
bp.texel_height);
yd++) {
uint32_t x =
Expand Down
4 changes: 2 additions & 2 deletions gapis/api/templates/vulkan_gfx_api_extras.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ bool Vulkan::replayCreateVkDeviceImpl(Stack* stack, size_val physicalDevice,
target = gapir::SurfaceType::Win32;
}

const void* data = CreateSurface(newCreateInfo.imageExtent.Width,
newCreateInfo.imageExtent.Height, target);
const void* data = CreateSurface(newCreateInfo.imageExtent.width,
newCreateInfo.imageExtent.height, target);
void* createInfo = nullptr;
if (data != nullptr) {
switch (target) {
Expand Down
9 changes: 9 additions & 0 deletions gapis/api/vulkan/api/command_buffer_control.api
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ enum CommandType {
cmd_vkCmdDrawIndexedIndirectCountKHR = 48,
cmd_vkCmdDrawIndirectCountAMD = 49,
cmd_vkCmdDrawIndexedIndirectCountAMD = 50,
cmd_vkCmdBeginDebugUtilsLabelEXT = 51,
cmd_vkCmdEndDebugUtilsLabelEXT = 52,
cmd_vkCmdInsertDebugUtilsLabelEXT = 53,
cmd_vkNoCommand = 0xFFFFFFFF
}

Expand Down Expand Up @@ -265,6 +268,9 @@ enum SemaphoreUpdate {
@untrackedMap dense_map!(u32, ref!vkCmdDrawIndexedIndirectCountKHRArgs) vkCmdDrawIndexedIndirectCountKHR
@untrackedMap dense_map!(u32, ref!vkCmdDrawIndirectCountAMDArgs) vkCmdDrawIndirectCountAMD
@untrackedMap dense_map!(u32, ref!vkCmdDrawIndexedIndirectCountAMDArgs) vkCmdDrawIndexedIndirectCountAMD
@untrackedMap dense_map!(u32, ref!vkCmdBeginDebugUtilsLabelEXTArgs) vkCmdBeginDebugUtilsLabelEXT
@untrackedMap dense_map!(u32, ref!vkCmdEndDebugUtilsLabelEXTArgs) vkCmdEndDebugUtilsLabelEXT
@untrackedMap dense_map!(u32, ref!vkCmdInsertDebugUtilsLabelEXTArgs) vkCmdInsertDebugUtilsLabelEXT
}

@internal class CommandBufferObject {
Expand Down Expand Up @@ -517,6 +523,9 @@ sub void resetBufferCommands(ref!CommandBufferObject obj) {
clear(obj.BufferCommands.vkCmdDrawIndexedIndirectCountKHR)
clear(obj.BufferCommands.vkCmdDrawIndirectCountAMD)
clear(obj.BufferCommands.vkCmdDrawIndexedIndirectCountAMD)
clear(obj.BufferCommands.vkCmdBeginDebugUtilsLabelEXT)
clear(obj.BufferCommands.vkCmdEndDebugUtilsLabelEXT)
clear(obj.BufferCommands.vkCmdInsertDebugUtilsLabelEXT)
}

sub void resetCommandBuffer(ref!CommandBufferObject obj) {
Expand Down
24 changes: 12 additions & 12 deletions gapis/api/vulkan/api/copy_clear_commands.api
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,14 @@ sub void trackVkCmdCopyImage(ref!vkCmdCopyImageArgs args) {
dstYStartInBlocks := as!u64(as!u64(region.dstOffset.y) / dstBlockHeight)
dstZStart := as!u64(region.dstOffset.z)

extentXInBlocks := roundUpTo(region.extent.Width, as!u32(srcBlockWidth))
extentYInBlocks := roundUpTo(region.extent.Height, as!u32(srcBlockHeight))
extentZ := region.extent.Depth
extentXInBlocks := roundUpTo(region.extent.width, as!u32(srcBlockWidth))
extentYInBlocks := roundUpTo(region.extent.height, as!u32(srcBlockHeight))
extentZ := region.extent.depth

srcImageLevelWidthInBlocks := as!u64(roundUpTo(getMipSize(srcImageObject.Info.Extent.Width, srcMipLevel), as!u32(srcBlockWidth)))
srcImageLevelHeightInBlocks := as!u64(roundUpTo(getMipSize(srcImageObject.Info.Extent.Height, srcMipLevel), as!u32(srcBlockHeight)))
dstImageLevelWidthInBlocks := as!u64(roundUpTo(getMipSize(dstImageObject.Info.Extent.Width, dstMipLevel), as!u32(dstBlockWidth)))
dstImageLevelHeightInBlocks := as!u64(roundUpTo(getMipSize(dstImageObject.Info.Extent.Height, dstMipLevel), as!u32(dstBlockHeight)))
srcImageLevelWidthInBlocks := as!u64(roundUpTo(getMipSize(srcImageObject.Info.Extent.width, srcMipLevel), as!u32(srcBlockWidth)))
srcImageLevelHeightInBlocks := as!u64(roundUpTo(getMipSize(srcImageObject.Info.Extent.height, srcMipLevel), as!u32(srcBlockHeight)))
dstImageLevelWidthInBlocks := as!u64(roundUpTo(getMipSize(dstImageObject.Info.Extent.width, dstMipLevel), as!u32(dstBlockWidth)))
dstImageLevelHeightInBlocks := as!u64(roundUpTo(getMipSize(dstImageObject.Info.Extent.height, dstMipLevel), as!u32(dstBlockHeight)))

minLayerCount := min!u32(region.srcSubresource.layerCount, region.dstSubresource.layerCount)
maxLayerCount := max!u32(region.srcSubresource.layerCount, region.dstSubresource.layerCount)
Expand Down Expand Up @@ -562,11 +562,11 @@ class RowLengthAndImageHeight {

sub RowLengthAndImageHeight getRowLengthAndImageHeight(VkBufferImageCopy region) {
rowLength := switch region.bufferRowLength == 0 {
case true: region.imageExtent.Width
case true: region.imageExtent.width
case false: region.bufferRowLength
}
imageHeight := switch region.bufferImageHeight == 0 {
case true: region.imageExtent.Height
case true: region.imageExtent.height
case false: region.bufferImageHeight
}
return RowLengthAndImageHeight(rowLength, imageHeight)
Expand Down Expand Up @@ -605,11 +605,11 @@ sub void copyImageBuffer(VkBuffer buffer, VkImage image, VkImageLayout layout, m
imageHeight := (as!u64(rowLengthAndImageHeight.ImageHeight / elementAndTexelBlockSize.TexelBlockSize.Height))
layerSize := rowLength * imageHeight * elementSize
zStart := as!u64(region.imageOffset.z)
zEnd := zStart + as!u64(region.imageExtent.Depth)
zEnd := zStart + as!u64(region.imageExtent.depth)
yStart := as!u64(as!u32(region.imageOffset.y) / elementAndTexelBlockSize.TexelBlockSize.Height)
yEnd := yStart + as!u64(region.imageExtent.Height / elementAndTexelBlockSize.TexelBlockSize.Height)
yEnd := yStart + as!u64(region.imageExtent.height / elementAndTexelBlockSize.TexelBlockSize.Height)
xStart := as!u64(as!u32(region.imageOffset.x) / elementAndTexelBlockSize.TexelBlockSize.Width)
xEnd := xStart + as!u64(region.imageExtent.Width / elementAndTexelBlockSize.TexelBlockSize.Width)
xEnd := xStart + as!u64(region.imageExtent.width / elementAndTexelBlockSize.TexelBlockSize.Width)
// When multiple layers are specified in the buffer image copy region,
// Vulkan assumes the data of all the layers are placed continuously in
// the source buffer memory.
Expand Down
5 changes: 5 additions & 0 deletions gapis/api/vulkan/api/enums.api
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ enum VkStructureType {
VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_TAG_INFO_EXT = 1000022001
VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT = 1000022002

//@extension("VK_EXT_debug_utils")
VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT = 1000128000,
VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_TAG_INFO_EXT = 1000128001,
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT = 1000128002,

//@extension("VK_NV_dedicated_allocation")
VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV = 1000026000,
VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV = 1000026001,
Expand Down
6 changes: 3 additions & 3 deletions gapis/api/vulkan/api/image.api
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ cmd VkResult vkCreateImage(
for j in (0 .. info.arrayLayers) {
aspect.Layers[j] = new!ImageLayer()
for i in (0 .. info.mipLevels) {
width := getMipSize(info.extent.Width, i) / divisor.Width
height := getMipSize(info.extent.Height, i) / divisor.Height
depth := getMipSize(info.extent.Depth, i)
width := getMipSize(info.extent.width, i) / divisor.Width
height := getMipSize(info.extent.height, i) / divisor.Height
depth := getMipSize(info.extent.depth, i)
level := new!ImageLevel(
Width: width,
Height: height,
Expand Down
20 changes: 10 additions & 10 deletions gapis/api/vulkan/api/queue.api
Original file line number Diff line number Diff line change
Expand Up @@ -263,22 +263,22 @@ sub void addSparseImageMemoryBinding(VkImage image, VkSparseImageMemoryBind bind
blockSize := getImagePlaneMemoryInfo(img, as!VkImageAspectFlagBits(0)).MemoryRequirements.alignment
if (aspect in img.SparseMemoryRequirements) {
gran := img.SparseMemoryRequirements[aspect].formatProperties.imageGranularity
mipWidth := getMipSize(img.Info.Extent.Width, level)
mipHeight := getMipSize(img.Info.Extent.Height, level)
widthInBlocks := roundUpTo(mipWidth, gran.Width)
heightInBlocks := roundUpTo(mipHeight, gran.Height)
mipWidth := getMipSize(img.Info.Extent.width, level)
mipHeight := getMipSize(img.Info.Extent.height, level)
widthInBlocks := roundUpTo(mipWidth, gran.width)
heightInBlocks := roundUpTo(mipHeight, gran.height)

xe := roundUpTo(bind.extent.Width, gran.Width)
ye := roundUpTo(bind.extent.Height, gran.Height)
ze := roundUpTo(bind.extent.Depth, gran.Depth)
xe := roundUpTo(bind.extent.width, gran.width)
ye := roundUpTo(bind.extent.height, gran.height)
ze := roundUpTo(bind.extent.depth, gran.depth)
for zi in (0 .. ze) {
for yi in (0 .. ye) {
for xi in (0 .. xe) {
loc := xi + yi * widthInBlocks + zi * widthInBlocks * heightInBlocks
offset := VkOffset3D(
x: bind.offset.x + as!s32(xi * gran.Width),
y: bind.offset.y + as!s32(yi * gran.Height),
z: bind.offset.z + as!s32(zi * gran.Depth),
x: bind.offset.x + as!s32(xi * gran.width),
y: bind.offset.y + as!s32(yi * gran.height),
z: bind.offset.z + as!s32(zi * gran.depth),
)
memOffset := as!u64(bind.memoryOffset + as!VkDeviceSize(loc) * blockSize)
levelInfo.Blocks[memOffset] = new!SparseBoundImageBlockInfo(
Expand Down
6 changes: 6 additions & 0 deletions gapis/api/vulkan/api/queued_command_tracking.api
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ sub void callCommand(ref!CommandReference reference) {
dovkCmdDrawIndirectCountAMD(CommandBuffers[reference.Buffer].BufferCommands.vkCmdDrawIndirectCountAMD[reference.MapIndex])
case cmd_vkCmdDrawIndexedIndirectCountAMD:
dovkCmdDrawIndexedIndirectCountAMD(CommandBuffers[reference.Buffer].BufferCommands.vkCmdDrawIndexedIndirectCountAMD[reference.MapIndex])
case cmd_vkCmdBeginDebugUtilsLabelEXT:
dovkCmdBeginDebugUtilsLabelEXT(CommandBuffers[reference.Buffer].BufferCommands.vkCmdBeginDebugUtilsLabelEXT[reference.MapIndex])
case cmd_vkCmdEndDebugUtilsLabelEXT:
dovkCmdEndDebugUtilsLabelEXT(CommandBuffers[reference.Buffer].BufferCommands.vkCmdEndDebugUtilsLabelEXT[reference.MapIndex])
case cmd_vkCmdInsertDebugUtilsLabelEXT:
dovkCmdInsertDebugUtilsLabelEXT(CommandBuffers[reference.Buffer].BufferCommands.vkCmdInsertDebugUtilsLabelEXT[reference.MapIndex])
default:
vkErrorInvalidCommandBuffer(reference.Buffer)
}
Expand Down
14 changes: 7 additions & 7 deletions gapis/api/vulkan/api/structs.api
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ class VkFormatProperties {
}

class VkExtent3D {
u32 Width
u32 Height
u32 Depth
u32 width
u32 height
u32 depth
}

class VkImageFormatProperties {
Expand Down Expand Up @@ -655,8 +655,8 @@ class VkOffset2D {
}

class VkExtent2D {
u32 Width
u32 Height
u32 width
u32 height
}

class VkRect2D {
Expand Down Expand Up @@ -1057,8 +1057,8 @@ class VkClearDepthStencilValue {
// @union
/// Union allowing specification of color, depth, and stencil color values. Actual value selected is based on attachment being cleared.
class VkClearValue {
VkClearColorValue color
// VkClearDepthStencilValue depthStencil
VkClearColorValue color
// VkClearDepthStencilValue depthStencil
}

class VkClearAttachment {
Expand Down
6 changes: 3 additions & 3 deletions gapis/api/vulkan/api/util.api
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,9 @@ sub VkDeviceSize inferImageLevelSize(ref!ImageObject img, u32 level) {
level_size := MutableVkDeviceSize(0)
if level < img_info.MipLevels {
block_info := getElementAndTexelBlockSize(img_info.Format)
width := getMipSize(img_info.Extent.Width, level)
height := getMipSize(img_info.Extent.Height, level)
depth := getMipSize(img_info.Extent.Depth, level)
width := getMipSize(img_info.Extent.width, level)
height := getMipSize(img_info.Extent.height, level)
depth := getMipSize(img_info.Extent.depth, level)
width_in_blocks := roundUpTo(width, block_info.TexelBlockSize.Width)
height_in_blocks := roundUpTo(height, block_info.TexelBlockSize.Height)
level_size.Val += as!VkDeviceSize(width_in_blocks * height_in_blocks * depth * block_info.ElementSize * img_info.ArrayLayers)
Expand Down
Loading

0 comments on commit fd11b07

Please sign in to comment.