Skip to content

Commit

Permalink
Update XGL from commit: 7115558
Browse files Browse the repository at this point in the history
* Add Instance- and Device-specific dispatch tables. Comply with spec requirements.
* Handle unaligned memory to image and image to memory copies on the DMA Queue
* Use included headers to determine apiVersion instead of manual bumps
* Complete VK_EXT_sampler_filter_minmax extension, allows more formats and is completely driven by the formats spreadsheet
* VK_KHR_subgroup support:
        -  Add missing subgroup builtins in compute shader
        - Move the implementation of gl_SubGroupSize from patch phase to
          .ll library
        - Support for the shufflexor, shuffleup, shuffledown function
* VK_KHR_multiview support:
       - LoadOp Clears implementation
       - Rewrite the function ConfigBuilder::BuildUserDataConfig to
         support merged shader.
       - Adjust the position of SGPR to emulate ViewIndex.
       - Set the user data configuration of ViewId even if the stage is
         not the last vertex processing stage.
* Implement interaction between VK_KHR_multiview and VK_KHR_device_group by adding support for VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT.
* Change implementation of KHR_descriptor_update_template to move work from vkUpdateDescriptorSetWithTemplateKHR to vkCreateDescriptorUpdateTemplateKHR
* Batch large numbers of copy/clear/etc. image regions to avoid OOM errors
* Rearranged the loop in DescriptorSet::InitImmutableDescriptors() to avoid looking up the the descriptor sizes in the device unless necessary. Cuts time in DescriptorSet::Reassign() in half.
* Remove DescriptorSetHeap::m_pHandles. We can compute the handle with a little arithmetic instead of a memory lookup. Cuts the time in AllocDescriptorSets() in half.
* [LLPC]Implement sparse texture residency
* [LLPC]Fix Crash when parsing Hull Shader
* [LLPC]Fix problems with address space mapping
* [LLPC]Restored correct addr space for gs-vs ring buffer descriptor load
* Fix  an assert when running DOOM in Wine
  • Loading branch information
