Skip to content

Commit

Permalink
Update xgl from commit: 9d5952b
Browse files Browse the repository at this point in the history
* Add Navi10 support
  • Loading branch information
JacobHeAMD committed Jul 12, 2019
1 parent 778b199 commit 2315f2a
Show file tree
Hide file tree
Showing 17 changed files with 914 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Expand Up @@ -55,6 +55,7 @@ option(XGL_BUILD_VEGA20 "Build open source vulkan for Vega20?" ON)
option(XGL_BUILD_RAVEN2 "Build open source vulkan for Raven2?" ON)

option(XGL_BUILD_LIT "Build with Lit test?" OFF)
option(XGL_BUILD_GFX10 "Build open source vulkan for GFX10" ON)

option(ICD_BUILD_LLPCONLY "Build LLPC Only?" OFF)
option(ICD_BUILD_SPVONLY "Build SPV Only?" OFF)
Expand Down Expand Up @@ -143,6 +144,7 @@ set(PAL_BUILD_GPUOPEN ${ICD_GPUOPEN_DEVMODE_BUILD} CACHE BOOL "${PROJECT_NAME} o
set(PAL_BUILD_VIDEO ${ICD_BUILD_VIDEO} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(PAL_BUILD_RAVEN2 ${XGL_BUILD_RAVEN2} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(PAL_BUILD_VEGA20 ${XGL_BUILD_VEGA20} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(PAL_BUILD_GFX10 ${XGL_BUILD_GFX10} CACHE BOOL "${PROJECT_NAME} override." FORCE)

# LLVM
set(XGL_LLVM_SRC_PATH ${PROJECT_SOURCE_DIR}/../llvm CACHE PATH "Specify the path to the LLVM.")
Expand Down Expand Up @@ -178,6 +180,7 @@ set(XGL_ICD_PATH ${PROJECT_SOURCE_DIR}/icd CACHE PATH "The path of xgl, it is re
set(XGL_LLPC_PATH ${PROJECT_SOURCE_DIR}/../llpc CACHE PATH "Specify the path to the LLPC.")
set(LLPC_CLIENT_INTERFACE_MAJOR_VERSION ${ICD_LLPC_CLIENT_MAJOR_VERSION} CACHE STRING "${PROJECT_NAME} override." FORCE)
set(LLPC_BUILD_LIT ${XGL_BUILD_LIT} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(LLPC_BUILD_GFX10 ${XGL_BUILD_GFX10} CACHE BOOL "${PROJECT_NAME} override." FORCE)
if(ICD_BUILD_LLPC)
set(LLVM_ENABLE_ASSERTIONS ${CMAKE_BUILD_TYPE_DEBUG} CACHE BOOL Force)
set(LLVM_TARGETS_TO_BUILD AMDGPU CACHE STRING Force)
Expand Down
9 changes: 9 additions & 0 deletions icd/CMakeLists.txt
Expand Up @@ -99,6 +99,11 @@ if(ICD_BUILD_LLPC)
target_compile_definitions(xgl PRIVATE VKI_BUILD_VEGA20=1)
target_compile_definitions(xgl PRIVATE PAL_BUILD_VEGA20)
endif()
if(XGL_BUILD_GFX10)
target_compile_definitions(xgl PRIVATE VKI_BUILD_GFX10=1)
target_compile_definitions(xgl PRIVATE PAL_BUILD_GFX10)
target_compile_definitions(xgl PRIVATE LLPC_BUILD_GFX10)
endif()
endif()

if(TARGET_ARCHITECTURE_BITS EQUAL 32)
Expand Down Expand Up @@ -237,6 +242,10 @@ target_sources(xgl PRIVATE
api/utils/json_reader.cpp
)

if(XGL_BUILD_GFX10)
target_sources(xgl PRIVATE api/appopt/wolfenstein2_layer.cpp)
endif()

### ICD Auto-generated String Files ####################################################################################
set(ICD_STRING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/api/strings)
# ICD settings code generation main script
Expand Down
197 changes: 197 additions & 0 deletions icd/api/app_shader_optimizer.cpp
Expand Up @@ -137,6 +137,61 @@ void ShaderOptimizer::ApplyProfileToShaderCreateInfo(
}
#endif

if (shaderCreate.apply.waveSize)
{
options.pOptions->waveSize = shaderCreate.tuningOptions.waveSize;
}

if (shaderCreate.apply.wgpMode)
{
options.pOptions->wgpMode = true;
}

if (shaderCreate.apply.waveBreakSize)
{
options.pOptions->waveBreakSize =
static_cast<Llpc::WaveBreakSize>(shaderCreate.tuningOptions.waveBreakSize);
}

if (shaderCreate.apply.nggDisable)
{
options.pNggState->enableNgg = false;
}

if (shaderCreate.apply.nggFasterLaunchRate)
{
options.pNggState->enableFastLaunch = true;
}

if (shaderCreate.apply.nggVertexReuse)
{
options.pNggState->enableVertexReuse = true;
}

if (shaderCreate.apply.nggEnableFrustumCulling)
{
options.pNggState->enableFrustumCulling = true;
}

if (shaderCreate.apply.nggEnableBoxFilterCulling)
{
options.pNggState->enableBoxFilterCulling = true;
}

if (shaderCreate.apply.nggEnableSphereCulling)
{
options.pNggState->enableSphereCulling = true;
}

if (shaderCreate.apply.nggEnableBackfaceCulling)
{
options.pNggState->enableBackfaceCulling = true;
}

if (shaderCreate.apply.nggEnableSmallPrimFilter)
{
options.pNggState->enableSmallPrimFilter = true;
}
}

}
Expand Down Expand Up @@ -442,6 +497,35 @@ void ShaderOptimizer::BuildTuningProfile()

action.shaderCreate.apply.allowReZ = m_settings.overrideAllowReZ;

switch (m_settings.overrideWaveSize)
{
case ShaderWaveSize::WaveSizeAuto:
break;
case ShaderWaveSize::WaveSize64:
action.shaderCreate.apply.waveSize = true;
action.shaderCreate.tuningOptions.waveSize = 64;
break;
case ShaderWaveSize::WaveSize32:
action.shaderCreate.apply.waveSize = true;
action.shaderCreate.tuningOptions.waveSize = 32;
break;
default:
VK_NEVER_CALLED();
}

switch (m_settings.overrideWgpMode)
{
case WgpMode::WgpModeAuto:
break;
case WgpMode::WgpModeCu:
break;
case WgpMode::WgpModeWgp:
action.shaderCreate.apply.wgpMode = true;
break;
default:
VK_NEVER_CALLED();
}

if (m_settings.overrideWavesPerCu != 0)
{
action.dynamicShaderInfo.apply.maxWavesPerCu = true;
Expand Down Expand Up @@ -856,6 +940,19 @@ static bool ParseJsonProfileActionShader(
"enableSelectiveInline",
"useSiScheduler",
"reconfigWorkgroupLayout",
"waveSize",
"wgpMode",
"waveBreakSize",
"nggDisable",
"nggFasterLaunchRate",
"nggVertexReuse",
"nggEnableFrustumCulling",
"nggEnableBoxFilterCulling",
"nggEnableSphereCulling",
"nggEnableBackfaceCulling",
"nggEnableSmallPrimFilter",
"enableSubvector",
"enableSubvectorSharedVgprs",
};

success &= CheckValidKeys(pJson, VK_ARRAY_SIZE(ValidKeys), ValidKeys);
Expand Down Expand Up @@ -928,6 +1025,106 @@ static bool ParseJsonProfileActionShader(
}
}

if ((pItem = utils::JsonGetValue(pJson, "waveSize")) != nullptr)
{
pActions->shaderCreate.apply.waveSize = true;
pActions->shaderCreate.tuningOptions.waveSize = static_cast<uint32_t>(pItem->integerValue);
}

if ((pItem = utils::JsonGetValue(pJson, "wgpMode")) != nullptr)
{
if (pItem->integerValue != 0)
{
pActions->shaderCreate.apply.wgpMode = 1;
}
}

if ((pItem = utils::JsonGetValue(pJson, "waveBreakSize")) != nullptr)
{
pActions->shaderCreate.apply.waveBreakSize = true;
pActions->shaderCreate.tuningOptions.waveBreakSize = static_cast<uint32_t>(pItem->integerValue);
}

if ((pItem = utils::JsonGetValue(pJson, "nggDisable")) != nullptr)
{
if (pItem->integerValue != 0)
{
pActions->shaderCreate.apply.nggDisable = 1;
}
}

if ((pItem = utils::JsonGetValue(pJson, "nggFasterLaunchRate")) != nullptr)
{
if (pItem->integerValue != 0)
{
pActions->shaderCreate.apply.nggFasterLaunchRate = 1;
}
}

if ((pItem = utils::JsonGetValue(pJson, "nggVertexReuse")) != nullptr)
{
if (pItem->integerValue != 0)
{
pActions->shaderCreate.apply.nggVertexReuse = 1;
}
}

if ((pItem = utils::JsonGetValue(pJson, "nggEnableFrustumCulling")) != nullptr)
{
if (pItem->integerValue != 0)
{
pActions->shaderCreate.apply.nggEnableFrustumCulling = 1;
}
}

if ((pItem = utils::JsonGetValue(pJson, "nggEnableBoxFilterCulling")) != nullptr)
{
if (pItem->integerValue != 0)
{
pActions->shaderCreate.apply.nggEnableBoxFilterCulling = 1;
}
}

if ((pItem = utils::JsonGetValue(pJson, "nggEnableSphereCulling")) != nullptr)
{
if (pItem->integerValue != 0)
{
pActions->shaderCreate.apply.nggEnableSphereCulling = 1;
}
}

if ((pItem = utils::JsonGetValue(pJson, "nggEnableBackfaceCulling")) != nullptr)
{
if (pItem->integerValue != 0)
{
pActions->shaderCreate.apply.nggEnableBackfaceCulling = 1;
}
}

if ((pItem = utils::JsonGetValue(pJson, "nggEnableSmallPrimFilter")) != nullptr)
{
if (pItem->integerValue != 0)
{
pActions->shaderCreate.apply.nggEnableSmallPrimFilter = 1;
}
}

if ((pItem = utils::JsonGetValue(pJson, "enableSubvector")) != nullptr)
{
if (pItem->integerValue != 0)
{
pActions->shaderCreate.apply.enableSubvector = 1;
}
}

if ((pItem = utils::JsonGetValue(pJson, "enableSubvectorSharedVgprs")) != nullptr)
{
if (pItem->integerValue != 0)
{
pActions->shaderCreate.apply.enableSubvectorSharedVgprs = 1;
}
}

if ((pItem = utils::JsonGetValue(pJson, "maxWavesPerCu")) != nullptr)
{
pActions->dynamicShaderInfo.apply.maxWavesPerCu = true;
Expand Down
104 changes: 104 additions & 0 deletions icd/api/appopt/wolfenstein2_layer.cpp
@@ -0,0 +1,104 @@
/*
***********************************************************************************************************************
*
* Copyright (c) 2019 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 wolfenstein2_layer.cpp
* @brief Implementation of the Wolfenstein 2 Layer.
***********************************************************************************************************************
*/

#include "wolfenstein2_layer.h"

#include "include/vk_conv.h"
#include "include/vk_device.h"

namespace vk
{

// =====================================================================================================================
Wolfenstein2Layer::Wolfenstein2Layer()
{
}

// =====================================================================================================================
Wolfenstein2Layer::~Wolfenstein2Layer()
{
}

namespace entry
{

namespace wolfenstein2_layer
{

// =====================================================================================================================
VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(
VkDevice device,
const VkImageCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkImage* pImage)
{
Device* pDevice = ApiDevice::ObjectFromHandle(device);
OptLayer* pLayer = pDevice->GetAppOptLayer();

VkImageCreateInfo createInfo = *pCreateInfo;

constexpr VkImageUsageFlags UsageFlags = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;

if (((createInfo.usage & UsageFlags) == UsageFlags) && (createInfo.format != VK_FORMAT_R8G8B8A8_UNORM))
{
// The mutable flag forces off DCC (as long as no image view format list is specified).
createInfo.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
}

return pLayer->GetNextLayer()->GetEntryPoints().vkCreateImage(device,
&createInfo,
pAllocator,
pImage);
}

} // namespace wolfenstein2_layer

} // namespace entry

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#define WOLFENSTEIN2_LAYER_OVERRIDE_ALIAS(entry_name, func_name) \
pDispatchTable->OverrideEntryPoints()->entry_name = vk::entry::wolfenstein2_layer::func_name

#define WOLFENSTEIN2_LAYER_OVERRIDE_ENTRY(entry_name) \
WOLFENSTEIN2_LAYER_OVERRIDE_ALIAS(entry_name, entry_name)

// =====================================================================================================================
void Wolfenstein2Layer::OverrideDispatchTable(
DispatchTable* pDispatchTable)
{
// Save current device dispatch table to use as the next layer.
m_nextLayer = *pDispatchTable;

WOLFENSTEIN2_LAYER_OVERRIDE_ENTRY(vkCreateImage);
}

} // namespace vk

0 comments on commit 2315f2a

Please sign in to comment.