summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2017-11-13 03:18:57 +0000
committerEgor Yusov <egor.yusov@gmail.com>2017-11-13 03:18:57 +0000
commit5e3941de79b573b8798f6a6bcd4eaf544c48cde2 (patch)
tree77f33c32420cec66a88f24555f7211c02136468a
parentMerge from dev branch (diff)
downloadDiligentTools-5e3941de79b573b8798f6a6bcd4eaf544c48cde2.tar.gz
DiligentTools-5e3941de79b573b8798f6a6bcd4eaf544c48cde2.zip
Updated to version 2.1
-rw-r--r--External/CMakeLists.txt7
-rw-r--r--External/libjpeg-9a/CMakeLists.txt75
-rw-r--r--External/libtiff-4.0.3/CMakeLists.txt92
-rw-r--r--External/lpng-1.6.17/CMakeLists.txt45
-rw-r--r--External/lua-5.2.3/CMakeLists.txt87
-rw-r--r--External/zlib-1.2.8/CMakeLists.txt47
-rw-r--r--HLSL2GLSLConverter/build/Win32/HLSL2GLSLConverter.props32
-rw-r--r--HLSL2GLSLConverter/build/Win32/HLSL2GLSLConverter.vcxproj243
-rw-r--r--HLSL2GLSLConverter/build/Win32/HLSL2GLSLConverter.vcxproj.filters64
-rw-r--r--HLSL2GLSLConverter/src/HLSL2GLSLConverterApp.cpp246
-rw-r--r--HLSL2GLSLConverter/testshaders/CommonShaderStructs.shinc8
-rw-r--r--HLSL2GLSLConverter/testshaders/ConverterTest.fx1238
-rw-r--r--HLSL2GLSLConverter/testshaders/IncludeTest.fxh333
-rw-r--r--HLSL2GLSLConverter/testshaders/SelectArraySlice.gsh27
-rw-r--r--HLSL2GLSLConverter/testshaders/TessTestDX.dsh30
-rw-r--r--HLSL2GLSLConverter/testshaders/TessTestDX.hsh47
-rw-r--r--HLSL2GLSLConverter/testshaders/TessTestTriDX.dsh32
-rw-r--r--HLSL2GLSLConverter/testshaders/TessTestTriDX.hsh44
-rw-r--r--RenderScript/include/ConvenienceFunctions.h4
-rw-r--r--RenderScript/include/ScriptParser.h6
-rw-r--r--RenderScript/include/ShaderParser.h1
-rw-r--r--RenderScript/include/pch.h2
-rw-r--r--RenderScript/src/BufferParser.cpp8
-rw-r--r--RenderScript/src/DrawAttribsParser.cpp32
-rw-r--r--RenderScript/src/ScissorRectParser.cpp2
-rw-r--r--RenderScript/src/ScriptParser.cpp3
-rw-r--r--RenderScript/src/ShaderParser.cpp4
-rw-r--r--RenderScript/src/ViewportParser.cpp2
-rw-r--r--TextureLoader/include/DDSLoader.h6
-rw-r--r--TextureLoader/interface/Image.h7
-rw-r--r--TextureLoader/interface/TextureLoader.h4
-rw-r--r--TextureLoader/src/DDSLoader.cpp17
-rw-r--r--TextureLoader/src/Image.cpp8
-rw-r--r--TextureLoader/src/TextureLoader.cpp25
-rw-r--r--TextureLoader/src/TextureUtilities.cpp65
35 files changed, 2828 insertions, 65 deletions
diff --git a/External/CMakeLists.txt b/External/CMakeLists.txt
new file mode 100644
index 0000000..1f22c54
--- /dev/null
+++ b/External/CMakeLists.txt
@@ -0,0 +1,7 @@
+cmake_minimum_required (VERSION 3.3)
+
+add_subdirectory(libjpeg-9a)
+add_subdirectory(libtiff-4.0.3)
+add_subdirectory(zlib-1.2.8)
+add_subdirectory(lpng-1.6.17)
+add_subdirectory(lua-5.2.3)
diff --git a/External/libjpeg-9a/CMakeLists.txt b/External/libjpeg-9a/CMakeLists.txt
new file mode 100644
index 0000000..ec1f7fb
--- /dev/null
+++ b/External/libjpeg-9a/CMakeLists.txt
@@ -0,0 +1,75 @@
+cmake_minimum_required (VERSION 3.3)
+
+project(LibJpeg C)
+
+if(MSVC)
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+endif()
+
+set(SOURCE
+ jaricom.c
+ jcapimin.c
+ jcapistd.c
+ jcarith.c
+ jccoefct.c
+ jccolor.c
+ jcdctmgr.c
+ jchuff.c
+ jcinit.c
+ jcmainct.c
+ jcmarker.c
+ jcmaster.c
+ jcomapi.c
+ jcparam.c
+ jcprepct.c
+ jcsample.c
+ jctrans.c
+ jdapimin.c
+ jdapistd.c
+ jdarith.c
+ jdatadst.c
+ jdatasrc.c
+ jdcoefct.c
+ jdcolor.c
+ jddctmgr.c
+ jdhuff.c
+ jdinput.c
+ jdmainct.c
+ jdmarker.c
+ jdmaster.c
+ jdmerge.c
+ jdpostct.c
+ jdsample.c
+ jdtrans.c
+ jerror.c
+ jfdctflt.c
+ jfdctfst.c
+ jfdctint.c
+ jidctflt.c
+ jidctfst.c
+ jidctint.c
+ jmemmgr.c
+ jmemnobs.c
+ jquant1.c
+ jquant2.c
+ jutils.c
+)
+
+set(INCLUDE
+ jconfig.h
+ jdct.h
+ jerror.h
+ jinclude.h
+ jmemsys.h
+ jmorecfg.h
+ jpegint.h
+ jpeglib.h
+ jversion.h
+)
+
+add_library(
+ LibJpeg ${SOURCE} ${INCLUDE}
+)
+
+source_group("source" FILES ${SOURCE})
+source_group("include" FILES ${INCLUDE})
diff --git a/External/libtiff-4.0.3/CMakeLists.txt b/External/libtiff-4.0.3/CMakeLists.txt
new file mode 100644
index 0000000..f1606b5
--- /dev/null
+++ b/External/libtiff-4.0.3/CMakeLists.txt
@@ -0,0 +1,92 @@
+cmake_minimum_required (VERSION 3.3)
+
+project(LibTiff C)
+
+if(WIN32)
+ add_definitions(-DPLATFORM_WINDOWS -D_CRT_SECURE_NO_WARNINGS)
+elseif(ANDROID)
+ add_definitions(-DPLATFORM_ANDROID)
+endif()
+
+
+set(SOURCE
+# libtiff/mkg3states.c
+ libtiff/tif_aux.c
+ libtiff/tif_close.c
+ libtiff/tif_codec.c
+ libtiff/tif_color.c
+ libtiff/tif_compress.c
+ libtiff/tif_dir.c
+ libtiff/tif_dirinfo.c
+ libtiff/tif_dirread.c
+ libtiff/tif_dirwrite.c
+ libtiff/tif_dumpmode.c
+ libtiff/tif_error.c
+ libtiff/tif_extension.c
+ libtiff/tif_fax3.c
+ libtiff/tif_fax3sm.c
+ libtiff/tif_flush.c
+ libtiff/tif_getimage.c
+ libtiff/tif_jbig.c
+ libtiff/tif_jpeg.c
+ libtiff/tif_jpeg_12.c
+ libtiff/tif_luv.c
+ libtiff/tif_lzma.c
+ libtiff/tif_lzw.c
+ libtiff/tif_next.c
+ libtiff/tif_ojpeg.c
+ libtiff/tif_open.c
+ libtiff/tif_packbits.c
+ libtiff/tif_pixarlog.c
+ libtiff/tif_predict.c
+ libtiff/tif_print.c
+ libtiff/tif_read.c
+ libtiff/tif_stream.cxx
+ libtiff/tif_strip.c
+ libtiff/tif_swab.c
+ libtiff/tif_thunder.c
+ libtiff/tif_tile.c
+ libtiff/tif_version.c
+ libtiff/tif_warning.c
+ libtiff/tif_write.c
+ libtiff/tif_zip.c
+)
+
+if(WIN32)
+ list(APPEND SOURCE libtiff/tif_win32.c)
+elseif(ANDROID)
+ list(APPEND SOURCE libtiff/tif_unix.c)
+endif()
+
+set(INCLUDE
+ libtiff/t4.h
+ libtiff/tif_config.android.h
+ libtiff/tif_config.h
+ libtiff/tif_config.h-vms
+ libtiff/tif_config.vc.h
+ libtiff/tif_config.wince.h
+ libtiff/tif_dir.h
+ libtiff/tif_fax3.h
+ libtiff/tif_predict.h
+ libtiff/tiff.h
+ libtiff/tiffconf.android.h
+ libtiff/tiffconf.h
+ libtiff/tiffconf.vc.h
+ libtiff/tiffconf.wince.h
+ libtiff/tiffio.h
+ libtiff/tiffio.hxx
+ libtiff/tiffiop.h
+ libtiff/tiffvers.h
+ libtiff/uvcode.h
+)
+
+include_directories(
+ libtiff
+)
+
+add_library(
+ LibTiff ${SOURCE} ${INCLUDE}
+)
+
+source_group("source" FILES ${SOURCE})
+source_group("include" FILES ${INCLUDE})
diff --git a/External/lpng-1.6.17/CMakeLists.txt b/External/lpng-1.6.17/CMakeLists.txt
new file mode 100644
index 0000000..55d1607
--- /dev/null
+++ b/External/lpng-1.6.17/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required (VERSION 3.3)
+
+project(LibPng C)
+
+if(MSVC)
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+endif()
+
+set(SOURCE
+ png.c
+ pngerror.c
+ pngget.c
+ pngmem.c
+ pngpread.c
+ pngread.c
+ pngrio.c
+ pngrtran.c
+ pngrutil.c
+ pngset.c
+ pngtrans.c
+ pngwio.c
+ pngwrite.c
+ pngwtran.c
+ pngwutil.c
+)
+
+set(INCLUDE
+ png.h
+ pngconf.h
+ pngdebug.h
+ pnginfo.h
+ pngpriv.h
+ pngstruct.h
+)
+
+include_directories(
+ ../zlib-1.2.8
+)
+
+add_library(
+ LibPng ${SOURCE} ${INCLUDE}
+)
+
+source_group("source" FILES ${SOURCE})
+source_group("include" FILES ${INCLUDE})
diff --git a/External/lua-5.2.3/CMakeLists.txt b/External/lua-5.2.3/CMakeLists.txt
new file mode 100644
index 0000000..01d5a18
--- /dev/null
+++ b/External/lua-5.2.3/CMakeLists.txt
@@ -0,0 +1,87 @@
+cmake_minimum_required (VERSION 3.3)
+
+project(Lua CXX)
+
+if(MSVC)
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+endif()
+
+set(SOURCE
+ src/lapi.c
+ src/lauxlib.c
+ src/lbaselib.c
+ src/lbitlib.c
+ src/lcode.c
+ src/lcorolib.c
+ src/lctype.c
+ src/ldblib.c
+ src/ldebug.c
+ src/ldo.c
+ src/ldump.c
+ src/lfunc.c
+ src/lgc.c
+ src/linit.c
+ src/liolib.c
+ src/llex.c
+ src/lmathlib.c
+ src/lmem.c
+ src/loadlib.c
+ src/lobject.c
+ src/lopcodes.c
+ src/loslib.c
+ src/lparser.c
+ src/lstate.c
+ src/lstring.c
+ src/lstrlib.c
+ src/ltable.c
+ src/ltablib.c
+ src/ltm.c
+# src/lua.c
+# src/luac.c
+ src/lundump.c
+ src/lvm.c
+ src/lzio.c
+)
+
+# We need to compile all source files with c++ compiler
+set_source_files_properties(${SOURCE} PROPERTIES LANGUAGE CXX)
+
+set(INCLUDE
+ src/lapi.h
+ src/lauxlib.h
+ src/lcode.h
+ src/lctype.h
+ src/ldebug.h
+ src/ldo.h
+ src/lfunc.h
+ src/lgc.h
+ src/llex.h
+ src/llimits.h
+ src/lmem.h
+ src/lobject.h
+ src/lopcodes.h
+ src/lparser.h
+ src/lstate.h
+ src/lstring.h
+ src/ltable.h
+ src/ltm.h
+ src/lua.h
+ src/lua.hpp
+ src/luaconf.h
+ src/lualib.h
+ src/lundump.h
+ src/lvm.h
+ src/lzio.h
+ src/winappstubs.h
+)
+
+include_directories(
+ src
+)
+
+add_library(
+ Lua ${SOURCE} ${INCLUDE}
+)
+
+source_group("source" FILES ${SOURCE})
+source_group("include" FILES ${INCLUDE})
diff --git a/External/zlib-1.2.8/CMakeLists.txt b/External/zlib-1.2.8/CMakeLists.txt
new file mode 100644
index 0000000..bc0c159
--- /dev/null
+++ b/External/zlib-1.2.8/CMakeLists.txt
@@ -0,0 +1,47 @@
+cmake_minimum_required (VERSION 3.3)
+
+project(ZLib C)
+
+if(MSVC)
+ add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
+ add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
+endif()
+
+set(SOURCE
+ adler32.c
+ compress.c
+ crc32.c
+ deflate.c
+ gzclose.c
+ gzlib.c
+ gzread.c
+ gzwrite.c
+ infback.c
+ inffast.c
+ inflate.c
+ inftrees.c
+ trees.c
+ uncompr.c
+ zutil.c
+)
+
+set(INCLUDE
+ crc32.h
+ deflate.h
+ gzguts.h
+ inffast.h
+ inffixed.h
+ inflate.h
+ inftrees.h
+ trees.h
+ zconf.h
+ zlib.h
+ zutil.h
+)
+
+add_library(
+ ZLib ${SOURCE} ${INCLUDE}
+)
+
+source_group("source" FILES ${SOURCE})
+source_group("include" FILES ${INCLUDE})
diff --git a/HLSL2GLSLConverter/build/Win32/HLSL2GLSLConverter.props b/HLSL2GLSLConverter/build/Win32/HLSL2GLSLConverter.props
new file mode 100644
index 0000000..4ed2087
--- /dev/null
+++ b/HLSL2GLSLConverter/build/Win32/HLSL2GLSLConverter.props
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ImportGroup Label="PropertySheets" />
+ <PropertyGroup Label="UserMacros">
+ <ProjectRoot>..\..</ProjectRoot>
+ <EngineRoot>..\..\..\..</EngineRoot>
+ <CoreRoot>$(EngineRoot)\diligentcore</CoreRoot>
+ <GraphicsRoot>$(CoreRoot)\Graphics</GraphicsRoot>
+ <ToolsRoot>$(ProjectRoot)\..</ToolsRoot>
+ </PropertyGroup>
+ <PropertyGroup>
+ <IncludePath>$(ProjectRoot)\include;$(ProjectRoot)\interface;$(CoreRoot)\Common\interface;$(CoreRoot)\Common\include;$(CoreRoot)\Platforms\interface;$(GraphicsRoot)\GraphicsEngine\interface;$(GraphicsRoot)\GraphicsTools\include;$(GraphicsRoot)\GraphicsEngineOpenGL\interface;$(GraphicsRoot)\HLSL2GLSLConverterLib\interface;$(GraphicsRoot)\HLSL2GLSLConverterLib\include;$(IncludePath)</IncludePath>
+ </PropertyGroup>
+ <ItemDefinitionGroup />
+ <ItemGroup>
+ <BuildMacro Include="ProjectRoot">
+ <Value>$(ProjectRoot)</Value>
+ </BuildMacro>
+ <BuildMacro Include="EngineRoot">
+ <Value>$(EngineRoot)</Value>
+ </BuildMacro>
+ <BuildMacro Include="CoreRoot">
+ <Value>$(CoreRoot)</Value>
+ </BuildMacro>
+ <BuildMacro Include="GraphicsRoot">
+ <Value>$(GraphicsRoot)</Value>
+ </BuildMacro>
+ <BuildMacro Include="ToolsRoot">
+ <Value>$(ToolsRoot)</Value>
+ </BuildMacro>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/HLSL2GLSLConverter/build/Win32/HLSL2GLSLConverter.vcxproj b/HLSL2GLSLConverter/build/Win32/HLSL2GLSLConverter.vcxproj
new file mode 100644
index 0000000..93bcf1d
--- /dev/null
+++ b/HLSL2GLSLConverter/build/Win32/HLSL2GLSLConverter.vcxproj
@@ -0,0 +1,243 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" 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>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\HLSL2GLSLConverterApp.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\..\diligentcore\Common\build\Win32\Common.vcxproj">
+ <Project>{7380f7e6-315f-4b4e-92eb-e6aeee865298}</Project>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\..\diligentcore\Graphics\GraphicsEngineOpenGL\build\Win32\GraphicsEngineOpenGL.vcxproj">
+ <Project>{15e346d3-fde6-4b29-88b7-fca14dada501}</Project>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\..\diligentcore\Graphics\GraphicsTools\build\Win32\GraphicsTools.vcxproj">
+ <Project>{c6014499-0cf2-43ec-a773-a4e354fb2d74}</Project>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\..\diligentcore\Graphics\HLSL2GLSLConverterLib\build\Win32\HLSL2GLSLConverterLib.vcxproj">
+ <Project>{1a782154-a5bd-4a05-b837-efc77f126c84}</Project>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\..\diligentcore\Platforms\Basic\build\Win32\BasicPlatform.vcxproj">
+ <Project>{8ada5f93-7a38-4ad8-b8f5-1ffd4d4f630c}</Project>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\..\diligentcore\Platforms\Win32\build\Win32\WindowsPlatform.vcxproj">
+ <Project>{58f32677-436b-412a-bbf8-2b1310d82cd8}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="..\..\..\..\build\Win32\bin\DLLs\x86\GraphicsEngineOpenGL_32d.dll">
+ <FileType>Document</FileType>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(RelativeDir)%(Filename).dll $(TargetDir)
+copy %(RelativeDir)%(Filename).pdb $(TargetDir)
+ </Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Copying %(Filename).dll and %(Filename).pdb</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(TargetDir)%(Filename).dll</Outputs>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="..\..\..\..\build\Win32\bin\DLLs\x86\GraphicsEngineOpenGL_32r.dll">
+ <FileType>Document</FileType>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(RelativeDir)%(Filename).dll $(TargetDir)
+copy %(RelativeDir)%(Filename).pdb $(TargetDir)
+ </Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Copying %(Filename).dll and %(Filename).pdb</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(TargetDir)%(Filename).dll</Outputs>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="..\..\..\..\build\Win32\bin\DLLs\x64\GraphicsEngineOpenGL_64d.dll">
+ <FileType>Document</FileType>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(RelativeDir)%(Filename).dll $(TargetDir)
+copy %(RelativeDir)%(Filename).pdb $(TargetDir)</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Copying %(Filename).dll and %(Filename).pdb</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)%(Filename).dll</Outputs>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="..\..\..\..\build\Win32\bin\DLLs\x64\GraphicsEngineOpenGL_64r.dll">
+ <FileType>Document</FileType>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(RelativeDir)%(Filename).dll $(TargetDir)
+copy %(RelativeDir)%(Filename).pdb $(TargetDir)
+ </Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Copying %(Filename).dll and %(Filename).pdb</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)%(Filename).dll</Outputs>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="..\..\testshaders\CommonShaderStructs.shinc" />
+ <None Include="..\..\testshaders\ConverterTest.fx">
+ <FileType>Document</FileType>
+ </None>
+ <None Include="..\..\testshaders\IncludeTest.fxh" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="..\..\testshaders\SelectArraySlice.gsh">
+ <FileType>Document</FileType>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="..\..\testshaders\TessTestDX.dsh">
+ <FileType>Document</FileType>
+ </None>
+ <None Include="..\..\testshaders\TessTestDX.hsh">
+ <FileType>Document</FileType>
+ </None>
+ <None Include="..\..\testshaders\TessTestTriDX.dsh">
+ <FileType>Document</FileType>
+ </None>
+ <None Include="..\..\testshaders\TessTestTriDX.hsh">
+ <FileType>Document</FileType>
+ </None>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{8ABE7F5C-D397-4667-8F6F-2F786D958371}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>HLSL2GLSLConverter</RootNamespace>
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</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" />
+ <Import Project="..\..\..\..\diligentcore\Shared\build\Windows\Win32d.props" />
+ <Import Project="HLSL2GLSLConverter.props" />
+ </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" />
+ <Import Project="..\..\..\..\diligentcore\Shared\build\Windows\Win32r.props" />
+ <Import Project="HLSL2GLSLConverter.props" />
+ </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" />
+ <Import Project="..\..\..\..\diligentcore\Shared\build\Windows\Win64d.props" />
+ <Import Project="HLSL2GLSLConverter.props" />
+ </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" />
+ <Import Project="..\..\..\..\diligentcore\Shared\build\Windows\Win64r.props" />
+ <Import Project="HLSL2GLSLConverter.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;ENGINE_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>_DEBUG;_CONSOLE;ENGINE_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;ENGINE_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>NDEBUG;_CONSOLE;ENGINE_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/HLSL2GLSLConverter/build/Win32/HLSL2GLSLConverter.vcxproj.filters b/HLSL2GLSLConverter/build/Win32/HLSL2GLSLConverter.vcxproj.filters
new file mode 100644
index 0000000..5413892
--- /dev/null
+++ b/HLSL2GLSLConverter/build/Win32/HLSL2GLSLConverter.vcxproj.filters
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="DLLs">
+ <UniqueIdentifier>{3e325a93-320d-4e63-9e41-93545bcc3542}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="TestShaders">
+ <UniqueIdentifier>{dc9df78d-68ad-46a4-956c-6c4a77d1fd44}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\HLSL2GLSLConverterApp.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="..\..\..\..\build\Win32\bin\DLLs\x86\GraphicsEngineOpenGL_32d.dll">
+ <Filter>DLLs</Filter>
+ </CustomBuild>
+ <CustomBuild Include="..\..\..\..\build\Win32\bin\DLLs\x86\GraphicsEngineOpenGL_32r.dll">
+ <Filter>DLLs</Filter>
+ </CustomBuild>
+ <CustomBuild Include="..\..\..\..\build\Win32\bin\DLLs\x64\GraphicsEngineOpenGL_64d.dll">
+ <Filter>DLLs</Filter>
+ </CustomBuild>
+ <CustomBuild Include="..\..\..\..\build\Win32\bin\DLLs\x64\GraphicsEngineOpenGL_64r.dll">
+ <Filter>DLLs</Filter>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="..\..\testshaders\ConverterTest.fx">
+ <Filter>TestShaders</Filter>
+ </None>
+ <None Include="..\..\testshaders\CommonShaderStructs.shinc">
+ <Filter>TestShaders</Filter>
+ </None>
+ <None Include="..\..\testshaders\IncludeTest.fxh">
+ <Filter>TestShaders</Filter>
+ </None>
+ <None Include="..\..\testshaders\SelectArraySlice.gsh">
+ <Filter>TestShaders</Filter>
+ </None>
+ <None Include="..\..\testshaders\TessTestDX.dsh">
+ <Filter>TestShaders</Filter>
+ </None>
+ <None Include="..\..\testshaders\TessTestDX.hsh">
+ <Filter>TestShaders</Filter>
+ </None>
+ <None Include="..\..\testshaders\TessTestTriDX.dsh">
+ <Filter>TestShaders</Filter>
+ </None>
+ <None Include="..\..\testshaders\TessTestTriDX.hsh">
+ <Filter>TestShaders</Filter>
+ </None>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/HLSL2GLSLConverter/src/HLSL2GLSLConverterApp.cpp b/HLSL2GLSLConverter/src/HLSL2GLSLConverterApp.cpp
new file mode 100644
index 0000000..1c6614e
--- /dev/null
+++ b/HLSL2GLSLConverter/src/HLSL2GLSLConverterApp.cpp
@@ -0,0 +1,246 @@
+// HLSL2GLSLConverterImpl.cpp : Defines the entry point for the console application.
+//
+
+#include <Windows.h>
+#include "Errors.h"
+#include "HLSL2GLSLConverterImpl.h"
+#include "RefCntAutoPtr.h"
+#include "Errors.h"
+#include "RenderDeviceFactoryOpenGL.h"
+#include "BasicShaderSourceStreamFactory.h"
+#include "RefCntAutoPtr.h"
+#include "DataBlobImpl.h"
+
+using namespace Diligent;
+
+// Called every time the application receives a message
+LRESULT CALLBACK MessageProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ // Send event message to AntTweakBar
+ switch (message)
+ {
+ case WM_PAINT:
+ {
+ PAINTSTRUCT ps;
+ BeginPaint(wnd, &ps);
+ EndPaint(wnd, &ps);
+ return 0;
+ }
+ case WM_SIZE: // Window size has been changed
+ return 0;
+ case WM_CHAR:
+ if (wParam == VK_ESCAPE)
+ PostQuitMessage(0);
+ return 0;
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ return 0;
+ default:
+ return DefWindowProc(wnd, message, wParam, lParam);
+ }
+}
+
+void PrintHelp()
+{
+ LOG_INFO_MESSAGE("Command line arguments:\n")
+ LOG_INFO_MESSAGE("-h Print help message\n")
+ LOG_INFO_MESSAGE("-i <filename> Input file path (relative to the search directories)\n")
+ LOG_INFO_MESSAGE("-d <dirname> Search directory to look for input file path as well as all #include files")
+ LOG_INFO_MESSAGE(" Every search directory should be specified using -d argument\n")
+ LOG_INFO_MESSAGE("-o <filename> Output file to write converted GLSL source to\n")
+ LOG_INFO_MESSAGE("-e <funcname> Shader entry point\n")
+ LOG_INFO_MESSAGE("-c Compile converted GLSL shader\n")
+ LOG_INFO_MESSAGE("-t <type> Shader type. Allowed values:")
+ LOG_INFO_MESSAGE(" vs - vertex shader")
+ LOG_INFO_MESSAGE(" ps - pixel shader")
+ LOG_INFO_MESSAGE(" gs - geometry shader")
+ LOG_INFO_MESSAGE(" ds - domain shader")
+ LOG_INFO_MESSAGE(" hs - domain shader")
+ LOG_INFO_MESSAGE(" cs - domain shader\n")
+ LOG_INFO_MESSAGE("-noglsldef Do not include glsl definitions into the converted source\n")
+}
+
+// Main
+int main(int argc, char** argv)
+{
+#if defined(_DEBUG) || defined(DEBUG)
+ _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+#endif
+
+ if (argc == 1)
+ {
+ PrintHelp();
+ return 0;
+ }
+
+ std::string InputPath, OutputPath, SearchDirectories, EntryPoint("main");
+ SHADER_TYPE ShaderType = SHADER_TYPE_UNKNOWN;
+ bool CompileShader = false;
+ bool IncludeGLSLDefintions = true;
+ for (int a = 1; a < argc; ++a) {
+ if (_stricmp(argv[a], "-h") == 0)
+ {
+ PrintHelp();
+ }
+ else if (_stricmp(argv[a], "-i") == 0 && a + 1 < argc)
+ {
+ InputPath = argv[++a];
+ }
+ else if (_stricmp(argv[a], "-o") == 0 && a + 1 < argc)
+ {
+ OutputPath = argv[++a];
+ }
+ else if (_stricmp(argv[a], "-d") == 0 && a + 1 < argc)
+ {
+ if(!SearchDirectories.empty())
+ SearchDirectories.push_back(';');
+ SearchDirectories += argv[++a];
+ }
+ else if (_stricmp(argv[a], "-e") == 0 && a + 1 < argc)
+ {
+ EntryPoint = argv[++a];
+ }
+ else if (_stricmp(argv[a], "-c") == 0)
+ {
+ CompileShader = true;
+ }
+ else if (_stricmp(argv[a], "-t") == 0 && a + 1 < argc)
+ {
+ ++a;
+ if (_stricmp(argv[a], "vs")==0)ShaderType = SHADER_TYPE_VERTEX;
+ else if (_stricmp(argv[a], "gs")==0)ShaderType = SHADER_TYPE_GEOMETRY;
+ else if (_stricmp(argv[a], "ps")==0)ShaderType = SHADER_TYPE_PIXEL;
+ else if (_stricmp(argv[a], "hs")==0)ShaderType = SHADER_TYPE_HULL;
+ else if (_stricmp(argv[a], "ds")==0)ShaderType = SHADER_TYPE_DOMAIN;
+ else if (_stricmp(argv[a], "cs")==0)ShaderType = SHADER_TYPE_COMPUTE;
+ else
+ {
+ LOG_ERROR_MESSAGE("Unknow shader type ", argv[a],"; Allowed values: vs,gs,ps,ds,hs,cs");
+ return -1;
+ }
+ }
+ else if (_stricmp(argv[a], "-noglsldef") == 0)
+ {
+ IncludeGLSLDefintions = false;
+ }
+ else
+ {
+ LOG_ERROR_MESSAGE("Unknow command line option ", argv[a]);
+ return -1;
+ }
+ }
+
+ if (InputPath.length() == 0)
+ {
+ LOG_ERROR_MESSAGE("Input file path not specified; use -i command line option");
+ return -1;
+ }
+
+ if(ShaderType == SHADER_TYPE_UNKNOWN)
+ {
+ LOG_ERROR_MESSAGE("Shader type not specified; use -t [vs;ps;gs;ds;hs;cs] command line option");
+ return -1;
+ }
+
+ LOG_INFO_MESSAGE("Converting \'", InputPath, "\' to GLSL...")
+
+#ifdef ENGINE_DLL
+ // Declare function pointer
+ GetEngineFactoryOpenGLType GetEngineFactoryOpenGL = nullptr;
+ if( !LoadGraphicsEngineOpenGL(GetEngineFactoryOpenGL) )
+ {
+ LOG_ERROR_MESSAGE("Failed to load OpenGL engine implementation");
+ return -1;
+ }
+#endif
+ IEngineFactoryOpenGL *pFactory = GetEngineFactoryOpenGL();
+
+ BasicShaderSourceStreamFactory BasicSSSFactory(SearchDirectories.c_str());
+ RefCntAutoPtr<IFileStream> pInputFileStream;
+ BasicSSSFactory.CreateInputStream(InputPath.c_str(), &pInputFileStream);
+ if (!pInputFileStream)
+ {
+ return -1;
+ }
+ RefCntAutoPtr<Diligent::IDataBlob> pHLSLSourceBlob( MakeNewRCObj<DataBlobImpl>()(0) );
+ pInputFileStream->Read(pHLSLSourceBlob);
+ auto *HLSLSource = reinterpret_cast<char*>(pHLSLSourceBlob->GetDataPtr());
+ auto SourceLen = static_cast<Int32>( pHLSLSourceBlob->GetSize() );
+
+ const auto &Converter = HLSL2GLSLConverterImpl::GetInstance();
+ RefCntAutoPtr<IHLSL2GLSLConversionStream> pStream;
+ Converter.CreateStream(InputPath.c_str(), &BasicSSSFactory, HLSLSource, SourceLen, &pStream);
+ RefCntAutoPtr<Diligent::IDataBlob> pGLSLSourceBlob;
+ pStream->Convert(EntryPoint.c_str(), ShaderType, IncludeGLSLDefintions, &pGLSLSourceBlob);
+ if(!pGLSLSourceBlob)return -1;
+
+ LOG_INFO_MESSAGE("Done")
+
+ if (OutputPath.length() != 0)
+ {
+ FileWrapper pOutputFile( OutputPath.c_str(), EFileAccessMode::Overwrite );
+ if (pOutputFile != nullptr)
+ {
+ if( !pOutputFile->Write(pGLSLSourceBlob->GetDataPtr(), pGLSLSourceBlob->GetSize()) )
+ {
+ LOG_ERROR_MESSAGE("Failed to write converted source to output file ", OutputPath);
+ }
+ }
+ else
+ {
+ LOG_ERROR_MESSAGE("Failed to open output file ", OutputPath);
+ }
+ }
+
+ if(CompileShader)
+ {
+ LOG_INFO_MESSAGE("Compiling entry point \'", EntryPoint, "\' in converted file \'", InputPath, '\'')
+ // Register window cla ss
+ WNDCLASSEX wcex = { sizeof(WNDCLASSEX), CS_HREDRAW|CS_VREDRAW, MessageProc,
+ 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, L"HLSL2GLSLConverter", NULL };
+ RegisterClassEx(&wcex);
+
+ // Create dummy window
+ RECT rc = { 0, 0, 512, 512 };
+ AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);
+ HWND wnd = CreateWindow(L"HLSL2GLSLConverter", L"HLSL2GLSL Converter",
+ WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
+ rc.right-rc.left, rc.bottom-rc.top, NULL, NULL, wcex.hInstance, NULL);
+
+ if (!wnd)
+ {
+ LOG_ERROR_MESSAGE("Failed to create window");
+ return -1;
+ }
+ RefCntAutoPtr<IRenderDevice> pDevice;
+ RefCntAutoPtr<IDeviceContext> pContext;
+ RefCntAutoPtr<ISwapChain> pSwapChain;
+ EngineCreationAttribs EngineCreationAttribs;
+ SwapChainDesc SCDesc;
+ SCDesc.SamplesCount = 1;
+ pFactory->CreateDeviceAndSwapChainGL(
+ EngineCreationAttribs, &pDevice, &pContext, SCDesc, wnd, &pSwapChain );
+ if (!pDevice)
+ {
+ LOG_ERROR_MESSAGE("Failed to create render device");
+ return -1;
+ }
+
+ ShaderCreationAttribs Attrs;
+ Attrs.EntryPoint = EntryPoint.c_str();
+ Attrs.Desc.ShaderType = ShaderType;
+ Attrs.Desc.Name = "Test shader";
+ Attrs.Source = reinterpret_cast<char*>(pGLSLSourceBlob->GetDataPtr());
+ Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_GLSL;
+ RefCntAutoPtr<IShader> pTestShader;
+ pDevice->CreateShader(Attrs, &pTestShader);
+ if(!pTestShader)
+ {
+ LOG_ERROR_MESSAGE("Failed to compile converted source \'", InputPath, '\'');
+ return -1;
+ }
+ LOG_INFO_MESSAGE("Done")
+ }
+
+ return 0;
+}
diff --git a/HLSL2GLSLConverter/testshaders/CommonShaderStructs.shinc b/HLSL2GLSLConverter/testshaders/CommonShaderStructs.shinc
new file mode 100644
index 0000000..436c797
--- /dev/null
+++ b/HLSL2GLSLConverter/testshaders/CommonShaderStructs.shinc
@@ -0,0 +1,8 @@
+
+struct QuadVSOut
+{
+ float2 m_f2UV : UV;
+ uint m_uiInstID : InstID;
+ float4 m_f4Pos : SV_Position;
+};
+
diff --git a/HLSL2GLSLConverter/testshaders/ConverterTest.fx b/HLSL2GLSLConverter/testshaders/ConverterTest.fx
new file mode 100644
index 0000000..2691279
--- /dev/null
+++ b/HLSL2GLSLConverter/testshaders/ConverterTest.fx
@@ -0,0 +1,1238 @@
+/***//* Some comment * ** * * * / ** //// */ //Another comment
+//
+// Comment
+
+/* More *//*com*///ments/**/
+//
+//
+
+
+# include /*Comment*/ <IncludeTest.fxh>
+// #include "NonExistingFile.h"
+
+
+//#define TEXTURE2D Texture2D <- Macros do not work currently
+//TEXTURE2D MacroTex2D;
+
+/******//* /* /**** / */
+void EmptyFunc(){}cbuffer cbTest1{int a;}cbuffer cbTest2{int b;}/*comment
+test
+
+**/cbuffer cbTest3{int c;}//Single line comment
+cbuffer cbTest4{int d;}
+
+cbuffer cbTest5
+{
+ float4 e;
+}
+
+cbuffer cbTest6
+{
+ float4 f;
+};
+
+int cbuffer_fake;
+int fakecbuffer;
+
+int GlobalIntVar;Texture2D Tex2D_Test1;Texture2D Tex2D_Test2;/*Comment* / *//* /** Comment2**/Texture2D Tex2D_Test3;
+
+Texture2D Tex2D_M1, Tex2D_M2;
+
+// Test texture declaration
+
+#ifndef GL_ES
+
+Texture1D Tex1D_F1;
+Texture1D<float>Tex1D_F2;
+Texture1D<int2>Tex1D_I;
+Texture1D<uint4>Tex1D_U;
+
+SamplerState Tex1D_F1_sampler;
+
+Texture1DArray Tex1D_F_A1;
+Texture1DArray <float> Tex1D_F_A2;
+Texture1DArray <int2> Tex1D_I_A;
+Texture1DArray <uint4> Tex1D_U_A;
+
+SamplerState Tex1D_F_A1_sampler;
+
+Texture1D Tex1DS1;
+Texture1D<float>Tex1DS2,Tex1DS3;
+SamplerComparisonState Tex1DS1_sampler, Tex1DS2_sampler, TestCmpSamplerArr[2], Tex1DS3_sampler;
+
+Texture1DArray Tex1DAS1;
+SamplerComparisonState Tex1DAS1_sampler, Tex1DAS2_sampler;
+Texture1DArray<float>Tex1DAS2;
+
+#endif
+
+Texture2D Tex2D_F1;
+Texture2D<float>Tex2D_F3[2],Tex2D_F2,Tex2DS_F4,Tex2DS_F5;
+Texture2D<float4>Tex2D_F6;
+Texture2D<int3>Tex2D_I;
+Texture2D<uint4>Tex2D_U;
+
+SamplerState Tex2D_F1_sampler,Tex2D_F6_sampler;
+SamplerComparisonState DummySampler, Tex2DS_F4_sampler,Tex2DS_F5_sampler;
+
+Texture2DArray Tex2D_F_A1;
+Texture2DArray <float> Tex2D_F_A2;
+Texture2DArray <float4> Tex2D_F_A3;
+Texture2DArray <int2> Tex2D_I_A;
+Texture2DArray <uint4> Tex2D_U_A;
+
+SamplerState Tex2D_F_A1_sampler,Tex2D_F_A3_sampler;
+
+Texture2DMS < float2 > Tex2DMS_F1;
+Texture2DMS < float, 4 > Tex2DMS_F2;
+Texture2DMS < int > Tex2DMS_I;
+Texture2DMS < uint > Tex2DMS_U;
+
+#ifndef GL_ES
+Texture2DMSArray < float3 > Tex2DMS_F_A1;
+Texture2DMSArray < float, 4> Tex2DMS_F_A2;
+Texture2DMSArray < int2 > Tex2DMS_I_A;
+Texture2DMSArray < uint4 > Tex2DMS_U_A;
+#endif
+
+Texture3D Tex3D_F1;
+Texture3D< float4 > Tex3D_F2;
+Texture3D< float > Tex3D_F3;
+Texture3D< int > Tex3D_I;
+Texture3D< uint2 > Tex3D_U;
+
+SamplerState Tex3D_F1_sampler;
+
+TextureCube TexC_F1;
+TextureCube <float2> TexC_F2;
+TextureCube <int4> TexC_I;
+TextureCube <uint> TexC_U;
+
+SamplerState TexC_F1_sampler;
+
+#ifndef GL_ES
+TextureCubeArray TexC_F_A1;
+TextureCubeArray <float2> TexC_F_A2;
+TextureCubeArray <int4 > TexC_I_A;
+TextureCubeArray <uint > TexC_U_A;
+
+SamplerState TexC_F_A1_sampler;
+#endif
+
+Texture2D Tex2DS1;
+SamplerComparisonState Tex2DS1_sampler;
+Texture2D<float>Tex2DS2;
+SamplerComparisonState Tex2DS2_sampler;
+
+Texture2DArray Tex2DAS1;
+SamplerComparisonState Tex2DAS1_sampler;
+Texture2DArray<float>Tex2DAS2;
+SamplerComparisonState Tex2DAS2_sampler;
+
+TextureCube TexCS1;
+SamplerComparisonState TexCS1_sampler;
+TextureCube< float > TexCS2;
+SamplerComparisonState TexCS2_sampler;
+
+#ifndef GL_ES
+TextureCubeArray TexCAS1;
+SamplerComparisonState TexCAS1_sampler;
+TextureCubeArray <float> TexCAS2;
+SamplerComparisonState TexCAS2_sampler;
+#endif
+
+int intvar1;SamplerState Dummy;int intvar2;
+
+int Texture2D_fake, Texture2DArray_fake, fakeTexture2D, fakeTexture2DArray;
+int Texture2DMS_fake;
+int fakeTexture2DMS;
+int Texture2DMSArray_fake;
+int fakeTexture2DMSArray;
+int Texture3D_fake;
+int fakeTexture3D;
+int TextureCube_fake, TextureCubeArray_fake;
+int fakeTextureCube, fakeTextureCubeArray;
+int SamplerState_fake;
+int SamplerComparisonState_fake;
+int fakeSamplerState;
+int fakeSamplerComparisonState;
+int Texture4D;
+int Texture2d;
+int TextureCub;
+int Texture2DArr;
+int Texture2DM;
+int Texture2DMSArr;
+
+void TestGetDimensions()
+{
+#ifndef GL_ES
+ // Texture1D
+ {
+ uint uWidth, uMipLevels;
+ int iWidth, iMipLevels;
+ float fWidth, fMipLevels;
+ Tex1D_F1.GetDimensions(uWidth);
+ Tex1D_F1.GetDimensions(0, uWidth, uMipLevels);
+ Tex1D_I.GetDimensions(uWidth);
+ Tex1D_I.GetDimensions(0, uWidth, uMipLevels);
+ Tex1D_U.GetDimensions(uWidth);
+ Tex1D_U.GetDimensions(0, uWidth, uMipLevels);
+ Tex1DS1.GetDimensions(uWidth);
+ Tex1DS1.GetDimensions(0, uWidth, uMipLevels);
+
+ Tex1D_F1.GetDimensions(fWidth);
+ Tex1D_F1.GetDimensions(0, fWidth, fMipLevels);
+ Tex1D_I.GetDimensions(fWidth);
+ Tex1D_I.GetDimensions(0, fWidth, fMipLevels);
+ Tex1D_U.GetDimensions(fWidth);
+ Tex1D_U.GetDimensions(0, fWidth, fMipLevels);
+ Tex1DS1.GetDimensions(fWidth);
+ Tex1DS1.GetDimensions(0, fWidth, fMipLevels);
+
+ Tex1D_F1.GetDimensions(iWidth);
+ Tex1D_F1.GetDimensions(0, iWidth, iMipLevels);
+ Tex1D_I.GetDimensions(iWidth);
+ Tex1D_I.GetDimensions(0, iWidth, iMipLevels);
+ Tex1D_U.GetDimensions(iWidth);
+ Tex1D_U.GetDimensions(0, iWidth, iMipLevels);
+ Tex1DS1.GetDimensions(iWidth);
+ Tex1DS1.GetDimensions(0, iWidth, iMipLevels);
+ }
+
+ // Texture1DArray
+ {
+ uint uWidth, uMipLevels, uElems;
+ float fWidth, fMipLevels, fElems;
+ int iWidth, iMipLevels, iElems;
+
+ Tex1D_F_A1.GetDimensions(0, uWidth, uElems, uMipLevels);
+ Tex1D_F_A1.GetDimensions(uWidth, uElems);
+ Tex1D_U_A.GetDimensions(0, uWidth, uElems, uMipLevels);
+ Tex1D_U_A.GetDimensions(uWidth, uElems);
+ Tex1D_I_A.GetDimensions(0, uWidth, uElems, uMipLevels);
+ Tex1D_I_A.GetDimensions(uWidth, uElems);
+ Tex1DAS1.GetDimensions(0, uWidth, uElems, uMipLevels);
+ Tex1DAS1.GetDimensions(uWidth, uElems);
+
+ Tex1D_F_A1.GetDimensions(0, iWidth, iElems, iMipLevels);
+ Tex1D_F_A1.GetDimensions(iWidth, iElems);
+ Tex1D_U_A.GetDimensions(0, iWidth, iElems, iMipLevels);
+ Tex1D_U_A.GetDimensions(iWidth, iElems);
+ Tex1D_I_A.GetDimensions(0, iWidth, iElems, iMipLevels);
+ Tex1D_I_A.GetDimensions(iWidth, iElems);
+ Tex1DAS1.GetDimensions(0, iWidth, iElems, iMipLevels);
+ Tex1DAS1.GetDimensions(iWidth, iElems);
+
+ Tex1D_F_A1.GetDimensions(0, fWidth, fElems, fMipLevels);
+ Tex1D_F_A1.GetDimensions(fWidth, fElems);
+ Tex1D_U_A.GetDimensions(0, fWidth, fElems, fMipLevels);
+ Tex1D_U_A.GetDimensions(fWidth, fElems);
+ Tex1D_I_A.GetDimensions(0, fWidth, fElems, fMipLevels);
+ Tex1D_I_A.GetDimensions(fWidth, fElems);
+ Tex1DAS1.GetDimensions(0, fWidth, fElems, fMipLevels);
+ Tex1DAS1.GetDimensions(fWidth, fElems);
+ }
+#endif
+
+ //Texture2D
+ {
+ uint uWidth, uHeight, uMipLevels;
+ int iWidth, iHeight, iMipLevels;
+ float fWidth, fHeight, fMipLevels;
+
+ Tex2D_F1.GetDimensions(uWidth, uHeight);
+ Tex2D_F1.GetDimensions(0, uWidth, uHeight, uMipLevels);
+ Tex2D_F3[0].GetDimensions( 0, uWidth, uHeight, uMipLevels );
+ Tex2D_I.GetDimensions(uWidth, uHeight);
+ Tex2D_I.GetDimensions(0, uWidth, uHeight, uMipLevels);
+ Tex2D_U.GetDimensions(uWidth, uHeight);
+ Tex2D_U.GetDimensions(0, uWidth, uHeight, uMipLevels);
+ Tex2DS1.GetDimensions(uWidth, uHeight);
+ Tex2DS1.GetDimensions(0, uWidth, uHeight, uMipLevels);
+
+ Tex2D_F1.GetDimensions(iWidth, iHeight);
+ Tex2D_F1.GetDimensions(0, iWidth, iHeight, iMipLevels);
+ Tex2D_F3[0].GetDimensions( 0, iWidth, iHeight, iMipLevels );
+ Tex2D_I.GetDimensions(iWidth, iHeight);
+ Tex2D_I.GetDimensions(0, iWidth, iHeight, iMipLevels);
+ Tex2D_U.GetDimensions(iWidth, iHeight);
+ Tex2D_U.GetDimensions(0, iWidth, iHeight, iMipLevels);
+ Tex2DS1.GetDimensions(iWidth, iHeight);
+ Tex2DS1.GetDimensions(0, iWidth, iHeight, iMipLevels);
+
+
+ Tex2D_F1.GetDimensions(fWidth, fHeight);
+ Tex2D_F1.GetDimensions(0, fWidth, fHeight, fMipLevels);
+ Tex2D_F3[0].GetDimensions( 0, fWidth, fHeight, fMipLevels );
+ Tex2D_I.GetDimensions(fWidth, fHeight);
+ Tex2D_I.GetDimensions(0, fWidth, fHeight, fMipLevels);
+ Tex2D_U.GetDimensions(fWidth, fHeight);
+ Tex2D_U.GetDimensions(0, fWidth, fHeight, fMipLevels);
+ Tex2DS1.GetDimensions(fWidth, fHeight);
+ Tex2DS1.GetDimensions(0, fWidth, fHeight, fMipLevels);
+ }
+
+ //Texture2DArray
+ {
+ uint uWidth, uHeight, uMipLevels, uElems;
+ int iWidth, iHeight, iMipLevels, iElems;
+ float fWidth, fHeight, fMipLevels, fElems;
+
+ Tex2D_F_A1.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels);
+ Tex2D_F_A1.GetDimensions(uWidth, uHeight, uElems);
+ Tex2D_U_A.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels);
+ Tex2D_U_A.GetDimensions(uWidth, uHeight, uElems);
+ Tex2D_I_A.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels);
+ Tex2D_I_A.GetDimensions(uWidth, uHeight, uElems);
+ Tex2DAS1.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels);
+ Tex2DAS1.GetDimensions(uWidth, uHeight, uElems);
+
+ Tex2D_F_A1.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels);
+ Tex2D_F_A1.GetDimensions(iWidth, iHeight, iElems);
+ Tex2D_U_A.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels);
+ Tex2D_U_A.GetDimensions(iWidth, iHeight, iElems);
+ Tex2D_I_A.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels);
+ Tex2D_I_A.GetDimensions(iWidth, iHeight, iElems);
+ Tex2DAS1.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels);
+ Tex2DAS1.GetDimensions(iWidth, iHeight, iElems);
+
+ Tex2D_F_A1.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels);
+ Tex2D_F_A1.GetDimensions(fWidth, fHeight, fElems);
+ Tex2D_U_A.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels);
+ Tex2D_U_A.GetDimensions(fWidth, fHeight, fElems);
+ Tex2D_I_A.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels);
+ Tex2D_I_A.GetDimensions(fWidth, fHeight, fElems);
+ Tex2DAS1.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels);
+ Tex2DAS1.GetDimensions(fWidth, fHeight, fElems);
+ }
+
+ //Texture3D
+ {
+ uint uWidth, uHeight, uDepth, uMipLevels;
+ int iWidth, iHeight, iDepth, iMipLevels;
+ float fWidth, fHeight, fDepth, fMipLevels;
+ Tex3D_F1.GetDimensions(0, uWidth, uHeight, uDepth, uMipLevels);
+ Tex3D_F1.GetDimensions(uWidth, uHeight, uDepth);
+ Tex3D_U.GetDimensions(0, uWidth, uHeight, uDepth, uMipLevels);
+ Tex3D_U.GetDimensions(uWidth, uHeight, uDepth);
+ Tex3D_I.GetDimensions(0, uWidth, uHeight, uDepth, uMipLevels);
+ Tex3D_I.GetDimensions(uWidth, uHeight, uDepth);
+
+ Tex3D_F1.GetDimensions(0, iWidth, iHeight, iDepth, iMipLevels);
+ Tex3D_F1.GetDimensions(iWidth, iHeight, iDepth);
+ Tex3D_U.GetDimensions(0, iWidth, iHeight, iDepth, iMipLevels);
+ Tex3D_U.GetDimensions(iWidth, iHeight, iDepth);
+ Tex3D_I.GetDimensions(0, iWidth, iHeight, iDepth, iMipLevels);
+ Tex3D_I.GetDimensions(iWidth, iHeight, iDepth);
+
+ Tex3D_F1.GetDimensions(0, fWidth, fHeight, fDepth, fMipLevels);
+ Tex3D_F1.GetDimensions(fWidth, fHeight, fDepth);
+ Tex3D_U.GetDimensions(0, fWidth, fHeight, fDepth, fMipLevels);
+ Tex3D_U.GetDimensions(fWidth, fHeight, fDepth);
+ Tex3D_I.GetDimensions(0, fWidth, fHeight, fDepth, fMipLevels);
+ Tex3D_I.GetDimensions(fWidth, fHeight, fDepth);
+ }
+
+ //TextureCube ~ Texture2D
+ {
+ uint uWidth, uHeight, uMipLevels;
+ int iWidth, iHeight, iMipLevels;
+ float fWidth, fHeight, fMipLevels;
+
+ TexC_F1.GetDimensions(0, uWidth, uHeight, uMipLevels);
+ TexC_F1.GetDimensions(uWidth, uHeight);
+ TexC_I.GetDimensions(0, uWidth, uHeight, uMipLevels);
+ TexC_I.GetDimensions(uWidth, uHeight);
+ TexC_U.GetDimensions(0, uWidth, uHeight, uMipLevels);
+ TexC_U.GetDimensions(uWidth, uHeight);
+ TexCS1.GetDimensions(0, uWidth, uHeight, uMipLevels);
+ TexCS1.GetDimensions(uWidth, uHeight);
+
+ TexC_F1.GetDimensions(0, iWidth, iHeight, uMipLevels);
+ TexC_F1.GetDimensions(iWidth, iHeight);
+ TexC_I.GetDimensions(0, iWidth, iHeight, uMipLevels);
+ TexC_I.GetDimensions(iWidth, iHeight);
+ TexC_U.GetDimensions(0, iWidth, iHeight, uMipLevels);
+ TexC_U.GetDimensions(iWidth, iHeight);
+ TexCS1.GetDimensions(0, iWidth, iHeight, uMipLevels);
+ TexCS1.GetDimensions(iWidth, iHeight);
+
+ TexC_F1.GetDimensions(0, fWidth, fHeight, uMipLevels);
+ TexC_F1.GetDimensions(fWidth, fHeight);
+ TexC_I.GetDimensions(0, fWidth, fHeight, uMipLevels);
+ TexC_I.GetDimensions(fWidth, fHeight);
+ TexC_U.GetDimensions(0, fWidth, fHeight, uMipLevels);
+ TexC_U.GetDimensions(fWidth, fHeight);
+ TexCS1.GetDimensions(0, fWidth, fHeight, uMipLevels);
+ TexCS1.GetDimensions(fWidth, fHeight);
+ }
+
+#ifndef GL_ES
+ //TextureCubeArray ~ Texture2DArray
+ {
+ uint uWidth, uHeight, uMipLevels, uElems;
+ float fWidth, fHeight, fMipLevels, fElems;
+ int iWidth, iHeight, iMipLevels, iElems;
+
+ TexC_F_A1.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels);
+ TexC_F_A1.GetDimensions(uWidth, uHeight, uElems);
+ TexC_I_A.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels);
+ TexC_I_A.GetDimensions(uWidth, uHeight, uElems);
+ TexC_U_A.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels);
+ TexC_U_A.GetDimensions(uWidth, uHeight, uElems);
+ TexCAS1.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels);
+ TexCAS1.GetDimensions(uWidth, uHeight, uElems);
+
+ TexC_F_A1.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels);
+ TexC_F_A1.GetDimensions(iWidth, iHeight, iElems);
+ TexC_I_A.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels);
+ TexC_I_A.GetDimensions(iWidth, iHeight, iElems);
+ TexC_U_A.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels);
+ TexC_U_A.GetDimensions(iWidth, iHeight, iElems);
+ TexCAS1.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels);
+ TexCAS1.GetDimensions(iWidth, iHeight, iElems);
+
+ TexC_F_A1.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels);
+ TexC_F_A1.GetDimensions(fWidth, fHeight, fElems);
+ TexC_I_A.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels);
+ TexC_I_A.GetDimensions(fWidth, fHeight, fElems);
+ TexC_U_A.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels);
+ TexC_U_A.GetDimensions(fWidth, fHeight, fElems);
+ TexCAS1.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels);
+ TexCAS1.GetDimensions(fWidth, fHeight, fElems);
+ }
+#endif
+
+
+#ifndef GL_ES // This should work on ES3.1, but compiler fails for no reason
+ // Texture2DMS
+ {
+ uint uWidth, uHeight, uNumSamples;
+ float fWidth, fHeight, fNumSamples;
+ int iWidth, iHeight, iNumSamples;
+ Tex2DMS_F1.GetDimensions(uWidth, uHeight, uNumSamples);
+ Tex2DMS_I.GetDimensions(uWidth, uHeight, uNumSamples);
+ Tex2DMS_U.GetDimensions(uWidth, uHeight, uNumSamples);
+
+ Tex2DMS_F1.GetDimensions(fWidth, fHeight, fNumSamples);
+ Tex2DMS_I.GetDimensions(fWidth, fHeight, fNumSamples);
+ Tex2DMS_U.GetDimensions(fWidth, fHeight, fNumSamples);
+
+ Tex2DMS_F1.GetDimensions(iWidth, iHeight, iNumSamples);
+ Tex2DMS_I.GetDimensions(iWidth, iHeight, iNumSamples);
+ Tex2DMS_U.GetDimensions(iWidth, iHeight, iNumSamples);
+ }
+#endif
+
+#ifndef GL_ES
+ // Texture2DMSArray
+ {
+ uint uWidth, uHeight, uElems, uNumSamples;
+ int iWidth, iHeight, iElems, iNumSamples;
+ float fWidth, fHeight, fElems, fNumSamples;
+ Tex2DMS_F_A1.GetDimensions(uWidth, uHeight, uElems, uNumSamples);
+ Tex2DMS_I_A.GetDimensions(uWidth, uHeight, uElems, uNumSamples);
+ // OpenGL4.2 only supports 32 texture units and this one is 33rd:
+ // Tex2DMS_U_A.GetDimensions(Width, Height, Elems, NumSamples);
+
+ Tex2DMS_F_A1.GetDimensions(fWidth, fHeight, fElems, fNumSamples);
+ Tex2DMS_I_A.GetDimensions(fWidth, fHeight, fElems, fNumSamples);
+
+ Tex2DMS_F_A1.GetDimensions(iWidth, iHeight, iElems, iNumSamples);
+ Tex2DMS_I_A.GetDimensions(iWidth, iHeight, iElems, iNumSamples);
+ }
+#endif
+}
+
+
+
+void TestSample()
+{
+ float2 f2UV = float2(0.2, 0.3);
+ float3 f3UVW = float3(0.2, 0.3, 0.5);
+ int3 Offset = int3(3, 6, 2);
+ float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0);
+
+#ifndef GL_ES
+ // Texture1D
+ Tex1D_F1.Sample(Tex1D_F1_sampler, f3UVW.x);
+ Tex1D_F1.Sample(Tex1D_F1_sampler, f3UVW.x, Offset.x);
+
+ // Texture1DArray
+ Tex1D_F_A1.Sample(Tex1D_F_A1_sampler, f3UVW.xy);
+ Tex1D_F_A1.Sample(Tex1D_F_A1_sampler, f3UVW.xy, Offset.x);
+#endif
+
+ //Texture2D
+ Tex2D_F1.Sample( Tex2D_F1_sampler, f3UVW.xy ).xyzw.xyzw;
+ Tex2D_F1.Sample( Tex2D_F1_sampler, f3UVW.xy, Offset.xy );
+ Tex2D_F1.Sample( Tex2D_F1_sampler, float2(0.1, 0.3) );
+ Tex2D_F1.Sample( Tex2D_F1_sampler, float2(0.1, (0.3+0.1) ), int2( (3-1) ,5) );
+
+ //Texture2DArray
+ Tex2D_F_A1.Sample( Tex2D_F_A1_sampler, f3UVW.xyz );
+ Tex2D_F_A1.Sample( Tex2D_F_A1_sampler, f3UVW.xyz, Offset.xy );
+
+ //Texture3D
+ Tex3D_F1.Sample(Tex3D_F1_sampler, f3UVW.xyz );
+ Tex3D_F1.Sample(Tex3D_F1_sampler, f3UVW.xyz, Offset.xyz );
+
+ //TextureCube
+ TexC_F1.Sample(TexC_F1_sampler, f3UVW.xyz );
+ // Offset not supported
+
+#ifndef GL_ES
+ // TextureCubeArray
+ TexC_F_A1.Sample( TexC_F_A1_sampler, f4UVWQ.xyzw );
+ TexC_F_A1.Sample( TexC_F_A1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0) );
+ // Offset not supported
+#endif
+}
+
+
+
+void TestSampleBias()
+{
+ float2 f2UV = float2(0.2, 0.3);
+ float3 f3UVW = float3(0.2, 0.3, 0.5);
+ int3 Offset = int3(3, 6, 2);
+ float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0);
+
+#ifndef GL_ES
+ // Texture1D
+ Tex1D_F1.SampleBias(Tex1D_F1_sampler, f3UVW.x, 1.5);
+ Tex1D_F1.SampleBias(Tex1D_F1_sampler, f3UVW.x, 1.5, Offset.x);
+
+ // Texture1DArray
+ Tex1D_F_A1.SampleBias(Tex1D_F_A1_sampler, f3UVW.xy, 1.5);
+ Tex1D_F_A1.SampleBias(Tex1D_F_A1_sampler, f3UVW.xy, 1.5, Offset.x);
+#endif
+
+ //Texture2D
+ Tex2D_F1.SampleBias( Tex2D_F1_sampler, f3UVW.xy, 1.5 );
+ Tex2D_F1.SampleBias( Tex2D_F1_sampler, f3UVW.xy, 1.5, Offset.xy );
+ Tex2D_F1.SampleBias( Tex2D_F1_sampler, float2(0.1, 0.3), 1.5 );
+ Tex2D_F1.SampleBias( Tex2D_F1_sampler, float2(0.1, (0.3+0.1) ), 1.5, int2( (3-1) ,5) );
+
+ //Texture2DArray
+ Tex2D_F_A1.SampleBias( Tex2D_F_A1_sampler, f3UVW.xyz, 1.5 );
+ Tex2D_F_A1.SampleBias( Tex2D_F_A1_sampler, f3UVW.xyz, 1.5, Offset.xy );
+
+ //Texture3D
+ Tex3D_F1.SampleBias(Tex3D_F1_sampler, f3UVW.xyz, 1.5 );
+ Tex3D_F1.SampleBias(Tex3D_F1_sampler, f3UVW.xyz, 1.5, Offset.xyz );
+
+ //TextureCube
+ TexC_F1.SampleBias(TexC_F1_sampler, f3UVW.xyz, 1.5 );
+ // Offset not supported
+
+#ifndef GL_ES
+ // TextureCubeArray
+ TexC_F_A1.SampleBias( TexC_F_A1_sampler, f4UVWQ.xyzw, 1.5 );
+ TexC_F_A1.SampleBias( TexC_F_A1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), 1.6 );
+ // Offset not supported
+#endif
+}
+
+void TestSampleLevel()
+{
+ float2 f2UV = float2(0.2, 0.3);
+ float3 f3UVW = float3(0.2, 0.3, 0.5);
+ float Level = 1.8;
+ int3 Offset = int3(3, 6, 2);
+ float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0);
+
+#ifndef GL_ES
+ // Texture1D
+ Tex1D_F1.SampleLevel(Tex1D_F1_sampler, f3UVW.x, Level);
+ Tex1D_F1.SampleLevel(Tex1D_F1_sampler, f3UVW.x, Level, Offset.x);
+
+ // Texture1DArray
+ Tex1D_F_A1.SampleLevel(Tex1D_F_A1_sampler, f3UVW.xy, Level);
+ Tex1D_F_A1.SampleLevel(Tex1D_F_A1_sampler, f3UVW.xy, Level, Offset.x);
+#endif
+
+ //Texture2D
+ Tex2D_F1.SampleLevel( Tex2D_F1_sampler, f3UVW.xy, Level );
+ Tex2D_F1.SampleLevel( Tex2D_F1_sampler, Tex2D_F1.SampleLevel( Tex2D_F1_sampler, f3UVW.xy, Level ).xy + Tex2D_F1.SampleLevel( Tex2D_F1_sampler, f3UVW.xy, Level ).xy, Level );
+ Tex2D_F1.SampleLevel( Tex2D_F1_sampler, f3UVW.xy, Level, Offset.xy );
+ Tex2D_F1.SampleLevel( Tex2D_F1_sampler, float2(0.1, 0.3), 4.0 );
+ Tex2D_F1.SampleLevel( Tex2D_F1_sampler, float2(0.1, (0.3+0.1) ), 4.0, int2( (3-1) ,5) );
+
+ //Texture2DArray
+ Tex2D_F_A1.SampleLevel( Tex2D_F_A1_sampler, f3UVW.xyz, Level );
+ Tex2D_F_A1.SampleLevel( Tex2D_F_A1_sampler, f3UVW.xyz, Level, Offset.xy );
+
+ //Texture3D
+ Tex3D_F1.SampleLevel(Tex3D_F1_sampler, f3UVW.xyz, Level );
+ Tex3D_F1.SampleLevel(Tex3D_F1_sampler, f3UVW.xyz, Level, Offset.xyz );
+
+ //TextureCube
+ TexC_F1.SampleLevel(TexC_F1_sampler, f3UVW.xyz, Level );
+ // Offset not supported
+
+#ifndef GL_ES
+ // TextureCubeArray
+ TexC_F_A1.SampleLevel( TexC_F_A1_sampler, f4UVWQ.xyzw, Level );
+ TexC_F_A1.SampleLevel( TexC_F_A1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), 5 );
+ // Offset not supported
+#endif
+}
+
+
+void TestSampleGrad()
+{
+ float2 f2UV = float2(0.2, 0.3);
+ float2 f2ddxUV = float2(0.01, -0.02);
+ float2 f2ddyUV = float2(-0.01, 0.01);
+ float3 f3UVW = float3(0.2, 0.3, 0.5);
+ float3 f3ddxUVW = float3(-0.02, 0.03, 0.05);
+ float3 f3ddyUVW = float3( 0.01, -0.02, 0.02);
+ int3 Offset = int3(3, 6, 2);
+ float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0);
+
+#ifndef GL_ES
+ // Texture1D
+ Tex1D_F1.SampleGrad(Tex1D_F1_sampler, f3UVW.x, f2ddxUV.x, f2ddyUV.x);
+ Tex1D_F1.SampleGrad(Tex1D_F1_sampler, f3UVW.x, f2ddxUV.x, f2ddyUV.x, Offset.x);
+
+ // Texture1DArray
+ Tex1D_F_A1.SampleGrad(Tex1D_F_A1_sampler, f3UVW.xy, f2ddxUV.x, f2ddyUV.x);
+ Tex1D_F_A1.SampleGrad(Tex1D_F_A1_sampler, f3UVW.xy, f2ddxUV.x, f2ddyUV.x, Offset.x);
+#endif
+
+ //Texture2D
+ Tex2D_F1.SampleGrad( Tex2D_F1_sampler, f3UVW.xy, f2ddxUV.xy, f2ddyUV.xy );
+ Tex2D_F1.SampleGrad( Tex2D_F1_sampler, f3UVW.xy, f2ddxUV.xy, f2ddyUV.xy, Offset.xy );
+ Tex2D_F1.SampleGrad( Tex2D_F1_sampler, float2(0.1, 0.3), float2(0.01, 0.02), float2(-0.02, 0.01) );
+ Tex2D_F1.SampleGrad( Tex2D_F1_sampler, float2(0.1, (0.3+0.1) ), float2(0.01, 0.02), float2(-0.02, 0.01), int2( (3-1) ,5) );
+
+ //Texture2DArray
+ Tex2D_F_A1.SampleGrad( Tex2D_F_A1_sampler, f3UVW.xyz, f2ddxUV.xy, f2ddyUV.xy );
+ Tex2D_F_A1.SampleGrad( Tex2D_F_A1_sampler, f3UVW.xyz, f2ddxUV.xy, f2ddyUV.xy, Offset.xy );
+
+ //Texture3D
+ Tex3D_F1.SampleGrad(Tex3D_F1_sampler, f3UVW.xyz, f3ddxUVW.xyz, f3ddyUVW.xyz );
+ Tex3D_F1.SampleGrad(Tex3D_F1_sampler, f3UVW.xyz, f3ddxUVW.xyz, f3ddyUVW.xyz, Offset.xyz );
+
+ //TextureCube
+ TexC_F1.SampleGrad(TexC_F1_sampler, f3UVW.xyz, f3ddxUVW.xyz, f3ddyUVW.xyz );
+ // Offset not supported
+
+#ifndef GL_ES
+ // TextureCubeArray
+ TexC_F_A1.SampleGrad( TexC_F_A1_sampler, f4UVWQ.xyzw, f3ddxUVW.xyz, f3ddyUVW.xyz );
+ TexC_F_A1.SampleGrad( TexC_F_A1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), float3(0.01,0.02,0.03), float3(-0.01,-0.02,-0.03) );
+ // Offset not supported
+#endif
+}
+
+
+
+void TestSampleCmp()
+{
+ float3 f3UVW = float3(0.2, 0.3, 0.5);
+ int3 Offset = int3(3, 6, 2);
+ float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0);
+ float CompareVal = 0.7;
+
+#ifndef GL_ES
+ // Texture1D
+ Tex1DS1.SampleCmp(Tex1DS1_sampler, f3UVW.x, CompareVal);
+ Tex1DS1.SampleCmp(Tex1DS1_sampler, f3UVW.x, CompareVal, Offset.x);
+
+ // Texture1DArray
+ Tex1DAS1.SampleCmp(Tex1DAS1_sampler, f3UVW.xy, CompareVal);
+ Tex1DAS1.SampleCmp(Tex1DAS1_sampler, f3UVW.xy, CompareVal, Offset.x);
+#endif
+
+ //Texture2D
+ Tex2DS1.SampleCmp( Tex2DS1_sampler, f3UVW.xy, CompareVal );
+ Tex2DS1.SampleCmp( Tex2DS1_sampler, f3UVW.xy, CompareVal, Offset.xy );
+ Tex2DS1.SampleCmp( Tex2DS1_sampler, float2(0.1, 0.3), 4.0 );
+ Tex2DS1.SampleCmp( Tex2DS1_sampler, float2(0.1, (0.3+0.1) ), 4.0, int2( (3-1) ,5) );
+ Tex2DS_F5.SampleCmp( Tex2DS_F5_sampler, f3UVW.xy, CompareVal );
+
+ //Texture2DArray
+ Tex2DAS1.SampleCmp( Tex2DAS1_sampler, f3UVW.xyz, CompareVal );
+ // This seems to be another bug on Intel driver: the following line does not compile:
+ // Tex2DAS1.SampleCmp( Tex2DAS1_sampler, f3UVW.xyz, CompareVal, Offset.xy );
+
+ //TextureCube
+ TexCS1.SampleCmp(TexCS1_sampler, f3UVW.xyz, CompareVal );
+ // Offset not supported
+
+#ifndef GL_ES
+ // TextureCubeArray
+ TexCAS1.SampleCmp( TexCAS1_sampler, f4UVWQ.xyzw, CompareVal );
+ TexCAS1.SampleCmp( TexCAS1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), 0.5 );
+ // Offset not supported
+#endif
+}
+
+
+
+void TestSampleCmpLevelZero()
+{
+ float3 f3UVW = float3(0.2, 0.3, 0.5);
+ int3 Offset = int3(3, 6, 2);
+ float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0);
+ float CompareVal = 0.7;
+
+#ifndef GL_ES
+ // Texture1D
+ Tex1DS1.SampleCmpLevelZero(Tex1DS1_sampler, f3UVW.x, CompareVal);
+ Tex1DS1.SampleCmpLevelZero(Tex1DS1_sampler, f3UVW.x, CompareVal, Offset.x);
+
+ // Texture1DArray
+ Tex1DAS1.SampleCmpLevelZero(Tex1DAS1_sampler, f3UVW.xy, CompareVal);
+ Tex1DAS1.SampleCmpLevelZero(Tex1DAS1_sampler, f3UVW.xy, CompareVal, Offset.x);
+#endif
+
+ //Texture2D
+ Tex2DS1.SampleCmpLevelZero( Tex2DS1_sampler, f3UVW.xy, CompareVal );
+ Tex2DS1.SampleCmpLevelZero( Tex2DS1_sampler, f3UVW.xy, CompareVal, Offset.xy );
+ Tex2DS1.SampleCmpLevelZero( Tex2DS1_sampler, float2(0.1, 0.3), 4.0 );
+ Tex2DS1.SampleCmpLevelZero( Tex2DS1_sampler, float2(0.1, (0.3+0.1) ), 4.0, int2( (3-1) ,5) );
+
+ //Texture2DArray
+ Tex2DAS1.SampleCmpLevelZero( Tex2DAS1_sampler, f3UVW.xyz, CompareVal );
+ // This seems to be another bug on Intel driver: the following line does not compile:
+ // Tex2DAS1.SampleCmpLevelZero( Tex2DAS1_sampler, f3UVW.xyz, CompareVal, Offset.xy );
+
+ //TextureCube
+ TexCS1.SampleCmpLevelZero(TexCS1_sampler, f3UVW.xyz, CompareVal );
+ // Offset not supported
+
+#ifndef GL_ES
+ // TextureCubeArray
+ TexCAS1.SampleCmpLevelZero( TexCAS1_sampler, f4UVWQ.xyzw, CompareVal );
+ TexCAS1.SampleCmpLevelZero( TexCAS1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), 0.5 );
+ // Offset not supported
+#endif
+}
+
+
+
+void TestLoad()
+{
+ int4 Location = int4(2, 5, 1, 10);
+ int3 Offset = int3(5, 10, 20);
+
+#ifndef GL_ES
+ // Texture1D
+ {
+ Tex1D_F1.Load(Location.xy);
+ Tex1D_F1.Load(Location.xy, Offset.x);
+ Tex1D_I.Load(Location.xy);
+ Tex1D_I.Load(Location.xy, Offset.x);
+ Tex1D_U.Load(Location.xy);
+ Tex1D_U.Load(Location.xy, Offset.x);
+ }
+
+ // Texture1DArray
+ {
+ Tex1D_F_A1.Load(Location.xyz);
+ Tex1D_F_A1.Load(Location.xyz, Offset.x);
+ Tex1D_U_A.Load(Location.xyz);
+ Tex1D_U_A.Load(Location.xyz, Offset.x);
+ Tex1D_I_A.Load(Location.xyz);
+ Tex1D_I_A.Load(Location.xyz, Offset.x);
+ }
+#endif
+
+ //Texture2D
+ {
+ Tex2D_F1.Load(Location.xyz);
+ Tex2D_F1.Load(Location.xyz, Offset.xy);
+ Tex2D_F1.Load(Tex2D_I.Load(Location.xyz).xyz + Tex2D_I.Load(Location.xyz).xyz);
+ Tex2D_I.Load(Location.xyz);
+ Tex2D_I.Load(Location.xyz, Offset.xy);
+ Tex2D_U.Load(Location.xyz);
+ Tex2D_U.Load(Location.xyz, Offset.xy);
+ }
+
+ //Texture2DArray
+ {
+ Tex2D_F_A1.Load(Location.xyzw);
+ Tex2D_F_A1.Load(Location.xyzw, Offset.xy);
+ Tex2D_U_A.Load(Location.xyzw);
+ Tex2D_U_A.Load(Location.xyzw, Offset.xy);
+ Tex2D_I_A.Load(Location.xyzw);
+ Tex2D_I_A.Load(Location.xyzw, Offset.xy);
+ }
+
+ //Texture3D
+ {
+ Tex3D_F1.Load(Location.xyzw);
+ Tex3D_F1.Load(Location.xyzw, Offset.xyz);
+ Tex3D_U.Load(Location.xyzw);
+ Tex3D_U.Load(Location.xyzw, Offset.xyz);
+ Tex3D_I.Load(Location.xyzw);
+ Tex3D_I.Load(Location.xyzw, Offset.xyz);
+ }
+
+#ifndef GL_ES // This should work on ES3.1, but compiler fails for no reason
+ // Texture2DMS
+ {
+ Tex2DMS_F1.Load(Location.xy, 1);
+ Tex2DMS_F1.Load(Location.xy, 1, Offset.xy);
+ Tex2DMS_I.Load(Location.xy, 1);
+ Tex2DMS_I.Load(Location.xy, 1, Offset.xy);
+ Tex2DMS_U.Load(Location.xy, 1);
+ Tex2DMS_U.Load(Location.xy, 1, Offset.xy);
+ }
+#endif
+
+#ifndef GL_ES
+ // Texture2DMSArray
+ {
+ Tex2DMS_F_A1.Load(Location.xyz, 1);
+ Tex2DMS_F_A1.Load(Location.xyz, 1, Offset.xy);
+ Tex2DMS_I_A.Load(Location.xyz, 1);
+ Tex2DMS_I_A.Load(Location.xyz, 1, Offset.xy);
+ Tex2DMS_U_A.Load(Location.xyz, 1);
+ Tex2DMS_U_A.Load(Location.xyz, 1, Offset.xy);
+ }
+#endif
+}
+
+
+
+
+void TestGather()
+{
+ float4 Location = float4(0.2, 0.5, 0.1, 0.7);
+ int3 Offset = int3(5, 10, 20);
+
+ //Texture2D
+ {
+ Tex2D_F1.Gather(Tex2D_F1_sampler, Location.xy);
+ Tex2D_F1.Gather(Tex2D_F1_sampler, Location.xy, Offset.xy);
+ //Tex2D_I.Gather(Location.xyz);
+ //Tex2D_I.Gather(Location.xyz, Offset.xy);
+ //Tex2D_U.Gather(Location.xyz);
+ //Tex2D_U.Gather(Location.xyz, Offset.xy);
+ }
+
+ //Texture2DArray
+ {
+ Tex2D_F_A1.Gather(Tex2D_F_A1_sampler, Location.xyz);
+ Tex2D_F_A1.Gather(Tex2D_F_A1_sampler, Location.xyz, Offset.xy);
+ //Tex2D_U_A.Gather(Location.xyzw);
+ //Tex2D_U_A.Gather(Location.xyzw, Offset.xy);
+ //Tex2D_I_A.Gather(Location.xyzw);
+ //Tex2D_I_A.Gather(Location.xyzw, Offset.xy);
+ }
+
+ // TextureCube
+ {
+ TexC_F1.Gather(TexC_F1_sampler, Location.xyz);
+ //TexC_I.Gather(Location.xyz);
+ //TexC_U.Gather(Location.xyz);
+ }
+#ifndef GL_ES
+ // TextureCubeArray
+ {
+ TexC_F_A1.Gather(TexC_F_A1_sampler, Location.xyzw);
+ //TexC_I_A.Gather(Location.xyzw);
+ //TexC_U_A.Gather(Location.xyzw);
+ }
+#endif
+}
+
+
+
+void TestGatherCmp()
+{
+ float4 Location = float4(0.2, 0.5, 0.1, 0.7);
+ int3 Offset = int3(5, 10, 20);
+ float CompareVal = 0.01;
+
+ //Texture2D
+ {
+ Tex2DS1.GatherCmp(Tex2DS1_sampler, Location.xy, CompareVal);
+ Tex2DS1.GatherCmp(Tex2DS1_sampler, Location.xy, CompareVal, Offset.xy);
+ }
+
+ //Texture2DArray
+ {
+ Tex2DAS1.GatherCmp(Tex2DAS1_sampler, Location.xyz, CompareVal);
+ Tex2DAS1.GatherCmp(Tex2DAS1_sampler, Location.xyz, CompareVal, Offset.xy);
+ }
+
+ // TextureCube
+ {
+ TexCS1.GatherCmp(TexCS1_sampler, Location.xyz, CompareVal);
+ }
+#ifndef GL_ES
+ // TextureCubeArray
+ {
+ TexCAS1.GatherCmp(TexCAS1_sampler, Location.xyzw, CompareVal);
+ }
+#endif
+}
+
+struct InnerStruct
+{
+ float f[4];
+ int i;
+ uint u;
+ bool b;
+};
+
+struct OuterStruct
+{
+ InnerStruct inner;
+ float f;
+ int i;
+ uint u;
+ bool b;
+};
+
+struct VSInputSubStruct
+{
+ float3 f3Normal : ATTRIB2;
+ int VertexId : SV_VertexId;
+};
+
+struct VSInput
+{
+ float3 f3PosWS : ATTRIBUTE;
+ float2 f2UV : ATTRIB1;
+ VSInputSubStruct SubStruct;
+};
+
+struct VSOutputSubStruct
+{
+ float4 f4Attrib : F4_ATTRIB2;
+ int iAttrib : I_ATTRIB;
+};
+struct VSOutput
+{
+ float2 f2Attrib : F2_ATTRIB;
+ float3 f3Attrib : F3_ATTRIB;
+ float4 f4Attrib : F4_ATTRIB;
+ uint uiAttrib : UI_ATTRIB;
+ uint3 ui3Attrib : UI3_ATTRIB;
+ float4 f4PosPS : SV_Position;
+ VSOutputSubStruct SubStruct;
+};
+
+float4 TestVS ( VSInput In,
+ in float3 f3UV : IN_UV,
+ in uint InstID : SV_InstanceID,
+ out VSOutput Out,
+ out float fAttrib : F_ATTRIB,
+ out int4 i4Attrib : I4_ATTRIB) : RET_ATTRIB
+{
+ Out.f4PosPS = float4(1.0, 2.0, 3.0, 4.0);
+ fAttrib = 1.0;
+ Out.f2Attrib = float2(5.0, 6.0) + In.f2UV;
+ Out.f3Attrib = float3(7.0, 8.0, 9.0) + In.f3PosWS + f3UV + In.SubStruct.f3Normal;
+ Out.f4Attrib = float4(10.0, 11.0, 12.0, 13.0);
+ if( In.f2UV.x < 0.5 )
+ return float4(0.2,0.3,0.4,0.5);
+
+ Out.f4Attrib.z = 0.1;
+ Out.SubStruct.f4Attrib = float4(10.0, 11.0, 12.0, 13.0);
+ //Out.uiAttrib = 1u;
+ //Out.ui3Attrib = uint3(2u, 3u, 4u);
+ //Out.iAttrib = 5;
+ //Out.i4Attrib = int4(5, 6, 7, 8);
+ return float4(0.5,0.6,0.7,0.8);
+}
+
+
+
+void TestFuncArgs1( Texture2D<float4> Arg1,
+ SamplerState Arg1_sampler,
+ Texture2D<float> Arg2,
+ SamplerComparisonState Arg2_sampler,
+ Texture3D<float> Arg3)
+{
+ uint uWidth, uHeight, uMipLevels;
+ Arg1.GetDimensions(uWidth, uHeight);
+
+ Arg2.SampleCmp( Arg2_sampler, float2(0.5,0.5), 0.1 );
+
+ Arg3.Load( int4(1, 2, 3, 0) );
+}
+
+void TestFuncArgs2( Texture3D<int> Arg1,
+ Texture2DArray<float4> Arg2,
+ SamplerState Arg2_sampler,
+ Texture2D<float> Arg3)
+{
+ Arg1.Load( int4(1, 2, 3, 0) );
+
+ uint uWidth, uHeight, uElems;
+ Arg2.GetDimensions(uWidth, uHeight, uElems);
+
+ Arg3.Load(int3(10,15,3) );
+}
+
+struct PSOutputSubStruct
+{
+ float4 Color4 : SV_Target4;
+};
+struct PSOutput
+{
+ float4 Color3 : SV_Target3;
+ PSOutputSubStruct substr;
+};
+
+float TestPS ( in VSOutput In,
+ out float4 Color : SV_Target,
+ out float3 Color2 : SV_Target2,
+ out PSOutput Out) : SV_Depth
+{
+ float4 Pos = In.f4PosPS;
+
+ Out.Color3 = float4(0.0, 1.0, 2.0, 3.0);
+ Out.substr.Color4 = float4(0.0, 1.0, 2.0, 3.0);
+
+ TestFuncArgs1( Tex2D_F6,
+ Tex2D_F6_sampler,
+ Tex2DS_F5,
+ Tex2DS_F5_sampler,
+ Tex3D_F3);
+ TestFuncArgs2( Tex3D_I,
+ Tex2D_F_A3,
+ Tex2D_F_A3_sampler,
+ Tex2D_F2);
+ {
+ float2 a = float2(0.0, 0.0);
+ float2 b = float2(1.0, 1.0);
+ float2 c = float2(2.0, 2.0);
+ a += b;
+ a-=b;
+ a *=c;
+ a/= c;
+ float2 d = a;
+
+ int2 x = int2(1, 2);
+ int2 y = int2(2, 1);
+ x %= y;
+ x &= y;
+ x |= y;
+ x ^= y;
+ x >>= y;
+ x <<= y;
+ x = x | y;
+ x = x & y;
+ x = x % y;
+ x = x ^ y;
+ x = ~y;
+ x = x >> y;
+ x = x << y;
+ x++;
+ ++x;
+ y--;
+ --y;
+ if( x.x>= y.x || y.y >=x.y && x.y == y.x && y.y==x.y && !(x.x==y.y) )
+ x += y;
+
+ [flatten]
+ if(x.x==y.x)
+ x.x=y.x;
+
+ [branch]
+ if(x.x==y.x)
+ x.x+=y.x;
+ {
+ [loop]
+ for(int i=0;i<10;++i)
+ x.x+=1;
+ }
+
+ {
+ [unroll]
+ for(int i=0;i<10;++i)
+ y.x+=1;
+ }
+
+ Color = In.f4Attrib;
+ Color2 = In.f3Attrib;
+ if( Pos.x < 0.2 ) return 0.1;
+ }
+
+ {
+ int i1 = 1;
+ int2 i2 = int2(1, 2);
+ int3 i3 = int3(1, 2, 3);
+ int4 i4 = int4(1,2,3,4);
+
+ float f1 = 1.0;
+ float2 f2 = float2(1.0, 2.0);
+ float3 f3 = float3(1.0, 2.0, 3.0);
+ float4 f4 = float4(1.0,2.0,3.0,4.0);
+ float f1_ = 2.0;
+ float2 f2_ = float2(11.0, 12.0);
+ float3 f3_ = float3(11.0, 12.0, 13.0);
+ float4 f4_ = float4(11.0,12.0,13.0,14.0);
+
+ uint u1 = 1u;
+ uint2 u2 = uint2(1u, 2u);
+ uint3 u3 = uint3(1u, 2u, 3u);
+ uint4 u4 = uint4(1u, 2u,3u,4u);
+
+ bool b1 = true;
+ bool2 b2 = bool2(true, false);
+ bool3 b3 = bool3(true, false, true);
+ bool4 b4 = bool4(true, false, true, false);
+
+ i1 = abs ( i1 ); i2 = abs ( i2 ); i3 = abs ( i3 ); i4 = abs ( i4 );
+ f1 = abs ( f1 ); f2 = abs ( f2 ); f3 = abs ( f3 ); f4 = abs ( f4 );
+
+ b1 = all ( b2 ); b1 = all ( b3 ); b1 = all ( b4 );
+ b1 = any ( b2 ); b1 = any ( b3 ); b1 = any ( b4 );
+
+ f1 = ceil( f1 ); f2 = ceil( f2 ); f3 = ceil( f3 ); f4 = ceil( f4 );
+
+ f1 = clamp(f1,f1,f1); f2 = clamp(f2,f2,f2); f3 = clamp(f3,f3,f3); f4 = clamp(f4,f4,f4);
+ i1 = clamp(i1,i1,i1); i2 = clamp(i2,i2,i2); i3 = clamp(i3,i3,i3); i4 = clamp(i4,i4,i4);
+ u1 = clamp(u1,u1,u1); u2 = clamp(u2,u2,u2); u3 = clamp(u3,u3,u3); u4 = clamp(u4,u4,u4);
+
+ // Trigonometric functions
+ f1 = cos( f1 ); f2 = cos( f2 ); f3 = cos( f3 ); f4 = cos( f4 );
+ f1 = sin( f1 ); f2 = sin( f2 ); f3 = sin( f3 ); f4 = sin( f4 );
+ f1 = tan( f1 ); f2 = tan( f2 ); f3 = tan( f3 ); f4 = tan( f4 );
+ f1 = cosh( f1 ); f2 = cosh( f2 ); f3 = cosh( f3 ); f4 = cosh( f4 );
+ f1 = sinh( f1 ); f2 = sinh( f2 ); f3 = sinh( f3 ); f4 = sinh( f4 );
+ f1 = tanh( f1 ); f2 = tanh( f2 ); f3 = tanh( f3 ); f4 = tanh( f4 );
+ f1 = acos( f1 ); f2 = acos( f2 ); f3 = acos( f3 ); f4 = acos( f4 );
+ f1 = asin( f1 ); f2 = asin( f2 ); f3 = asin( f3 ); f4 = asin( f4 );
+ f1 = atan( f1 ); f2 = atan( f2 ); f3 = atan( f3 ); f4 = atan( f4 );
+ f1 = atan2(f1,f1); f2 = atan2(f2,f2); f3 = atan2(f3,f3); f4 = atan2(f4,f4);
+ f1 = degrees( f1 ); f2 = degrees( f2 ); f3 = degrees( f3 ); f4 = degrees( f4 );
+ f1 = radians( f1 ); f2 = radians( f2 ); f3 = radians( f3 ); f4 = radians( f4 );
+
+ // Exponential functions
+ f1 = pow( f1, f1 ); f2 = pow( f2,f2 ); f3 = pow( f3,f3 ); f4 = pow( f4,f4 );
+ f1 = exp( f1 ); f2 = exp( f2 ); f3 = exp( f3 ); f4 = exp( f4 );
+ f1 = log( f1 ); f2 = log( f2 ); f3 = log( f3 ); f4 = log( f4 );
+ f1 = exp2( f1 ); f2 = exp2( f2 ); f3 = exp2( f3 ); f4 = exp2( f4 );
+ f1 = log2( f1 ); f2 = log2( f2 ); f3 = log2( f3 ); f4 = log2( f4 );
+ f1 = sqrt( f1 ); f2 = sqrt( f2 ); f3 = sqrt( f3 ); f4 = sqrt( f4 );
+ f1 = rsqrt( f1 ); f2 = rsqrt( f2 ); f3 = rsqrt( f3 ); f4 = rsqrt( f4 );
+ f1 = log10( f1 ); f2 = log10( f2 ); f3 = log10( f3 ); f4 = log10( f4 );
+
+ i1 = sign ( i1 ); i2 = sign ( i2 ); i3 = sign ( i3 ); i4 = sign ( i4 );
+ f1 = sign ( f1 ); f2 = sign ( f2 ); f3 = sign ( f3 ); f4 = sign ( f4 );
+ f1 = floor ( f1 ); f2 = floor( f2 ); f3 = floor( f3 ); f4 = floor( f4 );
+ f1 = trunc ( f1 ); f2 = trunc( f2 ); f3 = trunc( f3 ); f4 = trunc( f4 );
+ f1 = round ( f1 ); f2 = round( f2 ); f3 = round( f3 ); f4 = round( f4 );
+ f1 = frac ( f1 ); f2 = frac ( f2 ); f3 = frac ( f3 ); f4 = frac ( f4 );
+
+ f1 = 1.0;
+ f2 = float2(1.0, 2.0);
+ f3 = float3(1.0, 2.0, 3.0);
+ f4 = float4(1.0,2.0,3.0,4.0);
+ f1 = fmod ( f1, f1 ); f2 = fmod ( f2, f2 ); f3 = fmod ( f3, f3 ); f4 = fmod ( f4, f4 );
+ f1 = modf ( f1, f1 ); f2 = modf ( f2, f2 ); f3 = modf ( f3, f3 ); f4 = modf ( f4, f4 );
+
+ f1 = min(f1,f1); f2 = min(f2,f2); f3 = min(f3,f3); f4 = min(f4,f4);
+ i1 = min(i1,i1); i2 = min(i2,i2); i3 = min(i3,i3); i4 = min(i4,i4);
+ u1 = min(u1,u1); u2 = min(u2,u2); u3 = min(u3,u3); u4 = min(u4,u4);
+
+ f1 = max(f1,f1); f2 = max(f2,f2); f3 = max(f3,f3); f4 = max(f4,f4);
+ i1 = max(i1,i1); i2 = max(i2,i2); i3 = max(i3,i3); i4 = max(i4,i4);
+ u1 = max(u1,u1); u2 = max(u2,u2); u3 = max(u3,u3); u4 = max(u4,u4);
+
+ f1 = lerp(f1,f1,f1); f2 = lerp(f2,f2,f2); f3 = lerp(f3,f3,f3); f4 = lerp(f4,f4,f4);
+ f1 = step(f1,f1); f2 = step(f2,f2); f3 = step(f3,f3); f4 = step(f4,f4);
+ f1 = smoothstep(f1,f1_,f1); f2 = smoothstep(f2,f2_,f2); f3 = smoothstep(f3,f3_,f3); f4 = smoothstep(f4,f4_,f4);
+
+ b1 = isnan ( f1/Pos.x ); b2 = isnan( f2/Pos.x ); b3 = isnan( f3/Pos.x ); b4 = isnan( f4/Pos.x );
+ b1 = isinf ( f1/Pos.x ); b2 = isinf( f2/Pos.x ); b3 = isinf( f3/Pos.x ); b4 = isinf( f4/Pos.x );
+ b1 = isfinite ( f1/Pos.x ); b2 = isfinite( f2/Pos.x ); b3 = isfinite( f3/Pos.x ); b4 = isfinite( f4/Pos.x );
+ f1 = mad(f1,f1,f1); f2 = mad(f2,f2,f2); f3 = mad(f3,f3,f3); f4 = mad(f4,f4,f4);
+
+ f1 = distance(f1,f1); f1 = distance(f2,f2); f1 = distance(f3,f3); f1 = distance(f4,f4);
+ f1 = length(f1); f1 = length(f2); f1 = length(f3); f1 = length(f4);
+ f1 = dot(f1,f1); f1 = dot(f2,f2); f1 = dot(f3,f3); f1 = dot(f4,f4);
+ f3 = cross( f3, f3 );
+
+ f1 = 1.0;
+ f2 = float2(1.0, 2.0);
+ f3 = float3(1.0, 2.0, 3.0);
+ f4 = float4(1.0,2.0,3.0,4.0);
+ f1 = normalize(f1); f2 = normalize(f2); f3 = normalize(f3); f4 = normalize(f4);
+ f1 = reflect(f1,f1); f2 = reflect(f2,f2); f3 = reflect(f3,f3); f4 = reflect(f4,f4);
+ f1 = refract(f1,f1,1.0); f2 = refract(f2,f2,1.0); f3 = refract(f3,f3,1.0); f4 = refract(f4,f4,1.0);
+ f1 = faceforward(f1,f1,f1); f2 = faceforward(f2,f2,f2); f3 = faceforward(f3,f3,f3); f4 = faceforward(f4,f4,f4);
+
+ //f1 = dst(f1,f1); f1 = dst(f2,f2); f1 = dst(f3,f3); f1 = dst(f4,f4);
+ f1 = rcp(f1); f2 = rcp(f2); f3 = rcp(f3); f4 = rcp(f4);
+
+ i1 = countbits(u1); i2 = countbits(u2); i3 = countbits(u3); i4 = countbits(u4);
+ i1 = countbits(i1); i2 = countbits(i2); i3 = countbits(i3); i4 = countbits(i4);
+ i1 = firstbithigh(u1); i2 = firstbithigh(u2); i3 = firstbithigh(u3); i4 = firstbithigh(u4);
+ i1 = firstbithigh(i1); i2 = firstbithigh(i2); i3 = firstbithigh(i3); i4 = firstbithigh(i4);
+ i1 = firstbitlow(u1); i2 = firstbitlow(u2); i3 = firstbitlow(u3); i4 = firstbitlow(u4);
+ i1 = firstbitlow(i1); i2 = firstbitlow(i2); i3 = firstbitlow(i3); i4 = firstbitlow(i4);
+ u1 = reversebits(u1); u2 = reversebits(u2); u3 = reversebits(u3); u4 = reversebits(u4);
+ i1 = reversebits(i1); i2 = reversebits(i2); i3 = reversebits(i3); i4 = reversebits(i4);
+
+ f1 = saturate(f1); f2 = saturate(f2); f3 = saturate(f3); f4 = saturate(f4);
+ sincos(f1,f1,f1_); sincos(f2,f2,f2_); sincos(f3,f3,f3_); sincos(f4,f4,f4_);
+
+ f1 = frexp(f1_, i1); f2 = frexp(f2_, i2); f3 = frexp(f3_, i3); f4 = frexp(f4_, i4);
+ f1 = ldexp(f1, i1); f2 = ldexp(f2, i2); f3 = ldexp(f3, i3); f4 = ldexp(f4, i4);
+
+ float4x4 f4x4;
+ f4x4[0] = float4(0.0, 1.0/Pos.x, 2.0/Pos.y, 3.0);
+ f4x4[1] = float4(0.0, 1.0/Pos.x, 2.0/Pos.y, 3.0);
+ f4x4[2] = float4(0.0, 1.0/Pos.x, 2.0/Pos.y, 3.0);
+ f4x4[3] = float4(0.0, 1.0/Pos.x, 2.0/Pos.y, 3.0);
+ f4x4 = transpose(f4x4);
+ f1 = determinant( f4x4 );
+
+ float3x3 f3x3;
+ f3x3[0] = float3(0.0, 1.0/Pos.x, 2.0/Pos.y);
+ f3x3[1] = float3(0.0, 1.0/Pos.x, 2.0/Pos.y);
+ f3x3[2] = float3(0.0, 1.0/Pos.x, 2.0/Pos.y);
+ f3x3 = transpose(f3x3);
+ f1 = determinant( f3x3 );
+
+ float2x2 f2x2;
+ f2x2[0] = float2(0.0, 1.0/Pos.x);
+ f2x2[1] = float2(0.0, 1.0/Pos.x);
+ f2x2 = transpose(f2x2);
+ f1 = determinant( f2x2 );
+
+ f1 = ddx( Pos.x ); f2 = ddx( Pos.xy ); f3 = ddx( Pos.xyz ); f4 = ddx( Pos.xyzw );
+ f1 = ddy( Pos.x ); f2 = ddy( Pos.xy ); f3 = ddy( Pos.xyz ); f4 = ddy( Pos.xyzw );
+ f1 = ddx_coarse( Pos.x ); f2 = ddx_coarse( Pos.xy ); f3 = ddx_coarse( Pos.xyz ); f4 = ddx_coarse( Pos.xyzw );
+ f1 = ddy_coarse( Pos.x ); f2 = ddy_coarse( Pos.xy ); f3 = ddy_coarse( Pos.xyz ); f4 = ddy_coarse( Pos.xyzw );
+ f1 = ddx_fine( Pos.x ); f2 = ddx_fine( Pos.xy ); f3 = ddx_fine( Pos.xyz ); f4 = ddx_fine( Pos.xyzw );
+ f1 = ddy_fine( Pos.x ); f2 = ddy_fine( Pos.xy ); f3 = ddy_fine( Pos.xyz ); f4 = ddy_fine( Pos.xyzw );
+#ifdef FRAGMENT_SHADER
+ f1 = fwidth( Pos.x ); f2 = fwidth( Pos.xy ); f3 = fwidth( Pos.xyz ); f4 = fwidth( Pos.xyzw );
+#endif
+
+ f1 = asfloat( f1 ); f2 = asfloat( f2 ); f3 = asfloat( f3 ); f4 = asfloat( f4 );
+ f1 = asfloat( i1 ); f2 = asfloat( i2 ); f3 = asfloat( i3 ); f4 = asfloat( i4 );
+ f1 = asfloat( u1 ); f2 = asfloat( u2 ); f3 = asfloat( u3 ); f4 = asfloat( u4 );
+
+ i1 = asint( f1 ); i2 = asint( f2 ); i3 = asint( f3 ); i4 = asint( f4 );
+ i1 = asint( i1 ); i2 = asint( i2 ); i3 = asint( i3 ); i4 = asint( i4 );
+ i1 = asint( u1 ); i2 = asint( u2 ); i3 = asint( u3 ); i4 = asint( u4 );
+
+ u1 = asuint( f1 ); u2 = asuint( f2 ); u3 = asuint( f3 ); u4 = asuint( f4 );
+ u1 = asuint( i1 ); u2 = asuint( i2 ); u3 = asuint( i3 ); u4 = asuint( i4 );
+ u1 = asuint( u1 ); u2 = asuint( u2 ); u3 = asuint( u3 ); u4 = asuint( u4 );
+
+ f1 = f16tof32( u1 ); f2 = f16tof32( u2 ); f3 = f16tof32( u3 ); f4 = f16tof32( u4 );
+ f1 = f16tof32( i1 ); f2 = f16tof32( i2 ); f3 = f16tof32( i3 ); f4 = f16tof32( i4 );
+ u1 = f32tof16( f1 ); u2 = f32tof16( f2 ); u3 = f32tof16( f3 ); u4 = f32tof16( f4 );
+#ifndef GL_ES
+ double d = asdouble( u1, u1 );
+#endif
+
+ f1 = noise( f1 ); f2 = noise( f2 ); f3 = noise( f3 ); f4 = noise( f4 );
+ }
+ return 1.0;
+}
+// Test comment \ No newline at end of file
diff --git a/HLSL2GLSLConverter/testshaders/IncludeTest.fxh b/HLSL2GLSLConverter/testshaders/IncludeTest.fxh
new file mode 100644
index 0000000..1c57710
--- /dev/null
+++ b/HLSL2GLSLConverter/testshaders/IncludeTest.fxh
@@ -0,0 +1,333 @@
+//--------------------------------------------------------------------------------------
+// Copyright 2013 Intel Corporation
+// All Rights Reserved
+//
+// Permission is granted to use, copy, distribute and prepare derivative works of this
+// software for any purpose and without fee, provided, that the above copyright notice
+// and this statement appear in all copies. Intel makes no representations about the
+// suitability of this software for any purpose. THIS SOFTWARE IS PROVIDED "AS IS."
+// INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, AND ALL LIABILITY,
+// INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, FOR THE USE OF THIS SOFTWARE,
+// INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY RIGHTS, AND INCLUDING THE
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Intel does not
+// assume any responsibility for any errors which may appear in this software nor any
+// responsibility to update it.
+//--------------------------------------------------------------------------------------
+
+# ifndef _STRCUTURES_FXH_
+# define _STRCUTURES_FXH_
+
+#define PI (3.1415928f)
+
+#ifdef __cplusplus
+
+#ifndef BOOL
+# define BOOL int32_t // Do not use bool, because sizeof(bool)==1 !
+#endif
+
+#ifndef TRUE
+# define TRUE 1
+#endif
+
+#ifndef FALSE
+# define FALSE 0
+#endif
+
+#else
+
+# define BOOL bool
+
+#endif
+
+#ifdef __cplusplus
+# define CHECK_STRUCT_ALIGNMENT(s) static_assert( sizeof(s) % 16 == 0, "sizeof("#s") is not multiple of 16" );
+#else
+# define CHECK_STRUCT_ALIGNMENT(s)
+#endif
+
+
+
+#define MAX_CASCADES 8
+struct CascadeAttribs
+{
+ float4 f4LightSpaceScale;
+ float4 f4LightSpaceScaledBias;
+ float4 f4StartEndZ;
+};
+#ifdef __cplusplus
+static_assert( (sizeof(CascadeAttribs) % 16) == 0, "sizeof(CascadeAttribs) is not multiple of 16" );
+#endif
+
+struct ShadowMapAttribs
+{
+ // 0
+#ifdef __cplusplus
+ float4x4 mWorldToLightView; // Matrices in HLSL are COLUMN-major while float4x4 is ROW major
+#else
+ matrix mWorldToLightView; // Transform from view space to light projection space
+#endif
+ // 16
+ CascadeAttribs Cascades[MAX_CASCADES];
+
+#ifdef __cplusplus
+ float fCascadeCamSpaceZEnd[MAX_CASCADES];
+ float4x4 mWorldToShadowMapUVDepth[MAX_CASCADES];
+#else
+ float4 f4CascadeCamSpaceZEnd[MAX_CASCADES/4];
+ matrix mWorldToShadowMapUVDepth[MAX_CASCADES];
+#endif
+
+ // Do not use bool, because sizeof(bool)==1 !
+ BOOL bVisualizeCascades;
+
+ float3 f3Padding;
+};
+#ifdef __cplusplus
+static_assert( (sizeof(ShadowMapAttribs) % 16) == 0, "sizeof(ShadowMapAttribs) is not multiple of 16" );
+#endif
+
+
+struct LightAttribs
+{
+ float4 f4DirOnLight;
+ float4 f4AmbientLight;
+ float4 f4LightScreenPos;
+ float4 f4ExtraterrestrialSunColor;
+
+ BOOL bIsLightOnScreen;
+ float3 f3Dummy;
+
+ ShadowMapAttribs ShadowAttribs;
+};
+CHECK_STRUCT_ALIGNMENT(LightAttribs);
+
+struct CameraAttribs
+{
+ float4 f4CameraPos; ///< Camera world position
+ float fNearPlaneZ;
+ float fFarPlaneZ; // fNearPlaneZ < fFarPlaneZ
+ float2 f2Dummy;
+
+#ifdef __cplusplus
+ float4x4 WorldViewProj;
+ //float4x4 mView;
+ float4x4 mProj;
+ float4x4 mViewProjInv;
+#else
+ matrix WorldViewProj;
+ //matrix mView;
+ matrix mProj;
+ matrix mViewProjInv;
+#endif
+};
+CHECK_STRUCT_ALIGNMENT(CameraAttribs);
+
+#define LIGHT_SCTR_TECHNIQUE_EPIPOLAR_SAMPLING 0
+#define LIGHT_SCTR_TECHNIQUE_BRUTE_FORCE 1
+
+#define CASCADE_PROCESSING_MODE_SINGLE_PASS 0
+#define CASCADE_PROCESSING_MODE_MULTI_PASS 1
+#define CASCADE_PROCESSING_MODE_MULTI_PASS_INST 2
+
+#define REFINEMENT_CRITERION_DEPTH_DIFF 0
+#define REFINEMENT_CRITERION_INSCTR_DIFF 1
+
+// Extinction evaluation mode used when attenuating background
+#define EXTINCTION_EVAL_MODE_PER_PIXEL 0// Evaluate extinction for each pixel using analytic formula
+ // by Eric Bruneton
+#define EXTINCTION_EVAL_MODE_EPIPOLAR 1 // Render extinction in epipolar space and perform
+ // bilateral filtering in the same manner as for
+ // inscattering
+
+#define SINGLE_SCTR_MODE_NONE 0
+#define SINGLE_SCTR_MODE_INTEGRATION 1
+#define SINGLE_SCTR_MODE_LUT 2
+
+#define MULTIPLE_SCTR_MODE_NONE 0
+#define MULTIPLE_SCTR_MODE_UNOCCLUDED 1
+#define MULTIPLE_SCTR_MODE_OCCLUDED 2
+
+#define TONE_MAPPING_MODE_EXP 0
+#define TONE_MAPPING_MODE_REINHARD 1
+#define TONE_MAPPING_MODE_REINHARD_MOD 2
+#define TONE_MAPPING_MODE_UNCHARTED2 3
+#define TONE_MAPPING_FILMIC_ALU 4
+#define TONE_MAPPING_LOGARITHMIC 5
+#define TONE_MAPPING_ADAPTIVE_LOG 6
+
+
+struct PostProcessingAttribs
+{
+ uint m_uiNumEpipolarSlices;
+ uint m_uiMaxSamplesInSlice;
+ uint m_uiInitialSampleStepInSlice;
+ uint m_uiEpipoleSamplingDensityFactor;
+
+ float m_fRefinementThreshold;
+ // do not use bool, because sizeof(bool)==1 and as a result bool variables
+ // will be incorrectly mapped on GPU constant buffer
+ BOOL m_bShowSampling;
+ BOOL m_bCorrectScatteringAtDepthBreaks;
+ BOOL m_bShowDepthBreaks;
+
+ BOOL m_bShowLightingOnly;
+ BOOL m_bOptimizeSampleLocations;
+ BOOL m_bEnableLightShafts;
+ uint m_uiInstrIntegralSteps;
+
+ float2 m_f2ShadowMapTexelSize;
+ uint m_uiShadowMapResolution;
+ uint m_uiMinMaxShadowMapResolution;
+
+ BOOL m_bUse1DMinMaxTree;
+ float m_fMaxShadowMapStep;
+ float m_fMiddleGray;
+ uint m_uiLightSctrTechnique;
+
+ int m_iNumCascades;
+ int m_iFirstCascade;
+ float m_fNumCascades;
+ float m_fFirstCascade;
+
+ uint m_uiCascadeProcessingMode;
+ uint m_uiRefinementCriterion;
+ BOOL m_bIs32BitMinMaxMipMap;
+ uint m_uiMultipleScatteringMode;
+
+ uint m_uiSingleScatteringMode;
+ BOOL m_bAutoExposure;
+ uint m_uiToneMappingMode;
+ BOOL m_bLightAdaptation;
+
+ float m_fWhitePoint;
+ float m_fLuminanceSaturation;
+ float2 f2Dummy;
+
+ uint m_uiExtinctionEvalMode;
+ BOOL m_bUseCustomSctrCoeffs;
+ float m_fAerosolDensityScale;
+ float m_fAerosolAbsorbtionScale;
+
+ float4 m_f4CustomRlghBeta;
+ float4 m_f4CustomMieBeta;
+
+#ifdef __cplusplus
+ PostProcessingAttribs() :
+ m_uiNumEpipolarSlices(512),
+ m_uiMaxSamplesInSlice(256),
+ m_uiInitialSampleStepInSlice(16),
+ // Note that sampling near the epipole is very cheap since only a few steps
+ // required to perform ray marching
+ m_uiEpipoleSamplingDensityFactor(2),
+ m_fRefinementThreshold(0.03f),
+ m_bShowSampling(FALSE),
+ m_bCorrectScatteringAtDepthBreaks(FALSE),
+ m_bShowDepthBreaks(FALSE),
+ m_bShowLightingOnly(FALSE),
+ m_bOptimizeSampleLocations(TRUE),
+ m_bEnableLightShafts(TRUE),
+ m_uiInstrIntegralSteps(30),
+ m_bUse1DMinMaxTree(TRUE),
+ m_fMaxShadowMapStep(16.f),
+ m_f2ShadowMapTexelSize(0,0),
+ m_uiMinMaxShadowMapResolution(0),
+ m_fMiddleGray(.18f),
+ m_uiLightSctrTechnique(LIGHT_SCTR_TECHNIQUE_EPIPOLAR_SAMPLING),
+ m_iNumCascades(0),
+ m_iFirstCascade(1),
+ m_fNumCascades(0),
+ m_fFirstCascade(1),
+ m_uiCascadeProcessingMode(CASCADE_PROCESSING_MODE_SINGLE_PASS),
+ m_uiRefinementCriterion(REFINEMENT_CRITERION_INSCTR_DIFF),
+ m_bIs32BitMinMaxMipMap(FALSE),
+ m_uiMultipleScatteringMode(MULTIPLE_SCTR_MODE_UNOCCLUDED),
+ m_uiSingleScatteringMode(SINGLE_SCTR_MODE_LUT),
+ m_bAutoExposure(TRUE),
+ m_uiToneMappingMode(TONE_MAPPING_MODE_UNCHARTED2),
+ m_bLightAdaptation(TRUE),
+ m_fWhitePoint(3e+0f),
+ m_fLuminanceSaturation(1e+0),
+ m_uiExtinctionEvalMode(EXTINCTION_EVAL_MODE_EPIPOLAR),
+ m_bUseCustomSctrCoeffs(FALSE),
+ m_fAerosolDensityScale(1.f),
+ m_fAerosolAbsorbtionScale(0.1f),
+ m_f4CustomRlghBeta( 5.8e-6f, 13.5e-6f, 33.1e-6f, 0.f ),
+ m_f4CustomMieBeta(2.e-5f, 2.e-5f, 2.e-5f, 0.f)
+ {}
+#endif
+};
+CHECK_STRUCT_ALIGNMENT(PostProcessingAttribs);
+
+struct AirScatteringAttribs
+{
+ // Angular Rayleigh scattering coefficient contains all the terms exepting 1 + cos^2(Theta):
+ // Pi^2 * (n^2-1)^2 / (2*N) * (6+3*Pn)/(6-7*Pn)
+ float4 f4AngularRayleighSctrCoeff;
+ // Total Rayleigh scattering coefficient is the integral of angular scattering coefficient in all directions
+ // and is the following:
+ // 8 * Pi^3 * (n^2-1)^2 / (3*N) * (6+3*Pn)/(6-7*Pn)
+ float4 f4TotalRayleighSctrCoeff;
+ float4 f4RayleighExtinctionCoeff;
+
+ // Note that angular scattering coefficient is essentially a phase function multiplied by the
+ // total scattering coefficient
+ float4 f4AngularMieSctrCoeff;
+ float4 f4TotalMieSctrCoeff;
+ float4 f4MieExtinctionCoeff;
+
+ float4 f4TotalExtinctionCoeff;
+ // Cornette-Shanks phase function (see Nishita et al. 93) normalized to unity has the following form:
+ // F(theta) = 1/(4*PI) * 3*(1-g^2) / (2*(2+g^2)) * (1+cos^2(theta)) / (1 + g^2 - 2g*cos(theta))^(3/2)
+ float4 f4CS_g; // x == 3*(1-g^2) / (2*(2+g^2))
+ // y == 1 + g^2
+ // z == -2*g
+
+ float fEarthRadius;
+ float fAtmTopHeight;
+ float2 f2ParticleScaleHeight;
+
+ float fTurbidity;
+ float fAtmTopRadius;
+ float m_fAerosolPhaseFuncG;
+ float m_fDummy;
+
+
+#ifdef __cplusplus
+ AirScatteringAttribs():
+ f2ParticleScaleHeight(7994.f, 1200.f),
+ // Air molecules and aerosols are assumed to be distributed
+ // between 6360 km and 6420 km
+ fEarthRadius(6360000.f),
+ fAtmTopHeight(80000.f),
+ fTurbidity(1.02f),
+ m_fAerosolPhaseFuncG(0.76f)
+ {
+ fAtmTopRadius = fEarthRadius + fAtmTopHeight;
+ }
+#endif
+};
+
+CHECK_STRUCT_ALIGNMENT(AirScatteringAttribs);
+
+struct MiscDynamicParams
+{
+ float fMaxStepsAlongRay; // Maximum number of steps during ray tracing
+ float fCascadeInd;
+ float2 f2WQ; // Used when pre-computing inscattering look-up table
+
+ uint uiDepthSlice;
+ float fElapsedTime;
+ float2 f2Dummy;
+
+#ifdef __cplusplus
+ uint ui4SrcMinMaxLevelXOffset;
+ uint ui4SrcMinMaxLevelYOffset;
+ uint ui4DstMinMaxLevelXOffset;
+ uint ui4DstMinMaxLevelYOffset;
+#else
+ uint4 ui4SrcDstMinMaxLevelOffset;
+#endif
+};
+CHECK_STRUCT_ALIGNMENT(MiscDynamicParams);
+
+#endif //_STRCUTURES_FXH_
diff --git a/HLSL2GLSLConverter/testshaders/SelectArraySlice.gsh b/HLSL2GLSLConverter/testshaders/SelectArraySlice.gsh
new file mode 100644
index 0000000..a2176ec
--- /dev/null
+++ b/HLSL2GLSLConverter/testshaders/SelectArraySlice.gsh
@@ -0,0 +1,27 @@
+#include "CommonShaderStructs.shinc"
+
+struct SelectArraySliceGSOut
+{
+ QuadVSOut VSOutput;
+ int RenderTargetIndex : SV_RenderTargetArrayIndex;
+};
+
+cbuffer cbTileAttribs
+{
+ int g_TileArrayIndex[4];
+}
+
+[maxvertexcount(3)]
+void SelectArraySliceGS(triangle QuadVSOut In[3],
+ inout TriangleStream<SelectArraySliceGSOut> triStream )
+{
+ uint InstID = In[0].m_uiInstID;
+ int RTIndex = g_TileArrayIndex[InstID];
+ for(int i=0; i<3; i++)
+ {
+ SelectArraySliceGSOut Out;
+ Out.VSOutput = In[i];
+ Out.RenderTargetIndex = RTIndex;
+ triStream.Append( Out );
+ }
+}
diff --git a/HLSL2GLSLConverter/testshaders/TessTestDX.dsh b/HLSL2GLSLConverter/testshaders/TessTestDX.dsh
new file mode 100644
index 0000000..0534a1a
--- /dev/null
+++ b/HLSL2GLSLConverter/testshaders/TessTestDX.dsh
@@ -0,0 +1,30 @@
+
+struct DSOutput
+{
+ float4 f4Position : SV_Position;
+};
+
+
+struct HS_CONSTANT_DATA_OUTPUT
+{
+ float Edges[4] : SV_TessFactor;
+ float Inside[2] : SV_InsideTessFactor;
+};
+
+struct HSOutput
+{
+ float4 Position : POS;
+ float3 Color : COL;
+};
+
+[domain("quad")]
+ /* partitioning = fractional_even, outputtopology = triangle_cw */
+float3 main( HS_CONSTANT_DATA_OUTPUT input,
+ float2 QuadUV : SV_DomainLocation,
+ OutputPatch<HSOutput, 2> QuadPatch,
+ out DSOutput Out ): COLOR
+{
+ Out.f4Position.xy = QuadPatch[0].Position.xy + QuadUV.xy * 0.1;
+ Out.f4Position.zw = QuadPatch[0].Position.zw;
+ return frac( (QuadPatch[0].Color + float3(QuadUV.xy, 1.0)) * float3(4121.35f, 8232.25f, 9124.42f) );
+}
diff --git a/HLSL2GLSLConverter/testshaders/TessTestDX.hsh b/HLSL2GLSLConverter/testshaders/TessTestDX.hsh
new file mode 100644
index 0000000..62f64d6
--- /dev/null
+++ b/HLSL2GLSLConverter/testshaders/TessTestDX.hsh
@@ -0,0 +1,47 @@
+
+struct VSOutput
+{
+ float4 f4Position : SV_Position;
+ float3 f3Color : COLOR;
+};
+
+// Output patch constant data.
+struct HS_CONSTANT_DATA_OUTPUT
+{
+ float Edges[4] : SV_TessFactor;
+};
+
+HS_CONSTANT_DATA_OUTPUT ConstantHS( InputPatch<VSOutput, 2> p,
+ out float Inside[1+1] : SV_InsideTessFactor,
+ uint BlockID : SV_PrimitiveID)
+{
+ HS_CONSTANT_DATA_OUTPUT Factors;
+ Factors.Edges[0] = 2.5;
+ Factors.Edges[1] = 4.5;
+ Factors.Edges[2] = 5.5;
+ Factors.Edges[3] = 7.5;
+ Inside[0] = 6.2;
+ Inside[1] = 7.3;
+ return Factors;
+}
+
+
+struct HSOutput
+{
+ float4 Position : SV_Position;
+ float3 Color : COL;
+};
+
+[domain("quad")]
+[partitioning("fractional_even")]
+[outputtopology("triangle_cw")]
+[outputcontrolpoints(2)]
+[patchconstantfunc("ConstantHS")]
+[maxtessfactor( (float)(32.f+2.f) )]
+HSOutput main(InputPatch<VSOutput, 2> inputPatch, uint uCPID : SV_OutputControlPointID)
+{
+ HSOutput Out;
+ Out.Position = inputPatch[uCPID].f4Position;
+ Out.Color = inputPatch[uCPID].f3Color;
+ return Out;
+} \ No newline at end of file
diff --git a/HLSL2GLSLConverter/testshaders/TessTestTriDX.dsh b/HLSL2GLSLConverter/testshaders/TessTestTriDX.dsh
new file mode 100644
index 0000000..1aa899e
--- /dev/null
+++ b/HLSL2GLSLConverter/testshaders/TessTestTriDX.dsh
@@ -0,0 +1,32 @@
+
+struct DSOutput
+{
+ float4 f4Position : SV_Position;
+ float3 f3Color : COLOR;
+};
+
+
+struct HS_CONSTANT_DATA_OUTPUT
+{
+ float Edges[3] : SV_TessFactor;
+ float Inside : SV_InsideTessFactor;
+};
+
+struct HSOutput
+{
+ float4 Position : POS;
+ float3 Color : COL;
+};
+
+[domain("tri")]
+/* partitioning = fractional_odd ,
+ outputtopology = triangle_cw */
+void main( HS_CONSTANT_DATA_OUTPUT Input,
+ float3 QuadUV : SV_DomainLocation,
+ OutputPatch<HSOutput, 1> QuadPatch,
+ out DSOutput Out)
+{
+ Out.f4Position.xy = QuadPatch[0].Position.xy + QuadUV.x * float2(-0.15, 0.0) + QuadUV.y * float2(0.0, 0.15) + QuadUV.z * float2(+0.15, 0.0);
+ Out.f4Position.zw = QuadPatch[0].Position.zw;
+ Out.f3Color = frac( (QuadPatch[0].Color + QuadUV.xyz * float3(4121.35f, 8232.25f, 9124.42f) ) );
+}
diff --git a/HLSL2GLSLConverter/testshaders/TessTestTriDX.hsh b/HLSL2GLSLConverter/testshaders/TessTestTriDX.hsh
new file mode 100644
index 0000000..6280ebd
--- /dev/null
+++ b/HLSL2GLSLConverter/testshaders/TessTestTriDX.hsh
@@ -0,0 +1,44 @@
+
+struct VSOutput
+{
+ float4 f4Position : SV_Position;
+ float3 f3Color : COLOR;
+};
+
+// Output patch constant data.
+struct HS_CONSTANT_DATA_OUTPUT
+{
+ float Edges[3] : SV_TessFactor;
+};
+
+HS_CONSTANT_DATA_OUTPUT ConstantHS( InputPatch<VSOutput, 1> p,
+ uint BlockID : SV_PrimitiveID,
+ out float Inside : SV_InsideTessFactor)
+{
+ HS_CONSTANT_DATA_OUTPUT Factors;
+ Factors.Edges[0] = 2.5 + float(BlockID);
+ Factors.Edges[1] = 4.5 + p[0].f4Position.x * 1.53;
+ Factors.Edges[2] = 5.5 - p[0].f4Position.y * 2.53;
+ Inside = 6.2 + p[0].f4Position.x * 1.53;
+ return Factors;
+}
+
+struct HSOutput
+{
+ float4 Position : POS;
+ float3 Color : COL;
+};
+
+[domain("tri")]
+[partitioning("fractional_odd")]
+[outputtopology("triangle_cw")]
+[outputcontrolpoints(1)]
+[patchconstantfunc("ConstantHS")]
+[maxtessfactor( (float)(32.f+2.f) )]
+HSOutput main(InputPatch<VSOutput, 1> inputPatch, uint uCPID : SV_OutputControlPointID)
+{
+ HSOutput Out;
+ Out.Position = inputPatch[uCPID].f4Position;
+ Out.Color = inputPatch[uCPID].f3Color;
+ return Out;
+} \ No newline at end of file
diff --git a/RenderScript/include/ConvenienceFunctions.h b/RenderScript/include/ConvenienceFunctions.h
index 334f4c9..01bcdf4 100644
--- a/RenderScript/include/ConvenienceFunctions.h
+++ b/RenderScript/include/ConvenienceFunctions.h
@@ -52,7 +52,7 @@ Diligent::RefCntAutoPtr<Diligent::ScriptParser> CreateRenderScriptFromFile( cons
Diligent::FileWrapper ScriptFile(FilePath);
if( !ScriptFile )
LOG_ERROR_AND_THROW( "Failed to open Lua source file" );
- Diligent::RefCntAutoPtr<Diligent::IDataBlob> pFileData( new Diligent::DataBlobImpl );
+ Diligent::RefCntAutoPtr<Diligent::IDataBlob> pFileData( Diligent::MakeNewRCObj<Diligent::DataBlobImpl>()(0) );
ScriptFile->Read( pFileData );
// Null-terminator is not read from the stream
@@ -60,7 +60,7 @@ Diligent::RefCntAutoPtr<Diligent::ScriptParser> CreateRenderScriptFromFile( cons
auto *ScriptText = reinterpret_cast<char*>(pFileData->GetDataPtr());
ScriptText[pFileData->GetSize() - 1] = 0;
- pScriptParser = new Diligent::ScriptParser( pRenderDevice );
+ pScriptParser = Diligent::MakeNewRCObj<Diligent::ScriptParser>()( pRenderDevice );
pScriptParser->Parse( ScriptText );
SetGlobalVars( pScriptParser );
pScriptParser->Run( pContext );
diff --git a/RenderScript/include/ScriptParser.h b/RenderScript/include/ScriptParser.h
index 828a945..137f0fd 100644
--- a/RenderScript/include/ScriptParser.h
+++ b/RenderScript/include/ScriptParser.h
@@ -33,10 +33,12 @@
namespace Diligent
{
- class ScriptParser : public Diligent::RefCountedObject<Diligent::IObject>
+ class ScriptParser : public RefCountedObject<IObject>
{
public:
- ScriptParser( IRenderDevice *pRenderDevice );
+ typedef RefCountedObject<IObject> TBase;
+
+ ScriptParser( IReferenceCounters *pRefCounters, IRenderDevice *pRenderDevice );
~ScriptParser();
virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface );
diff --git a/RenderScript/include/ShaderParser.h b/RenderScript/include/ShaderParser.h
index a1df356..b827def 100644
--- a/RenderScript/include/ShaderParser.h
+++ b/RenderScript/include/ShaderParser.h
@@ -52,6 +52,7 @@ namespace Diligent
String FilePathBuffer;
String EntryPointBuffer;
String SearchDirectoriesBuffer;
+ const char *SearchDirectories = nullptr;
std::vector<ShaderVariableDesc> m_VarDescBuffer;
std::vector<String> m_VarNamesBuffer;
std::vector<StaticSamplerDesc> m_StaticSamplersBuffer;
diff --git a/RenderScript/include/pch.h b/RenderScript/include/pch.h
index eec1e6d..ffe6b1c 100644
--- a/RenderScript/include/pch.h
+++ b/RenderScript/include/pch.h
@@ -37,8 +37,8 @@
#include "lauxlib.h"
#include "BasicTypes.h"
-#include "Errors.h"
#include "ParsingErrors.h"
+#include "Errors.h"
#include "RefCntAutoPtr.h"
#include "RenderDevice.h"
diff --git a/RenderScript/src/BufferParser.cpp b/RenderScript/src/BufferParser.cpp
index 92cbc2e..40cda67 100644
--- a/RenderScript/src/BufferParser.cpp
+++ b/RenderScript/src/BufferParser.cpp
@@ -83,7 +83,7 @@ namespace Diligent
DEFINE_FLAGS_BINDER( m_Bindings, SBuffDescWrapper, CPUAccessFlags, CPU_ACCESS_FLAG, m_CpuAccessFlagEnumMapping );
DEFINE_ENUM_ELEMENT_MAPPING( m_BuffModeEnumMapping, BUFFER_MODE_UNDEFINED );
- DEFINE_ENUM_ELEMENT_MAPPING( m_BuffModeEnumMapping, BUFFER_MODE_FORMATED );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_BuffModeEnumMapping, BUFFER_MODE_FORMATTED );
DEFINE_ENUM_ELEMENT_MAPPING( m_BuffModeEnumMapping, BUFFER_MODE_STRUCTURED );
static_assert(BUFFER_MODE_NUM_MODES == BUFFER_MODE_STRUCTURED + 1, "Not all buffer modes initialized.");
VERIFY( m_BuffModeEnumMapping.m_Str2ValMap.size() == BUFFER_MODE_NUM_MODES,
@@ -106,11 +106,11 @@ namespace Diligent
ParseLuaTable( L, 1, &BufferDesc, m_Bindings );
CHECK_LUA_STACK_HEIGHT();
- if( BufferDesc.Mode == BUFFER_MODE_FORMATED )
+ if( BufferDesc.Mode == BUFFER_MODE_FORMATTED )
{
auto &BuffFmt = BufferDesc.Format;
if( BuffFmt.ValueType == VT_UNDEFINED || BuffFmt.NumComponents == 0 )
- SCRIPT_PARSING_ERROR( L, "Valid format must be specified for a formated buffer" );
+ SCRIPT_PARSING_ERROR( L, "Valid format must be specified for a formatted buffer" );
auto FmtSize = GetValueSize( BuffFmt.ValueType ) * BuffFmt.NumComponents;
if( BufferDesc.ElementByteStride != 0 )
{
@@ -128,7 +128,7 @@ namespace Diligent
if( BufferDesc.Mode == BUFFER_MODE_STRUCTURED && BufferDesc.ElementByteStride == 0 )
SCRIPT_PARSING_ERROR( L, "UAV element byte stride of a structured buffer cannot be zero" );
- if( (BufferDesc.Mode == BUFFER_MODE_FORMATED || BufferDesc.Mode == BUFFER_MODE_STRUCTURED) &&
+ if( (BufferDesc.Mode == BUFFER_MODE_FORMATTED || BufferDesc.Mode == BUFFER_MODE_STRUCTURED) &&
(BufferDesc.uiSizeInBytes % BufferDesc.ElementByteStride) != 0 )
SCRIPT_PARSING_ERROR( L, "Buffer size (", BufferDesc.uiSizeInBytes, ") is not multiple of element byte stride (", BufferDesc.ElementByteStride, ")." );
diff --git a/RenderScript/src/DrawAttribsParser.cpp b/RenderScript/src/DrawAttribsParser.cpp
index f1be965..fd55c14 100644
--- a/RenderScript/src/DrawAttribsParser.cpp
+++ b/RenderScript/src/DrawAttribsParser.cpp
@@ -39,6 +39,38 @@ namespace Diligent
DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP );
DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_POINT_LIST );
DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_LINE_LIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST );
+ DEFINE_ENUM_ELEMENT_MAPPING( m_PrimTopologyEnumMapping, PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST );
VERIFY( m_PrimTopologyEnumMapping.m_Str2ValMap.size() == PRIMITIVE_TOPOLOGY_NUM_TOPOLOGIES - 1,
"Unexpected map size. Did you update PRIMITIVE_TOPOLOGY enum?" );
VERIFY( m_PrimTopologyEnumMapping.m_Val2StrMap.size() == PRIMITIVE_TOPOLOGY_NUM_TOPOLOGIES - 1,
diff --git a/RenderScript/src/ScissorRectParser.cpp b/RenderScript/src/ScissorRectParser.cpp
index ecc60a8..a36036d 100644
--- a/RenderScript/src/ScissorRectParser.cpp
+++ b/RenderScript/src/ScissorRectParser.cpp
@@ -108,7 +108,7 @@ namespace Diligent
}
}
- if( RTWidth == 0 && RTHeight != 0 || RTWidth != 0 && RTHeight == 0 )
+ if( (RTWidth == 0 && RTHeight != 0) || (RTWidth != 0 && RTHeight == 0) )
SCRIPT_PARSING_ERROR( L, "Render target size is incomplete (", RTWidth, "x", RTHeight, "). Use either 0x0 or fully specified size" );
Uint32 NumScissorRects = static_cast<Uint32>( m_ScissorRects.size() );
diff --git a/RenderScript/src/ScriptParser.cpp b/RenderScript/src/ScriptParser.cpp
index 8f23f8d..8e65d75 100644
--- a/RenderScript/src/ScriptParser.cpp
+++ b/RenderScript/src/ScriptParser.cpp
@@ -85,7 +85,8 @@ namespace Diligent
m_pScriptParser->m_pScissorRectParser->PushObject( L, &Rect );
}
- ScriptParser::ScriptParser( IRenderDevice *pRenderDevice ) :
+ ScriptParser::ScriptParser( IReferenceCounters *pRefCounters, IRenderDevice *pRenderDevice ) :
+ TBase(pRefCounters),
m_pRenderDevice( pRenderDevice ),
m_LuaState( LuaState::LUA_LIB_BASE | LuaState::LUA_LIB_COROUTINE | LuaState::LUA_LIB_TABLE |
LuaState::LUA_LIB_STRING | LuaState::LUA_LIB_BIT32 | LuaState::LUA_LIB_MATH )
diff --git a/RenderScript/src/ShaderParser.cpp b/RenderScript/src/ShaderParser.cpp
index 10416e2..12d9157 100644
--- a/RenderScript/src/ShaderParser.cpp
+++ b/RenderScript/src/ShaderParser.cpp
@@ -86,7 +86,7 @@ namespace Diligent
);
}
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
+ virtual void SetValue( lua_State *L, int Index, void* pBasePointer )override
{
auto &ShaderVarDescBuffer = GetMemberByOffest<std::vector<ShaderVariableDesc>>( pBasePointer, m_VarDescBufferOffset);
auto &ShaderNamesBuffer = GetMemberByOffest<std::vector<String>>( pBasePointer, m_VarNamesBufferOffset);
@@ -191,7 +191,7 @@ namespace Diligent
);
}
- virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
+ virtual void SetValue( lua_State *L, int Index, void* pBasePointer )override
{
auto &StaticSamplersBuffer = GetMemberByOffest<std::vector<StaticSamplerDesc>>( pBasePointer, m_StaticSamplersBufferOffset);
auto &StaticSamplerTexNamesBuffer = GetMemberByOffest<std::vector<String>>( pBasePointer, m_StaticSamplerTexNamesBufferOffset);
diff --git a/RenderScript/src/ViewportParser.cpp b/RenderScript/src/ViewportParser.cpp
index 3f4dc06..555baa3 100644
--- a/RenderScript/src/ViewportParser.cpp
+++ b/RenderScript/src/ViewportParser.cpp
@@ -117,7 +117,7 @@ namespace Diligent
}
}
- if( RTWidth == 0 && RTHeight != 0 || RTWidth != 0 && RTHeight == 0 )
+ if( (RTWidth == 0 && RTHeight != 0) || (RTWidth != 0 && RTHeight == 0) )
SCRIPT_PARSING_ERROR( L, "Render target size is incomplete (", RTWidth, "x", RTHeight, "). Use either 0x0 or fully specified size" );
Uint32 NumViewports = static_cast<Uint32>( m_Viewports.size() );
diff --git a/TextureLoader/include/DDSLoader.h b/TextureLoader/include/DDSLoader.h
index fb3e332..cf6335b 100644
--- a/TextureLoader/include/DDSLoader.h
+++ b/TextureLoader/include/DDSLoader.h
@@ -51,8 +51,9 @@ void CreateDDSTextureFromMemory(
const Diligent::Uint8* ddsData,
size_t ddsDataSize,
Diligent::ITexture** texture,
- size_t maxsize/*,
- D2D1_ALPHA_MODE* alphaMode*/
+ size_t maxsize,
+ /*D2D1_ALPHA_MODE* alphaMode,*/
+ const char* name
);
void CreateDDSTextureFromMemoryEx(
@@ -61,6 +62,7 @@ void CreateDDSTextureFromMemoryEx(
size_t ddsDataSize,
size_t maxsize,
Diligent::USAGE usage,
+ const char* name,
unsigned int bindFlags,
unsigned int cpuAccessFlags,
unsigned int miscFlags,
diff --git a/TextureLoader/interface/Image.h b/TextureLoader/interface/Image.h
index eacf315..0f18835 100644
--- a/TextureLoader/interface/Image.h
+++ b/TextureLoader/interface/Image.h
@@ -62,10 +62,13 @@ namespace Diligent
{}
};
- class Image : public Diligent::ObjectBase<Diligent::IObject, Diligent::IMemoryAllocator>
+ class Image : public ObjectBase<IObject>
{
public:
- Image( Diligent::IFileStream *pSrcFile,
+ typedef ObjectBase<IObject> TBase;
+
+ Image( IReferenceCounters *pRefCounters,
+ Diligent::IFileStream *pSrcFile,
const ImageLoadInfo& LoadInfo );
const ImageDesc &GetDesc(){ return m_Desc; }
diff --git a/TextureLoader/interface/TextureLoader.h b/TextureLoader/interface/TextureLoader.h
index 341e1e8..c52da69 100644
--- a/TextureLoader/interface/TextureLoader.h
+++ b/TextureLoader/interface/TextureLoader.h
@@ -32,19 +32,23 @@ namespace Diligent
{
struct TextureLoadInfo
{
+ const Diligent::Char *Name;
Diligent::USAGE Usage;
Diligent::Uint32 BindFlags;
Diligent::Uint32 MipLevels;
Diligent::Uint32 CPUAccessFlags;
Diligent::Bool IsSRGB;
+ Diligent::Bool GenerateMips;
Diligent::TEXTURE_FORMAT Format;
TextureLoadInfo() :
+ Name(""),
Usage( Diligent::USAGE_STATIC ),
BindFlags( Diligent::BIND_SHADER_RESOURCE ),
MipLevels(0),
CPUAccessFlags(0),
IsSRGB(false),
+ GenerateMips(true),
Format(Diligent::TEX_FORMAT_UNKNOWN)
{}
};
diff --git a/TextureLoader/src/DDSLoader.cpp b/TextureLoader/src/DDSLoader.cpp
index 37bccf6..34a625a 100644
--- a/TextureLoader/src/DDSLoader.cpp
+++ b/TextureLoader/src/DDSLoader.cpp
@@ -537,6 +537,7 @@ static void GetSurfaceInfo(
case DXGI_FORMAT_G8R8_G8B8_UNORM:
packed = true;
break;
+ default: break;
}
if (bc)
@@ -930,6 +931,7 @@ static void CreateTexture(
_In_ size_t arraySize,
_In_ DXGI_FORMAT format,
_In_ USAGE usage,
+ _In_ const char *name,
_In_ unsigned int bindFlags,
_In_ unsigned int cpuAccessFlags,
_In_ unsigned int miscFlags,
@@ -951,6 +953,7 @@ static void CreateTexture(
}
TextureDesc desc;
+ desc.Name = name;
desc.Width = static_cast<Uint32>(width);
desc.MipLevels = static_cast<Uint32>(mipCount);
desc.ArraySize = static_cast<Uint32>(arraySize);
@@ -1150,6 +1153,7 @@ static void CreateTextureFromDDS(
_In_ size_t bitSize,
_In_ size_t maxsize,
_In_ USAGE usage,
+ _In_ const char *name,
_In_ unsigned int bindFlags,
_In_ unsigned int cpuAccessFlags,
_In_ unsigned int miscFlags,
@@ -1319,7 +1323,7 @@ static void CreateTextureFromDDS(
size_t tdepth = 0;
FillInitData(width, height, depth, mipCount, arraySize, format, maxsize, bitSize, bitData, twidth, theight, tdepth, skipMip, initData.get());
- CreateTexture(pDevice, resDim, twidth, theight, tdepth, mipCount - skipMip, arraySize, format, usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, isCubeMap, initData.get(), texture/*, textureView*/);
+ CreateTexture(pDevice, resDim, twidth, theight, tdepth, mipCount - skipMip, arraySize, format, usage, name, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, isCubeMap, initData.get(), texture/*, textureView*/);
#if 0
if (FAILED(hr) && !maxsize && (mipCount > 1))
@@ -1403,11 +1407,11 @@ void CreateDDSTextureFromMemory(
const Uint8* ddsData,
size_t ddsDataSize,
ITexture** texture,
- size_t maxsize/*,
- D2D1_ALPHA_MODE* alphaMode*/
- )
+ size_t maxsize,
+ /*D2D1_ALPHA_MODE* alphaMode,*/
+ const char* name)
{
- return CreateDDSTextureFromMemoryEx(pDevice, ddsData, ddsDataSize, maxsize, USAGE_DEFAULT, BIND_SHADER_RESOURCE, 0, 0, false, texture/*, alphaMode*/);
+ return CreateDDSTextureFromMemoryEx(pDevice, ddsData, ddsDataSize, maxsize, USAGE_DEFAULT, name, BIND_SHADER_RESOURCE, 0, 0, false, texture/*, alphaMode*/);
}
@@ -1418,6 +1422,7 @@ void CreateDDSTextureFromMemoryEx(
size_t ddsDataSize,
size_t maxsize,
USAGE usage,
+ const char *name,
unsigned int bindFlags,
unsigned int cpuAccessFlags,
unsigned int miscFlags,
@@ -1482,7 +1487,7 @@ void CreateDDSTextureFromMemoryEx(
ptrdiff_t offset = sizeof(Uint32) + sizeof(DDS_HEADER) + (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0);
- CreateTextureFromDDS(pDevice, header, ddsData + offset, ddsDataSize - offset, maxsize, usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, texture/*, textureView*/);
+ CreateTextureFromDDS(pDevice, header, ddsData + offset, ddsDataSize - offset, maxsize, usage, name, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, texture/*, textureView*/);
//if (alphaMode)
// *alphaMode = GetAlphaMode(header);
diff --git a/TextureLoader/src/Image.cpp b/TextureLoader/src/Image.cpp
index e47b311..2cf0dbe 100644
--- a/TextureLoader/src/Image.cpp
+++ b/TextureLoader/src/Image.cpp
@@ -386,11 +386,13 @@ namespace Diligent
// warnings occurred (test whether jerr.pub.num_warnings is nonzero).
}
- Image::Image( Diligent::IFileStream *pSrcFile,
+ Image::Image( IReferenceCounters *pRefCounters,
+ IFileStream *pSrcFile,
const ImageLoadInfo& LoadInfo ) :
- m_pData( new Diligent::DataBlobImpl )
+ TBase(pRefCounters),
+ m_pData( MakeNewRCObj<DataBlobImpl>()(0) )
{
- RefCntAutoPtr<IDataBlob> pFileData( new Diligent::DataBlobImpl );
+ RefCntAutoPtr<IDataBlob> pFileData( MakeNewRCObj<DataBlobImpl>()(0) );
pSrcFile->Read(pFileData);
if( LoadInfo.Format == EImageFileFormat::tiff )
diff --git a/TextureLoader/src/TextureLoader.cpp b/TextureLoader/src/TextureLoader.cpp
index 14f6f24..cf7a32d 100644
--- a/TextureLoader/src/TextureLoader.cpp
+++ b/TextureLoader/src/TextureLoader.cpp
@@ -119,6 +119,7 @@ namespace Diligent
{
const auto& ImgDesc = pSrcImage->GetDesc();
TextureDesc TexDesc;
+ TexDesc.Name = TexLoadInfo.Name;
TexDesc.Type = RESOURCE_DIM_TEX_2D;
TexDesc.Width = ImgDesc.Width;
TexDesc.Height = ImgDesc.Height;
@@ -204,16 +205,19 @@ namespace Diligent
CoarseMipStride = (CoarseMipStride + 3) & (-4);
Mips[m].resize(CoarseMipStride * CoarseMipHeight);
- if( ChannelDepth == 8 )
- ComputeCoarseMip<Uint8>( NumComponents, IsSRGB,
- pSubResources[m-1].pData, pSubResources[m-1].Stride,
- Mips[m].data(), CoarseMipStride,
- CoarseMipWidth, CoarseMipHeight);
- else if( ChannelDepth == 16 )
- ComputeCoarseMip<Uint16>( NumComponents, IsSRGB,
- pSubResources[m-1].pData, pSubResources[m-1].Stride,
- Mips[m].data(), CoarseMipStride,
- CoarseMipWidth, CoarseMipHeight);
+ if (TexLoadInfo.GenerateMips)
+ {
+ if (ChannelDepth == 8)
+ ComputeCoarseMip<Uint8>(NumComponents, IsSRGB,
+ pSubResources[m - 1].pData, pSubResources[m - 1].Stride,
+ Mips[m].data(), CoarseMipStride,
+ CoarseMipWidth, CoarseMipHeight);
+ else if (ChannelDepth == 16)
+ ComputeCoarseMip<Uint16>(NumComponents, IsSRGB,
+ pSubResources[m - 1].pData, pSubResources[m - 1].Stride,
+ Mips[m].data(), CoarseMipStride,
+ CoarseMipWidth, CoarseMipHeight);
+ }
pSubResources[m].pData = Mips[m].data();
pSubResources[m].Stride = CoarseMipStride;
@@ -239,6 +243,7 @@ namespace Diligent
static_cast<size_t>(pDDSData->GetSize()),
0, // maxSize
TexLoadInfo.Usage,
+ TexLoadInfo.Name,
TexLoadInfo.BindFlags,
TexLoadInfo.CPUAccessFlags,
0, // miscFlags
diff --git a/TextureLoader/src/TextureUtilities.cpp b/TextureLoader/src/TextureUtilities.cpp
index 48f5bd5..3bd8442 100644
--- a/TextureLoader/src/TextureUtilities.cpp
+++ b/TextureLoader/src/TextureUtilities.cpp
@@ -40,40 +40,49 @@ void CreateImageFromFile( const Diligent::Char *FilePath,
Image **ppImage,
IDataBlob **ppDDSData)
{
- auto *pDotPos = strrchr( FilePath, '.' );
- if( pDotPos == nullptr )
- LOG_ERROR_AND_THROW( "File path ", FilePath, " does not contain extension" );
+ try
+ {
+ auto *pDotPos = strrchr(FilePath, '.');
+ if (pDotPos == nullptr)
+ LOG_ERROR_AND_THROW("File path \"", FilePath, "\" does not contain extension");
- auto *pExtension = pDotPos + 1;
- if( *pExtension == 0 )
- LOG_ERROR_AND_THROW( "File path ", FilePath, " contains empty extension" );
+ auto *pExtension = pDotPos + 1;
+ if (*pExtension == 0)
+ LOG_ERROR_AND_THROW("File path \"", FilePath, "\" contains empty extension");
- String Extension(pExtension);
- std::transform( Extension.begin(), Extension.end(), Extension.begin(), ::tolower );
+ String Extension(pExtension);
+ std::transform(Extension.begin(), Extension.end(), Extension.begin(), ::tolower);
- Diligent::RefCntAutoPtr<BasicFileStream> pFileStream( new BasicFileStream( FilePath, EFileAccessMode::Read ) );
+ RefCntAutoPtr<BasicFileStream> pFileStream(MakeNewRCObj<BasicFileStream>()(FilePath, EFileAccessMode::Read));
+ if(!pFileStream->IsValid())
+ LOG_ERROR_AND_THROW("Failed to open image file \"", FilePath, '\"');
- if( Extension == "dds" )
- {
- VERIFY_EXPR(ppDDSData != nullptr);
- *ppDDSData = new DataBlobImpl;
- pFileStream->Read(*ppDDSData);
- (*ppDDSData)->AddRef();
- }
- else
- {
- ImageLoadInfo ImgLoadInfo;
- if( Extension == "png" )
- ImgLoadInfo.Format = EImageFileFormat::png;
- else if( Extension == "jpeg" || Extension == "jpg" )
- ImgLoadInfo.Format = EImageFileFormat::jpeg;
- else if( Extension == "tiff" || Extension == "tif" )
- ImgLoadInfo.Format = EImageFileFormat::tiff;
+ if (Extension == "dds")
+ {
+ VERIFY_EXPR(ppDDSData != nullptr);
+ *ppDDSData = MakeNewRCObj<DataBlobImpl>()(0);
+ pFileStream->Read(*ppDDSData);
+ (*ppDDSData)->AddRef();
+ }
else
- LOG_ERROR_AND_THROW( "Unsupported file format ", Extension );
+ {
+ ImageLoadInfo ImgLoadInfo;
+ if (Extension == "png")
+ ImgLoadInfo.Format = EImageFileFormat::png;
+ else if (Extension == "jpeg" || Extension == "jpg")
+ ImgLoadInfo.Format = EImageFileFormat::jpeg;
+ else if (Extension == "tiff" || Extension == "tif")
+ ImgLoadInfo.Format = EImageFileFormat::tiff;
+ else
+ LOG_ERROR_AND_THROW("Unsupported file format ", Extension);
- *ppImage = new Image(pFileStream, ImgLoadInfo);
- (*ppImage)->AddRef();
+ *ppImage = MakeNewRCObj<Image>()(pFileStream, ImgLoadInfo);
+ (*ppImage)->AddRef();
+ }
+ }
+ catch (std::runtime_error &err)
+ {
+ LOG_ERROR("Failed to create image from file: ", err.what())
}
}