JacobHeAMD committed Mar 16, 2018
1 parent 1607b04 commit 03a38de
Show file tree
Hide file tree
Showing 89 changed files with 5,280 additions and 2,229 deletions.
1 change: 1 addition & 0 deletions icd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ target_sources(xgl PRIVATE
api/color_space_helper.cpp
api/gpu_event_mgr.cpp
api/internal_mem_mgr.cpp
api/pipeline_compiler.cpp
api/stencil_ops_combiner.cpp
api/vert_buf_binding_mgr.cpp
api/virtual_stack_mgr.cpp
Expand Down
3 changes: 3 additions & 0 deletions icd/api/include/khronos/sdk-1.1/vk_layer_dispatch_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ typedef struct VkLayerDispatchTable_ {

// ---- VK_EXT_external_memory_host extension commands
PFN_vkGetMemoryHostPointerPropertiesEXT GetMemoryHostPointerPropertiesEXT;

// ---- VK_AMD_buffer_marker extension commands
PFN_vkCmdWriteBufferMarkerAMD CmdWriteBufferMarkerAMD;
} VkLayerDispatchTable;


149 changes: 149 additions & 0 deletions icd/api/include/pipeline_compiler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/*
***********************************************************************************************************************
*
* Copyright (c) 2018 Advanced Micro Devices, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**********************************************************************************************************************/
/**
***********************************************************************************************************************
* @file pipeline_compiler.h
* @brief Contains declaration of Vulkan pipeline compiler
***********************************************************************************************************************
*/

#pragma once

#include "include/khronos/vulkan.h"
#include "include/vk_utils.h"
#include "include/vk_defines.h"
#include "include/vk_shader_code.h"

#include "llpc.h"

namespace Bil
{

struct BilConvertOptions;
struct BilShaderPatchOutput;
enum BilDescriptorType : uint32_t;

}

namespace vk
{

class PhysicalDevice;
class PipelineLayout;
class PipelineCache;
struct VbBindingInfo;

// =====================================================================================================================
// Represents Vulkan pipeline compiler, it wraps LLPC and SCPC, and hides the differences.
class PipelineCompiler
{
public:
// Creation info parameters for all the necessary LLPC/SCPC state objects encapsulated
// by the Vulkan graphics pipeline.
struct GraphicsPipelineCreateInfo
{
Llpc::GraphicsPipelineBuildInfo pipelineInfo;
const PipelineLayout* pLayout;
const VkPipelineShaderStageCreateInfo* pStages[ShaderGfxStageCount];
VkPipelineCreateFlags flags;
void* pMappingBuffer;
VkFormat dbFormat;
};

// Creation info parameters for all the necessary LLPC/SCPC state objects encapsulated
// by the Vulkan compute pipeline.
struct ComputePipelineCreateInfo
{
Llpc::ComputePipelineBuildInfo pipelineInfo;
const PipelineLayout* pLayout;
const VkPipelineShaderStageCreateInfo* pStage;
VkPipelineCreateFlags flags;
void* pMappingBuffer;
};

PipelineCompiler(PhysicalDevice* pPhysicalDevice);
~PipelineCompiler();
VkResult Initialize();
void Destroy();

VkResult CreateGraphicsPipelineBinary(
Device* pDevice,
uint32_t deviceIndex,
PipelineCache* pPipelineCache,
GraphicsPipelineCreateInfo* pCreateInfo,
size_t* pPipelineBinarySize,
const void** ppPipelineBinary);

VkResult CreateComputePipelineBinary(
Device* pDevice,
uint32_t deviceIndex,
PipelineCache* pPipelineCache,
ComputePipelineCreateInfo* pInfo,
size_t* pPipelineBinarySize,
const void** ppPipelineBinary);

VkResult ConvertGraphicsPipelineInfo(
Device* pDevice,
const VkGraphicsPipelineCreateInfo* pIn,
GraphicsPipelineCreateInfo* pInfo,
VbBindingInfo* pVbInfo);

VkResult ConvertComputePipelineInfo(
const VkComputePipelineCreateInfo* pIn,
ComputePipelineCreateInfo* pInfo);

void FreeComputePipelineBinary(
ComputePipelineCreateInfo* pCreateInfo,
const void* pPipelineBinary,
size_t binarySize);

void FreeGraphicsPipelineBinary(
GraphicsPipelineCreateInfo* pCreateInfo,
const void* pPipelineBinary,
size_t binarySize);

void FreeComputePipelineCreateInfo(ComputePipelineCreateInfo* pCreateInfo);

void FreeGraphicsPipelineCreateInfo(GraphicsPipelineCreateInfo* pCreateInfo);
// Get LLPC compiler explicitly.
// TODO: Should be removed in the future
Llpc::ICompiler* GetLlpcCompiler() { return m_pLlpc; }

private:
VkResult CreateLlpcCompiler();

static bool IsDualSourceBlend(VkBlendFactor blend);

// -----------------------------------------------------------------------------------------------------------------

PhysicalDevice* m_pPhysicalDevice; // Vulkan physical device object
Llpc::GfxIpVersion m_gfxIp; // Graphics IP version info, used by LLPC
Pal::GfxIpLevel m_gfxIpLevel; // Graphics IP Level, used by SCPC

Llpc::ICompiler* m_pLlpc; // LLPC compiler object

}; // class PipelineCompiler

} // namespce vk
2 changes: 2 additions & 0 deletions icd/api/include/vk_cmdbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,8 @@ class CmdBuffer
const uint32_t queryCount,
const uint32_t timestampChunk);

VK_INLINE uint32_t EstimateMaxObjectsOnVirtualStack(size_t objectSize) const;

