Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v23.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaoliu78 committed Sep 14, 2023
2 parents bc9a158 + a531788 commit 5a37cc7
Show file tree
Hide file tree
Showing 41 changed files with 2,482 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AlignConsecutiveAssignments: true
DerivePointerAlignment: false
ColumnLimit: 90
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dgpu/scripts/libigdrcl.so filter=lfs diff=lfs merge=lfs -text
dgpu/ocl-hotfix/libigdrcl.so filter=lfs diff=lfs merge=lfs -text
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,16 @@
*.py[cod]
*$py.class

## video files
*.h264
*.264

## dependencies
dgpu\mediasample\ediaSample\deps\include\nlohmann
dgpu\mediasample\ediaSample\deps\include\nlohmann\*

## built executables
dgpu\mediasample\MediaSample\x64
dgpu\mediasample\MediaSample\x64\*
dgpu\mediasample\MediaSample\bin
dgpu\mediasample\MediaSample\bin\*
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ Reference code for VDI(Virtual Desktop Infrastructure), including:
- Deployment utils, auto config tools
- BKMs
- Reference applications

Dependencies for dGPU:
nlohmann's json is required to parse configuration files. In order to get this component, it is required to clone it from https://github.com/nlohmann/json.git and copy the \include\nlohmann folder to \dgpu\mediasample\MediaSample\deps\include so that it could be used by the media sample.
60 changes: 60 additions & 0 deletions dgpu/mediasample/MediaSample-build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
@echo off

setlocal EnableDelayedExpansion

REM Setup workspace path
set WorkspacePath=%~dp0
echo Workspace Path = %WorkspacePath%
echo.
echo VS path is %VS2022INSTALLDIR%
set PATH=%PATH%;%VS2022INSTALLDIR%\Msbuild\Current\bin;

echo Fetching deps...
echo .
set jsonURL=https://github.com/nlohmann/json/releases/download/v3.8.0/include.zip
set jsonOutput=%WorkspacePath%\include.zip
set jsonPath=%WorkspacePath%\tmp\nlohmann
mkdir %WorkspacePath%\MediaSample\deps\include\nlohmann
set jsonIncludePath=%WorkspacePath%\MediaSample\deps\include\nlohmann
powershell.exe -c "Invoke-WebRequest -Uri %jsonURL% -OutFile %jsonOutput%"
powershell.exe -c "Expand-Archive %jsonOutput% -DestinationPath %jsonPath%"
xcopy /s /y %jsonPath%\include\nlohmann %jsonIncludePath%


REM Select build type (Release/Debug), platform (x64/Win32)
REM Default set to Release|x64
:parse_args
set BuildType=Release
set BuildPlatform=x64
set BuildPlatformToolset=v143
set BuildVersion=

if "%__BUILD_HELP%" neq "" goto :usage

REM Selected build type and platfrom
echo Build Type = %BuildType%
echo Build Platform = %BuildPlatform%
REM Setup build target configuration
set BuildTargetCfg=/p:Configuration=%BuildType%;Platform=%BuildPlatform%
echo Build Target = %BuildTargetCfg%
echo Build Version = %BuildVersion%
echo.

del /q %jsonOutput%
rd /s /q tmp

echo.
echo Start building Testapp ...
title Building Testapp ...

MSBuild.exe "MediaSample.sln" -t:Rebuild %BuildTargetCfg% -v:normal -m
echo.
echo ... Building Testapp = %ERRORLEVEL%
if %ERRORLEVEL% neq 0 goto :build_failed