#if VK_ENABLE_DEBUG_BARRIERS
void DbgCmdBarrier(bool preCmd);
#endif
Expand Down
2 changes: 0 additions & 2 deletions icd/api/include/vk_compute_pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ class ComputePipeline : public Pipeline, public NonDispatchable<VkPipeline, Comp
ImmedInfo immedInfo;
Pal::ComputePipelineCreateInfo pipeline;
const PipelineLayout* pLayout;
const VkPipelineShaderStageCreateInfo* pStage;
VkPipelineCreateFlags flags;
};

static void ConvertComputePipelineInfo(
Expand Down
7 changes: 6 additions & 1 deletion icd/api/include/vk_descriptor_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "include/vk_dispatch.h"
#include "include/vk_memory.h"
#include "include/internal_mem_mgr.h"
#include "include/vk_descriptor_set.h"

namespace vk
{
Expand Down Expand Up @@ -158,9 +159,13 @@ class DescriptorSetHeap
void Reset();

private:

size_t SetSize() const { return Util::Pow2Align(sizeof(DescriptorSet), VK_DEFAULT_MEM_ALIGN); }

VkDescriptorSet DescriptorSetHandleFromIndex(uint32_t idx) const;

uint32_t m_nextFreeHandle;
uint32_t m_maxSets;
VkDescriptorSet* m_pHandles;

uint32_t* m_pFreeIndexStack;
uint32_t m_freeIndexStackCount;
Expand Down
69 changes: 40 additions & 29 deletions icd/api/include/vk_descriptor_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,55 +68,53 @@ union DescriptorSetFlags
class DescriptorSet : public NonDispatchable<VkDescriptorSet, DescriptorSet>
{
public:
VK_INLINE void WriteSamplerDescriptors(
const Device::Properties& deviceProperties,
template <size_t samplerDescSize>
static void WriteSamplerDescriptors(
const VkDescriptorImageInfo* pDescriptors,
uint32_t* pDestAddr,
uint32_t count,
uint32_t dwStride,
size_t descriptorStrideInBytes);

VK_INLINE void WriteImageSamplerDescriptors(
const Device::Properties& deviceProperties,
template <size_t imageDescSize, size_t samplerDescSize>
static void WriteImageSamplerDescriptors(
const VkDescriptorImageInfo* pDescriptors,
uint32_t deviceIdx,
uint32_t* pDestAddr,
uint32_t count,
uint32_t dwStride,
size_t descriptorStrideInBytes);

VK_INLINE void WriteImageDescriptors(
VkDescriptorType descType,
const Device::Properties& deviceProperties,
template <size_t imageDescSize>
static void WriteImageDescriptors(
const VkDescriptorImageInfo* pDescriptors,
uint32_t deviceIdx,
uint32_t* pDestAddr,
uint32_t count,
uint32_t dwStride,
size_t descriptorStrideInBytes);

VK_INLINE void WriteFmaskDescriptors(
const Device* pDevice,
template <size_t imageDescSize>
static void WriteFmaskDescriptors(
const VkDescriptorImageInfo* pDescriptors,
uint32_t deviceIdx,
uint32_t* pDestAddr,
uint32_t count,
uint32_t dwStride,
size_t descriptorStrideInBytes);

VK_INLINE void WriteBufferInfoDescriptors(
template <VkDescriptorType type>
static void WriteBufferInfoDescriptors(
const Device* pDevice,
VkDescriptorType type,
const VkDescriptorBufferInfo* pDescriptors,
uint32_t deviceIdx,
uint32_t* pDestAddr,
uint32_t count,
uint32_t dwStride,
size_t descriptorStrideInBytes);

VK_INLINE void WriteBufferDescriptors(
const Device::Properties& deviceProperties,
VkDescriptorType type,
template <size_t bufferDescSize, VkDescriptorType type>
static void WriteBufferDescriptors(
const VkBufferView* pDescriptors,
uint32_t deviceIdx,
uint32_t* pDestAddr,
Expand Down Expand Up @@ -161,39 +159,52 @@ class DescriptorSet : public NonDispatchable<VkDescriptorSet, DescriptorSet>
const uint32_t* pDynamicOffsets,
uint32_t numDynamicDescriptors);

static PFN_vkUpdateDescriptorSets GetUpdateDescriptorSetsFunc(const Device* pDevice);

protected:
DescriptorSet(
DescriptorPool* pPool,
uint32_t heapIndex,
DescriptorSetFlags flags);

~DescriptorSet()
{ PAL_NEVER_CALLED(); }

template <uint32_t numPalDevices>
static PFN_vkUpdateDescriptorSets GetUpdateDescriptorSetsFunc(const Device* pDevice);

template <size_t imageDescSize, size_t samplerDescSize, size_t bufferDescSize, uint32_t numPalDevices>
static VKAPI_ATTR void VKAPI_CALL UpdateDescriptorSets(
VkDevice device,
uint32_t descriptorWriteCount,
const VkWriteDescriptorSet* pDescriptorWrites,
uint32_t descriptorCopyCount,
const VkCopyDescriptorSet* pDescriptorCopies);

template <size_t imageDescSize, size_t samplerDescSize, size_t bufferDescSize>
static void WriteDescriptorSets(
const Device* pDevice,
uint32_t deviceIdx,
const Device::Properties& deviceProperties,
uint32_t descriptorWriteCount,
const VkWriteDescriptorSet* pDescriptorWrites,
size_t descriptorStrideInBytes = 0);
size_t descriptorStrideInBytes = 0);

template <size_t imageDescSize>
static void CopyDescriptorSets(
const Device* pDevice,
uint32_t deviceIdx,
const Device::Properties& deviceProperties,
uint32_t descriptorCopyCount,
const VkCopyDescriptorSet* pDescriptorCopies);

protected:
DescriptorSet(
DescriptorPool* pPool,
uint32_t heapIndex,
DescriptorSetFlags flags);

~DescriptorSet()
{ PAL_NEVER_CALLED(); }

void Reassign(
const DescriptorSetLayout* pLayout,
Pal::gpusize gpuMemOffset,
Pal::gpusize* gpuBaseAddress,
uint32_t** cpuBaseAddress,
uint32_t numPalDevices,
const InternalMemory* const pInternalMem,
void* pAllocHandle,
VkDescriptorSet* pHandle);
void* pAllocHandle);

void Reset();

void InitImmutableDescriptors(
const DescriptorSetLayout* pLayout,
Expand Down
23 changes: 23 additions & 0 deletions icd/api/include/vk_descriptor_set_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,29 @@ class DescriptorSetLayout : public NonDispatchable<VkDescriptorSetLayout, Descri
static uint32_t GetDescImmutableSectionDwSize(const Device* pDevice, VkDescriptorType type);
static uint32_t GetDynamicBufferDescDwSize(const Device* pDevice);

size_t GetDstStaOffset(const BindingInfo& dstBinding, uint32_t dstArrayElement) const
{
size_t offset = dstBinding.sta.dwOffset + (dstArrayElement * dstBinding.sta.dwArrayStride);

return offset;
}

size_t GetDstFmaskOffset(const BindingInfo& dstBinding, uint32_t dstArrayElement) const
{
size_t offset = Info().sta.dwSize +
dstBinding.fmask.dwOffset +
(dstArrayElement * dstBinding.fmask.dwArrayStride);

return offset;
}

size_t GetDstDynOffset(const BindingInfo& dstBinding, uint32_t dstArrayElement) const
{
size_t offset = dstBinding.dyn.dwOffset + dstArrayElement * dstBinding.dyn.dwArrayStride;

return offset;
}

protected:
DescriptorSetLayout(
const Device* pDevice,
Expand Down
Loading

0 comments on commit 03a38de

Please sign in to comment.