mkdir bin
xcopy /y MediaSample\deps\bin\QESLib.dll bin\
MOVE /y x64\Release\*.exe bin\
xcopy /y MediaSample\config\*.json bin\
rd /s /q x64
rd /s /q MediaSample\x64
31 changes: 31 additions & 0 deletions dgpu/mediasample/MediaSample.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33815.320
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MediaSample", "MediaSample\MediaSample.vcxproj", "{21C60783-49A7-4F02-9EF6-D23C7404F70C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{21C60783-49A7-4F02-9EF6-D23C7404F70C}.Debug|x64.ActiveCfg = Debug|x64
{21C60783-49A7-4F02-9EF6-D23C7404F70C}.Debug|x64.Build.0 = Debug|x64
{21C60783-49A7-4F02-9EF6-D23C7404F70C}.Debug|x86.ActiveCfg = Debug|Win32
{21C60783-49A7-4F02-9EF6-D23C7404F70C}.Debug|x86.Build.0 = Debug|Win32
{21C60783-49A7-4F02-9EF6-D23C7404F70C}.Release|x64.ActiveCfg = Release|x64
{21C60783-49A7-4F02-9EF6-D23C7404F70C}.Release|x64.Build.0 = Release|x64
{21C60783-49A7-4F02-9EF6-D23C7404F70C}.Release|x86.ActiveCfg = Release|Win32
{21C60783-49A7-4F02-9EF6-D23C7404F70C}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E46A3229-10FB-4ACE-AEF0-DE6185FBF304}
EndGlobalSection
EndGlobal
148 changes: 148 additions & 0 deletions dgpu/mediasample/MediaSample/MediaSample.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{21c60783-49a7-4f02-9ef6-d23c7404f70c}</ProjectGuid>
<RootNamespace>MediaSample</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)deps\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProjectDir)deps\lib\</AdditionalLibraryDirectories>
<AdditionalDependencies>QESLib.lib;dxgi.lib;d3d11.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)deps\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProjectDir)deps\lib\</AdditionalLibraryDirectories>
<AdditionalDependencies>QESLib.lib;dxgi.lib;d3d11.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="buffer.cpp" />
<ClCompile Include="config.cpp" />
<ClCompile Include="mediasample.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="buffer.h" />
<ClInclude Include="config.h" />
<ClInclude Include="mediasample.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
39 changes: 39 additions & 0 deletions dgpu/mediasample/MediaSample/MediaSample.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="mediasample.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="buffer.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="config.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="mediasample.hpp">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="buffer.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="config.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions dgpu/mediasample/MediaSample/MediaSample.vcxproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommandArguments>-cfg D:\Source\RIV\cg_engine_lite\x64\Release\config.json -n 1000 -fixFPS 30</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommandArguments>-cfg D:\Source\RIV\cg_engine_lite\x64\Release\config.json -n 1000 -fixFPS 30</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
54 changes: 54 additions & 0 deletions dgpu/mediasample/MediaSample/buffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "buffer.h"

BufferQueue::BufferQueue() {
m_Size = 0;
m_maxSize = 6;
std::unique_lock<std::mutex> lock(queue_mutex_);
}

bool BufferQueue::EnqueueBuffer(Buffer buf) {
std::unique_lock<std::mutex> lock(queue_mutex_);
m_SourceQueue.push(buf);
m_Size += 1;
if (m_Size > m_maxSize) {
m_SourceQueue.pop();
m_Size -= 1;
}
return true;
}

bool BufferQueue::SetMaxSize(int psize) {
m_maxSize = psize;
return true;
}

Buffer BufferQueue::DequeueBuffer() {
std::unique_lock<std::mutex> lock(queue_mutex_);
Buffer buf{};
if (!m_SourceQueue.empty()) {
buf = m_SourceQueue.front();
if (m_Size > 1) {
m_SourceQueue.pop();
m_Size -= 1;
}
buf.width = GetSystemMetrics(SM_CXSCREEN);
}
else {
buf.width = GetSystemMetrics(SM_CYSCREEN);
}
return buf;
}

Buffer BufferQueue::AcquireBuffer() {
std::unique_lock<std::mutex> lock(queue_mutex_);
Buffer buf{};
if (!m_SourceQueue.empty()) {
buf = m_SourceQueue.front();
buf.width = GetSystemMetrics(SM_CXSCREEN);
//printf("a buffer is dequeued");
}
else {
buf.width = GetSystemMetrics(SM_CYSCREEN);
}
return buf;
}
Loading

0 comments on commit 5a37cc7

Please sign in to comment.