diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2019-12-25 03:23:32 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2019-12-25 03:23:32 +0000 |
| commit | 040e4cb7e454d532d249d2a5de6f2aba0c902baa (patch) | |
| tree | c89a3a009e2d145c3c3cfdb053ad7392eedf6d98 /Tests/TestApp | |
| parent | Added codacy bages (diff) | |
| download | DiligentEngine-040e4cb7e454d532d249d2a5de6f2aba0c902baa.tar.gz DiligentEngine-040e4cb7e454d532d249d2a5de6f2aba0c902baa.zip | |
Updated submodules; removed tests folder (tests are now part of every submodule)
Diffstat (limited to 'Tests/TestApp')
80 files changed, 0 insertions, 7064 deletions
diff --git a/Tests/TestApp/CMakeLists.txt b/Tests/TestApp/CMakeLists.txt deleted file mode 100644 index f826502..0000000 --- a/Tests/TestApp/CMakeLists.txt +++ /dev/null @@ -1,178 +0,0 @@ -cmake_minimum_required (VERSION 3.6) - -project(TestApp) - -file(GLOB SOURCE LIST_DIRECTORIES false src/*.cpp) -file(GLOB INCLUDE LIST_DIRECTORIES false include/*.h) - -if(NOT GL_SUPPORTED AND NOT GLES_SUPPORTED) - list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/ShaderConverterTest.cpp) - list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/TestCreateObjFromNativeResGL.cpp) - list(REMOVE_ITEM INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/ShaderConverterTest.h) - list(REMOVE_ITEM INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/TestCreateObjFromNativeResGL.h) -endif() - -if(NOT D3D11_SUPPORTED) - list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/TestCreateObjFromNativeResD3D11.cpp) - list(REMOVE_ITEM INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/TestCreateObjFromNativeResD3D11.h) -endif() - -if(NOT D3D12_SUPPORTED) - list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/TestCreateObjFromNativeResD3D12.cpp) - list(REMOVE_ITEM INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/TestCreateObjFromNativeResD3D12.h) -endif() - -if(NOT VULKAN_SUPPORTED) - list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/TestCreateObjFromNativeResVK.cpp) - list(REMOVE_ITEM INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/TestCreateObjFromNativeResVK.h) -endif() - -file(GLOB ASSETS LIST_DIRECTORIES false assets/*.*) -file(GLOB SHADERS LIST_DIRECTORIES false assets/shaders/*.*) -file(GLOB CS_TEST_SHADERS LIST_DIRECTORIES false assets/shaders/CSTest/*.*) -file(GLOB RT_TEST_SHADERS LIST_DIRECTORIES false assets/shaders/RTTest/*.*) - -set_source_files_properties(${ASSETS} PROPERTIES - VS_DEPLOYMENT_LOCATION "." - MACOSX_PACKAGE_LOCATION "Resources" -) - -set_source_files_properties(${SHADERS} PROPERTIES - VS_DEPLOYMENT_LOCATION "Shaders" - MACOSX_PACKAGE_LOCATION "Resources/Shaders" -) - -set_source_files_properties(${CS_TEST_SHADERS} PROPERTIES - VS_DEPLOYMENT_LOCATION "Shaders/CSTest" - MACOSX_PACKAGE_LOCATION "Resources/Shaders/CSTest" -) - -set_source_files_properties(${RT_TEST_SHADERS} PROPERTIES - VS_DEPLOYMENT_LOCATION "Shaders/RTTest" - MACOSX_PACKAGE_LOCATION "Resources/Shaders/RTTest" -) - -set(ALL_SHADERS ${SHADERS} ${CS_TEST_SHADERS} ${RT_TEST_SHADERS}) -set_source_files_properties(${ALL_SHADERS} PROPERTIES VS_TOOL_OVERRIDE "None") - -set(ALL_ASSETS ${ASSETS} ${ALL_SHADERS}) -add_target_platform_app(TestApp "${SOURCE}" "${INCLUDE}" "${ALL_ASSETS}") - -if(PLATFORM_WIN32) - set(WIN32_SOURCE src/Win32/TestAppWin32.cpp) - target_sources(TestApp PRIVATE ${WIN32_SOURCE}) - source_group("src\\Win32" FILES ${WIN32_SOURCE}) - - set_target_properties(TestApp PROPERTIES - VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets" - ) - copy_required_dlls(TestApp) - -elseif(PLATFORM_UNIVERSAL_WINDOWS) - - set(UWP_SOURCE - src/UWP/TestAppUWP.cpp - ) - target_sources(TestApp PRIVATE ${UWP_SOURCE}) - source_group("src\\UWP" FILES ${UWP_SOURCE}) - target_include_directories(TestApp PRIVATE src/UWP) - -elseif(PLATFORM_ANDROID) - set(ANDROID_SOURCE - src/Android/TestAppAndroid.cpp - ) - target_sources(TestApp PRIVATE ${ANDROID_SOURCE}) - source_group("src\\Android" FILES ${ANDROID_SOURCE}) -elseif(PLATFORM_LINUX) - set(LINUX_SOURCE - src/Linux/TestAppLinux.cpp - ) - target_sources(TestApp PRIVATE ${LINUX_SOURCE}) - source_group("src\\Linux" FILES ${LINUX_SOURCE}) -elseif(PLATFORM_MACOS) - - set(MAC_SOURCE - src/MacOS/TestAppMacOS.cpp - ) - target_sources(TestApp PRIVATE ${MAC_SOURCE}) - source_group("src\\MacOS" FILES ${MAC_SOURCE}) - -elseif(PLATFORM_IOS) - set(IOS_SOURCE - src/IOS/TestAppIOS.cpp - ) - target_sources(TestApp PRIVATE ${IOS_SOURCE}) - source_group("src\\MacOS" FILES ${IOS_SOURCE}) -endif() - -set_common_target_properties(TestApp) -target_include_directories(TestApp -PRIVATE - ../../DiligentCore/ThirdParty/vulkan -PUBLIC - include -) - - -if(MSVC) - target_compile_options(TestApp PRIVATE -DUNICODE /wd4201 /wd4189) - - if(PLATFORM_UNIVERSAL_WINDOWS) - # Disable w4189: local variable is initialized but not referenced - # Disable w4063: case is not a valid value for switch of enum - # Consume the windows runtime extensions (/ZW) - target_compile_options(TestApp PRIVATE /wd4063 /ZW) - endif() -endif() - -get_supported_backends(ENGINE_LIBRARIES) - -target_link_libraries(TestApp -PRIVATE - Diligent-BuildSettings -PUBLIC - NativeAppBase - Diligent-Common - Diligent-GraphicsTools - Diligent-TargetPlatform - Diligent-GraphicsAccessories - ${ENGINE_LIBRARIES} -) - -if(GL_SUPPORTED OR GLES_SUPPORTED) - target_link_libraries(TestApp PRIVATE Diligent-HLSL2GLSLConverterLib) -endif() - -if(GL_SUPPORTED) - target_link_libraries(TestApp PRIVATE glew-static) -endif() - - -if(PLATFORM_UNIVERSAL_WINDOWS) - target_link_libraries(TestApp PRIVATE dxguid.lib) -elseif(PLATFORM_ANDROID) - target_link_libraries(TestApp PRIVATE GLESv3 PUBLIC native_app_glue) -elseif(PLATFORM_LINUX) - target_link_libraries(TestApp PRIVATE GL X11 pthread) -elseif(PLATFORM_MACOS OR PLATFORM_IOS) - -endif() - -if(PLATFORM_WIN32 OR PLATFORM_LINUX) - # Copy assets to target folder - add_custom_command(TARGET TestApp POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory - "${CMAKE_CURRENT_SOURCE_DIR}/assets" - "\"$<TARGET_FILE_DIR:TestApp>\"") -endif() - -source_group("src" FILES ${SOURCE}) -source_group("include" FILES ${INCLUDE}) -source_group("assets" FILES ${ASSETS}) -source_group("assets\\shaders" FILES ${SHADERS}) -source_group("assets\\shaders\\CSTest" FILES ${CS_TEST_SHADERS}) -source_group("assets\\shaders\\RTTest" FILES ${RT_TEST_SHADERS}) - -set_target_properties(TestApp PROPERTIES - FOLDER Tests -) diff --git a/Tests/TestApp/assets/LuaTest.lua b/Tests/TestApp/assets/LuaTest.lua deleted file mode 100644 index b4ffc48..0000000 --- a/Tests/TestApp/assets/LuaTest.lua +++ /dev/null @@ -1,708 +0,0 @@ --- Test script file - -assert( TestGlobalBool == true ) -assert( TestGlobalInt == 19 ) -assert( TestGlobalFloat == 139.25 ) -assert( TestGlobalString == "Test Global String" ) - -assert(TestGlobalBuffer.uiSizeInBytes == 256) -assert(TestGlobalBuffer.Name == "TestGlobalBuff") -assert(TestGlobalBuffer.Usage == "USAGE_DYNAMIC") -assert(TestGlobalBuffer.BindFlags[1] == "BIND_UNIFORM_BUFFER") -assert(TestGlobalBuffer.CPUAccessFlags[1] == "CPU_ACCESS_WRITE") - - -assert( TestGlobalSampler.Name == "Test Sampler" ) -assert( TestGlobalSampler.MinFilter == "FILTER_TYPE_COMPARISON_POINT" ) -assert( TestGlobalSampler.MagFilter == "FILTER_TYPE_COMPARISON_LINEAR" ) -assert( TestGlobalSampler.MipFilter == "FILTER_TYPE_COMPARISON_LINEAR" ) -assert( TestGlobalSampler.AddressU == "TEXTURE_ADDRESS_WRAP" ) -assert( TestGlobalSampler.AddressV == "TEXTURE_ADDRESS_MIRROR" ) -assert( TestGlobalSampler.AddressW == "TEXTURE_ADDRESS_CLAMP" ) -assert( TestGlobalSampler.MipLODBias == 4 ) -assert( TestGlobalSampler.MinLOD == 1.5 ) -assert( TestGlobalSampler.MaxLOD == 4 ) -assert( TestGlobalSampler.MaxAnisotropy == 2 ) -assert( TestGlobalSampler.ComparisonFunc == "COMPARISON_FUNC_LESS" ) -assert( TestGlobalSampler.BorderColor.r == 0.0 ) -assert( TestGlobalSampler.BorderColor.g == 0.0 ) -assert( TestGlobalSampler.BorderColor.b == 0.0 ) -assert( TestGlobalSampler.BorderColor.a == 1.0 ) - -assert( TestGlobalBuffer2UAV.ViewType == "BUFFER_VIEW_UNORDERED_ACCESS" ) -assert( TestGlobalBuffer2UAV.ByteOffset == 0 ) -assert( TestGlobalBuffer2UAV.ByteWidth == 64 ) - -function CheckTextureAttribs(Texture) - assert( Texture.Type == "RESOURCE_DIM_TEX_2D" ) - assert( Texture.Name == "Test Global Texture 2D" ) - assert( Texture.Width == 1024 ) - assert( Texture.Height == 512 ) - assert( Texture.MipLevels == 1 ) - assert( Texture.Format == "TEX_FORMAT_RGBA8_UNORM" ) - assert( Texture.Usage == "USAGE_DYNAMIC" ) - assert( Texture.BindFlags[1] == "BIND_SHADER_RESOURCE" ) - assert( Texture.CPUAccessFlags[1] == "CPU_ACCESS_WRITE" ) -end -CheckTextureAttribs( TestGlobalTexture ) - -TestSampler = Sampler.Create{ - Name = "Test Sampler", - MinFilter = "FILTER_TYPE_POINT", - MagFilter = "FILTER_TYPE_LINEAR", - MipFilter = "FILTER_TYPE_POINT", - AddressU = "TEXTURE_ADDRESS_WRAP", - AddressV = "TEXTURE_ADDRESS_MIRROR", - AddressW = "TEXTURE_ADDRESS_CLAMP", - MipLODBias = 2, - MinLOD = 0.5, - MaxLOD = 10, - MaxAnisotropy = 6, - ComparisonFunc = "COMPARISON_FUNC_GREATER_EQUAL", - BorderColor = {r = 0.0, g = 0.0, b=0.0, a=1.0}, -} -assert( TestSampler.Name == "Test Sampler" ) -assert( TestSampler.MinFilter == "FILTER_TYPE_POINT" ) -assert( TestSampler.MagFilter == "FILTER_TYPE_LINEAR" ) -assert( TestSampler.MipFilter == "FILTER_TYPE_POINT" ) -assert( TestSampler.AddressU == "TEXTURE_ADDRESS_WRAP" ) -assert( TestSampler.AddressV == "TEXTURE_ADDRESS_MIRROR" ) -assert( TestSampler.AddressW == "TEXTURE_ADDRESS_CLAMP" ) -assert( TestSampler.MipLODBias == 2 ) -assert( TestSampler.MinLOD == 0.5 ) -assert( TestSampler.MaxLOD == 10 ) -assert( TestSampler.MaxAnisotropy == 6 ) -assert( TestSampler.ComparisonFunc == "COMPARISON_FUNC_GREATER_EQUAL" ) -assert( TestSampler.BorderColor.r == 0.0 ) -assert( TestSampler.BorderColor.g == 0.0 ) -assert( TestSampler.BorderColor.b == 0.0 ) -assert( TestSampler.BorderColor.a == 1.0 ) - - - -TestSampler2 = Sampler.Create{ - Name = TestSampler.Name, - MinFilter = TestSampler.MinFilter, - MagFilter = TestSampler.MagFilter, - MipFilter = TestSampler.MipFilter, - AddressU = TestSampler.AddressU, - AddressV = TestSampler.AddressV, - AddressW = TestSampler.AddressW, - MipLODBias = TestSampler.MipLODBias, - MinLOD = TestSampler.MinLOD, - MaxLOD = TestSampler.MaxLOD, - MaxAnisotropy = TestSampler.MaxAnisotropy, - ComparisonFunc = TestSampler.ComparisonFunc, - BorderColor = TestSampler.BorderColor, -} -assert( TestSampler2.Name == "Test Sampler" ) -assert( TestSampler2.MinFilter == "FILTER_TYPE_POINT" ) -assert( TestSampler2.MagFilter == "FILTER_TYPE_LINEAR" ) -assert( TestSampler2.MipFilter == "FILTER_TYPE_POINT" ) -assert( TestSampler2.AddressU == "TEXTURE_ADDRESS_WRAP" ) -assert( TestSampler2.AddressV == "TEXTURE_ADDRESS_MIRROR" ) -assert( TestSampler2.AddressW == "TEXTURE_ADDRESS_CLAMP" ) -assert( TestSampler2.MipLODBias == 2 ) -assert( TestSampler2.MinLOD == 0.5 ) -assert( TestSampler2.MaxLOD == 10 ) -assert( TestSampler2.MaxAnisotropy == 6 ) -assert( TestSampler2.ComparisonFunc == "COMPARISON_FUNC_GREATER_EQUAL" ) -assert( TestSampler2.BorderColor.r == 0.0 ) -assert( TestSampler2.BorderColor.g == 0.0 ) -assert( TestSampler2.BorderColor.b == 0.0 ) -assert( TestSampler2.BorderColor.a == 1.0 ) - - - -TestSampler3 = Sampler.Create{ - BorderColor = - {r = TestSampler2.BorderColor.r, - g = TestSampler2.BorderColor.g, - b = TestSampler2.BorderColor.b, - a = TestSampler2.BorderColor.a - } -} -assert( TestSampler3.BorderColor.r == 0.0 ) -assert( TestSampler3.BorderColor.g == 0.0 ) -assert( TestSampler3.BorderColor.b == 0.0 ) -assert( TestSampler3.BorderColor.a == 1.0 ) - --- TestSampler3.MaxLOD = 0 -TestSampler3.BorderColor.a = 1 -assert( TestSampler3.BorderColor.a ==1.0 ) - -function Func1() - local TestSampler = Sampler.Create{ - MinFilter = "FILTER_TYPE_POINT" - } -end - -function Func2() - Func1() -end - -Func2() - - -TestSampler4 = Sampler.Create{} - - -ErrorTestSampler = Sampler.Create -{ - SomeUndefinedMember = Undefined, - MinFilter = Undefined2 -} - -function GetShaderPath( ShaderName, ShaderExt ) - - local ProcessedShaderPath = "" - if Constants.DeviceType == "D3D11" or Constants.DeviceType == "D3D12" then - ProcessedShaderPath = "Shaders\\" .. ShaderName .. "DX." .. ShaderExt - else - ProcessedShaderPath = "Shaders\\" .. ShaderName .. "GL." .. ShaderExt - end - - return ProcessedShaderPath -end - -TestVS = Shader.Create{ - FilePath = GetShaderPath("minimalInst", "vsh"), - UseCombinedTextureSamplers = true, - Desc = { - ShaderType = "SHADER_TYPE_VERTEX", - Name = "TestVS" - } -} -assert(TestVS.Desc.ShaderType == "SHADER_TYPE_VERTEX") -assert(TestVS.Desc.Name == "TestVS") - -TestPS = Shader.Create{ - FilePath = GetShaderPath("minimal", "psh"), - UseCombinedTextureSamplers = true, - Desc = { - ShaderType = "SHADER_TYPE_PIXEL", - Name = "TestPS", - } -} -assert(TestPS.Desc.ShaderType == "SHADER_TYPE_PIXEL") -assert(TestPS.Desc.Name == "TestPS") - -TestPS2 = Shader.Create{ - FilePath = GetShaderPath("minimal", "psh"), - UseCombinedTextureSamplers = true, - Desc = { - ShaderType = TestPS.Desc.ShaderType, - Name = TestPS.Desc.Name .. "2" - } -} -assert(TestPS2.Desc.ShaderType == "SHADER_TYPE_PIXEL") -assert(TestPS2.Desc.Name == "TestPS2") - -UniformBuffPS = Shader.Create{ - FilePath = GetShaderPath("UniformBuffer", "psh"), - UseCombinedTextureSamplers = true, - Desc = { - ShaderType = "SHADER_TYPE_PIXEL", - Name = "Unifrom buffer PS" - } -} - ---svTestBlock = UniformBuffPS:GetShaderVariable("cbTestBlock") ---svTestBlock2 = ShaderVariable.Create(UniformBuffPS, "cbTestBlock2") ---svTestBlock2:Set(nil) ---Test = svTestBlock2["Error"] ---svTestBlock2["Error"] = 0 - -function TestShaderVariable(inVar) - inVar:Set(nil) -end - -TestVertexLayoutPSO = PipelineState.Create -{ - Name = "Test Vertex Layout PSO", - GraphicsPipeline = - { - InputLayout = - { - { InputIndex = 0, BufferSlot = 0, NumComponents = 3, ValueType = "VT_FLOAT32", IsNormalized = false}, - { InputIndex = 1, BufferSlot = 1, NumComponents = 4, ValueType = "VT_UINT8", IsNormalized = true}, - { InputIndex = 2, BufferSlot = 2, NumComponents = 2, ValueType = "VT_FLOAT32", IsNormalized = false, Frequency = "FREQUENCY_PER_INSTANCE", InstanceDataStepRate = 1}, - }, - pVS = TestVS, - pPS = TestPS, - RTVFormats = "TEX_FORMAT_RGBA8_UNORM_SRGB", - DSVFormat = "TEX_FORMAT_D32_FLOAT", - } -} - - -function CheckVertexDescription(VD) - assert(VD[1].InputIndex == 0) - assert(VD[1].BufferSlot == 0) - assert(VD[1].NumComponents == 3) - assert(VD[1].ValueType == "VT_FLOAT32") - assert(VD[1].IsNormalized == false) - assert(VD[2].InputIndex == 1) - assert(VD[2].BufferSlot == 1) - assert(VD[2].NumComponents == 4) - assert(VD[2].ValueType == "VT_UINT8") - assert(VD[2].IsNormalized == true) - assert(VD[3].InputIndex == 2) - assert(VD[3].BufferSlot == 2) - assert(VD[3].NumComponents == 2) - assert(VD[3].ValueType == "VT_FLOAT32") - assert(VD[3].IsNormalized == false) - assert(VD[3].Frequency == "FREQUENCY_PER_INSTANCE") - assert(VD[3].InstanceDataStepRate == 1) -end - -CheckVertexDescription(TestVertexLayoutPSO.GraphicsPipeline.InputLayout) - -TestVertexLayoutPSO2 = PipelineState.Create -{ - Name = "Test Vertex Layout PSO", - GraphicsPipeline = - { - InputLayout = TestVertexLayoutPSO.GraphicsPipeline.InputLayout, - pVS = TestVS, - pPS = TestPS, - RTVFormats = "TEX_FORMAT_RGBA8_UNORM_SRGB", - DSVFormat = "TEX_FORMAT_D32_FLOAT", - } -} - -CheckVertexDescription(TestVertexLayoutPSO2.GraphicsPipeline.InputLayout) - - -TestVertexLayoutPSO3 = PipelineState.Create -{ - Name = "Test Vertex Layout PSO", - GraphicsPipeline = - { - InputLayout = - { - TestVertexLayoutPSO.GraphicsPipeline.InputLayout[1], - { - InputIndex = TestVertexLayoutPSO.GraphicsPipeline.InputLayout[2].InputIndex, - BufferSlot = TestVertexLayoutPSO.GraphicsPipeline.InputLayout[2].BufferSlot, - NumComponents = TestVertexLayoutPSO.GraphicsPipeline.InputLayout[2].NumComponents, - ValueType = TestVertexLayoutPSO.GraphicsPipeline.InputLayout[2].ValueType, - IsNormalized = TestVertexLayoutPSO.GraphicsPipeline.InputLayout[2].IsNormalized - }, - { - InputIndex = TestVertexLayoutPSO2.GraphicsPipeline.InputLayout[3].InputIndex, - BufferSlot = TestVertexLayoutPSO2.GraphicsPipeline.InputLayout[3].BufferSlot, - NumComponents = TestVertexLayoutPSO2.GraphicsPipeline.InputLayout[3].NumComponents, - ValueType = TestVertexLayoutPSO2.GraphicsPipeline.InputLayout[3].ValueType, - IsNormalized = TestVertexLayoutPSO2.GraphicsPipeline.InputLayout[3].IsNormalized, - Frequency = TestVertexLayoutPSO2.GraphicsPipeline.InputLayout[3].Frequency, - InstanceDataStepRate = TestVertexLayoutPSO2.GraphicsPipeline.InputLayout[3].InstanceDataStepRate, - } - }, - pVS = TestVS, - pPS = TestPS, - RTVFormats = "TEX_FORMAT_RGBA8_UNORM_SRGB", - DSVFormat = "TEX_FORMAT_D32_FLOAT", - } -} - -assert(TestVertexLayoutPSO:IsCompatibleWith(TestVertexLayoutPSO)) -assert(TestVertexLayoutPSO:IsCompatibleWith(TestVertexLayoutPSO2)) -assert(TestVertexLayoutPSO:IsCompatibleWith(TestVertexLayoutPSO3)) -assert(TestVertexLayoutPSO2:IsCompatibleWith(TestVertexLayoutPSO)) -assert(TestVertexLayoutPSO2:IsCompatibleWith(TestVertexLayoutPSO2)) -assert(TestVertexLayoutPSO2:IsCompatibleWith(TestVertexLayoutPSO3)) -assert(TestVertexLayoutPSO3:IsCompatibleWith(TestVertexLayoutPSO)) -assert(TestVertexLayoutPSO3:IsCompatibleWith(TestVertexLayoutPSO2)) -assert(TestVertexLayoutPSO3:IsCompatibleWith(TestVertexLayoutPSO3)) - -CheckVertexDescription(TestVertexLayoutPSO3.GraphicsPipeline.InputLayout) - - - -function TestRenderScript () - Context.SetShaders(TestVS, TestPS) -end - -function TestRenderScriptParams (Bool1, MagicNumber1, MagicNumber2, Bool2, MagicString) - assert(Bool1 == true) - assert(MagicNumber1 == 123) - assert(MagicNumber2 == 345.5) - assert(Bool2 == false) - assert(MagicString == "Magic String") -end - - -function TestSamplerArg(Sampler) - assert( Sampler.Name == "Test Sampler" ) - assert( Sampler.MinFilter == "FILTER_TYPE_POINT" ) - assert( Sampler.MagFilter == "FILTER_TYPE_LINEAR" ) - assert( Sampler.MipFilter == "FILTER_TYPE_POINT" ) - assert( Sampler.AddressU == "TEXTURE_ADDRESS_WRAP" ) - assert( Sampler.AddressV == "TEXTURE_ADDRESS_MIRROR" ) - assert( Sampler.AddressW == "TEXTURE_ADDRESS_CLAMP" ) - assert( Sampler.MipLODBias == 2 ) - assert( Sampler.MinLOD == 0.5 ) - assert( Sampler.MaxLOD == 10 ) - assert( Sampler.MaxAnisotropy == 6 ) - assert( Sampler.ComparisonFunc == "COMPARISON_FUNC_GREATER_EQUAL" ) - assert( Sampler.BorderColor.r == 0.0 ) - assert( Sampler.BorderColor.g == 0.0 ) - assert( Sampler.BorderColor.b == 0.0 ) - assert( Sampler.BorderColor.a == 1.0 ) - Sampler = nil - collectgarbage() -end - - -function TestVertexDescInPSO(VertexDescPSO) - CheckVertexDescription(VertexDescPSO.GraphicsPipeline.InputLayout) - VertexDescPSO = nil - collectgarbage() -end - - -function TestShaderArg(Shader) - assert(Shader.Desc.ShaderType == "SHADER_TYPE_VERTEX") - assert(Shader.Desc.Name == "TestVS") - Shader = nil - collectgarbage() -end - - -TestBuffer = Buffer.Create( - { - Name = "Test Buffer", - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_VERTEX_BUFFER", "BIND_SHADER_RESOURCE"}, - uiSizeInBytes = 64, - Mode = "BUFFER_MODE_FORMATTED", - ElementByteStride = 4 - }, - "VT_FLOAT32", - {1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15,16} -) -assert(TestBuffer.Name == "Test Buffer") -assert(TestBuffer.Usage == "USAGE_DEFAULT") -assert(TestBuffer.BindFlags[1] == "BIND_VERTEX_BUFFER" and TestBuffer.BindFlags[2] == "BIND_SHADER_RESOURCE" or - TestBuffer.BindFlags[2] == "BIND_VERTEX_BUFFER" and TestBuffer.BindFlags[1] == "BIND_SHADER_RESOURCE") -assert(TestBuffer.Mode == "BUFFER_MODE_FORMATTED") - -TestBufferSRV = TestBuffer:CreateView{ - Name = "TestBuffer SRV", - ViewType = "BUFFER_VIEW_SHADER_RESOURCE", - ByteOffset = 16, - ByteWidth = 32, - Format = {ValueType = "VT_FLOAT32", NumComponents = 1, IsNormalized = false} -} - -assert(TestBufferSRV.ViewType == "BUFFER_VIEW_SHADER_RESOURCE" ) -assert(TestBufferSRV.ByteOffset == 16) -assert(TestBufferSRV.ByteWidth == 32) -assert(TestBufferSRV.Format.ValueType == "VT_FLOAT32" ) -assert(TestBufferSRV.Format.NumComponents == 1 ) -assert(TestBufferSRV.Format.IsNormalized == false ) - - -function TestBufferArg (Buffer) - assert(TestBuffer.Name == "Test Buffer") - assert(TestBuffer.Usage == "USAGE_DEFAULT") - assert(TestBuffer.BindFlags[1] == "BIND_VERTEX_BUFFER" and TestBuffer.BindFlags[2] == "BIND_SHADER_RESOURCE" or - TestBuffer.BindFlags[2] == "BIND_VERTEX_BUFFER" and TestBuffer.BindFlags[1] == "BIND_SHADER_RESOURCE") - Buffer = nil - collectgarbage() -end - - -TestBuffer2 = Buffer.Create({ - Name = "Test Buffer2", - Usage = "USAGE_STAGING", - CPUAccessFlags = {"CPU_ACCESS_WRITE"}, - uiSizeInBytes = 256 -}) -assert(TestBuffer2.Name == "Test Buffer2") -assert(TestBuffer2.Usage == "USAGE_STAGING") -assert(TestBuffer2.Mode == "BUFFER_MODE_UNDEFINED") -assert(TestBuffer2.CPUAccessFlags[1] == "CPU_ACCESS_WRITE") - -TestBuffer3 = Buffer.Create( - { - Name = "Test Buffer", - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_VERTEX_BUFFER", "BIND_SHADER_RESOURCE"}, - uiSizeInBytes = 64, - Mode = "BUFFER_MODE_FORMATTED", - ElementByteStride = 4 - } -) - -Context.SetVertexBuffers(1, TestBuffer, 0, TestBuffer3, 16, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION", "SET_VERTEX_BUFFERS_FLAG_RESET") -Context.SetVertexBuffers(1, TestBuffer, 0, nil) -Context.SetVertexBuffers(nil, nil, nil, "RESOURCE_STATE_TRANSITION_MODE_NONE", {"SET_VERTEX_BUFFERS_FLAG_RESET", "SET_VERTEX_BUFFERS_FLAG_RESET"}) - -TestBuffer3 = Buffer.Create({ - Name = "Test Buffer 3", - BindFlags = {"BIND_VERTEX_BUFFER", "BIND_UNORDERED_ACCESS", "BIND_SHADER_RESOURCE"}, - Mode = "BUFFER_MODE_RAW", - uiSizeInBytes = (4+4) * 4 * 4, - ElementByteStride = 4 * 4 -}) -assert( TestBuffer3.Mode == "BUFFER_MODE_RAW" ) - -TestBuffer3SRV = TestBuffer3:CreateView{ - Name = "TestBuffer3 SRV", - ViewType = "BUFFER_VIEW_SHADER_RESOURCE", - ByteOffset = 16, - ByteWidth = 32 -} -assert(TestBuffer3SRV.ViewType == "BUFFER_VIEW_SHADER_RESOURCE" ) -assert(TestBuffer3SRV.ByteOffset == 16) -assert(TestBuffer3SRV.ByteWidth == 32) - -Buff3UAV = TestBuffer3:CreateView{ - Name = "TestBuffer3 UAV", - ViewType = "BUFFER_VIEW_UNORDERED_ACCESS", - ByteOffset = 16 -} -assert(Buff3UAV.ViewType == "BUFFER_VIEW_UNORDERED_ACCESS" ) -assert(Buff3UAV.ByteOffset == 16 ) -assert(Buff3UAV.ByteWidth == TestBuffer3.uiSizeInBytes - Buff3UAV.ByteOffset) - - -function TestBufferViewArg(BuffViewArg) - assert( BuffViewArg.Name == "TestGlobalBuff2UAV" ) - assert( BuffViewArg.ViewType == "BUFFER_VIEW_UNORDERED_ACCESS" ) - assert( BuffViewArg.ByteOffset == 0 ) - assert( BuffViewArg.ByteWidth == 32 ) -end - - -IndexBuffer = Buffer.Create( - { BindFlags = "BIND_INDEX_BUFFER" }, - "VT_UINT32", - {0,1,2} -) -Context.SetIndexBuffer(IndexBuffer, 4, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - -TestTexture = Texture.Create{ - Name = "Test Texture 2D", - Type = "RESOURCE_DIM_TEX_2D_ARRAY", Width = 512, Height = 512, ArraySize = 16, - Format = "TEX_FORMAT_RGBA8_UNORM", - MipLevels = 8, - SampleCount = 1, - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_SHADER_RESOURCE", "BIND_UNORDERED_ACCESS"} -} - -assert( TestTexture.Name == "Test Texture 2D" ) -assert( TestTexture.Type == "RESOURCE_DIM_TEX_2D_ARRAY" ) -assert( TestTexture.Width == 512 ) -assert( TestTexture.Height == 512 ) -assert( TestTexture.ArraySize == 16 ) -assert( TestTexture.Format == "TEX_FORMAT_RGBA8_UNORM" ) -assert( TestTexture.MipLevels == 8 ) -assert( TestTexture.SampleCount == 1 ) -assert( TestTexture.Usage == "USAGE_DEFAULT" ) -assert( TestTexture.BindFlags[1] == "BIND_SHADER_RESOURCE" and TestTexture.BindFlags[2] == "BIND_UNORDERED_ACCESS" or - TestTexture.BindFlags[1] == "BIND_UNORDERED_ACCESS" and TestTexture.BindFlags[2] == "BIND_SHADER_RESOURCE" ) - -DefaultTestSRV = TestTexture:GetDefaultView("TEXTURE_VIEW_SHADER_RESOURCE") -assert( DefaultTestSRV.ViewType == "TEXTURE_VIEW_SHADER_RESOURCE" ) -assert( DefaultTestSRV.Format == TestTexture.Format ) -assert( DefaultTestSRV.TextureDim == TestTexture.Type ) -assert( DefaultTestSRV.MostDetailedMip == 0 ) -assert( DefaultTestSRV.NumMipLevels == TestTexture.MipLevels ) -assert( DefaultTestSRV.FirstArraySlice == 0 ) -assert( DefaultTestSRV.NumArraySlices == TestTexture.ArraySize ) - -TestUAV1 = TestTexture:CreateView{ - ViewType = "TEXTURE_VIEW_UNORDERED_ACCESS", - TextureDim = "RESOURCE_DIM_TEX_2D", - AccessFlags = "UAV_ACCESS_FLAG_READ", - MostDetailedMip = 1, - NumMipLevels = 1, - FirstArraySlice = 0, - NumArraySlices = 1 -} - -assert(TestUAV1.AccessFlags[1] == "UAV_ACCESS_FLAG_READ") -assert( type(TestUAV1.AccessFlags[2]) == "nil") - -TestUAV2 = TestTexture:CreateView{ - ViewType = "TEXTURE_VIEW_UNORDERED_ACCESS", - TextureDim = "RESOURCE_DIM_TEX_2D_ARRAY", - AccessFlags = "UAV_ACCESS_FLAG_WRITE", - FirstArraySlice = 0, - NumArraySlices = TestTexture.ArraySize -} -assert(TestUAV2.AccessFlags[1] == "UAV_ACCESS_FLAG_WRITE") -assert( type(TestUAV2.AccessFlags[2]) == "nil") - -TestUAV3 = TestTexture:CreateView{ - ViewType = "TEXTURE_VIEW_UNORDERED_ACCESS", - TextureDim = "RESOURCE_DIM_TEX_2D_ARRAY", - AccessFlags = {"UAV_ACCESS_FLAG_READ", "UAV_ACCESS_FLAG_WRITE"}, - MostDetailedMip = 4, - NumArraySlices = TestTexture.ArraySize -} - -function Set (list) - local set = {} - for _, l in ipairs(list) do set[l] = true end - return set -end -FlagsSet = Set(TestUAV3.AccessFlags) -assert(FlagsSet["UAV_ACCESS_FLAG_READ"] and FlagsSet["UAV_ACCESS_FLAG_WRITE"] and FlagsSet["UAV_ACCESS_FLAG_READ_WRITE"]) -assert( type(TestUAV3.AccessFlags[4]) == "nil") - - -DefaultTestSRV:SetSampler(TestSampler) - -if Constants.DeviceType == "D3D11" or Constants.DeviceType == "D3D12" then - - --TestTextureView = TextureView.Create(TestTexture, - TestTextureView = TestTexture:CreateView( - { - Name = "TestTextureSRV", - ViewType = "TEXTURE_VIEW_SHADER_RESOURCE", - TextureDim = "RESOURCE_DIM_TEX_2D_ARRAY", - Format = "TEX_FORMAT_RGBA8_UNORM", - MostDetailedMip = 1, - NumMipLevels = 2, - FirstArraySlice = 3, - NumArraySlices = 4 - } - ) - assert( TestTextureView.Name == "TestTextureSRV" ) - assert( TestTextureView.ViewType == "TEXTURE_VIEW_SHADER_RESOURCE" ) - assert( TestTextureView.TextureDim == "RESOURCE_DIM_TEX_2D_ARRAY" ) - assert( TestTextureView.Format == "TEX_FORMAT_RGBA8_UNORM" ) - assert( TestTextureView.MostDetailedMip == 1 ) - assert( TestTextureView.NumMipLevels == 2 ) - assert( TestTextureView.FirstArraySlice == 3 ) - assert( TestTextureView.NumArraySlices == 4 ) - - assert( TestGlobalTextureView.Name == "TestTextureSRV2" ) - assert( TestGlobalTextureView.ViewType == "TEXTURE_VIEW_SHADER_RESOURCE" ) - assert( TestGlobalTextureView.TextureDim == "RESOURCE_DIM_TEX_2D" ) - assert( TestGlobalTextureView.Format == "TEX_FORMAT_RGBA8_UNORM" ) - assert( TestGlobalTextureView.MostDetailedMip == 0 ) - assert( TestGlobalTextureView.NumMipLevels == 1 ) - assert( TestGlobalTextureView.FirstArraySlice == 0 ) - assert( TestGlobalTextureView.NumArraySlices == 1 ) -end - -function TestTextureViewArg(TextureView) - assert( TextureView.Name == "TestTextureSRV" ) - assert( TextureView.ViewType == "TEXTURE_VIEW_SHADER_RESOURCE" ) - assert( TextureView.TextureDim == "RESOURCE_DIM_TEX_2D_ARRAY" ) - assert( TextureView.Format == "TEX_FORMAT_RGBA8_UNORM" ) - assert( TextureView.MostDetailedMip == 1 ) - assert( TextureView.NumMipLevels == 2 ) - assert( TextureView.FirstArraySlice == 3 ) - assert( TextureView.NumArraySlices == 4 ) -end - - -function TestTextureArg(Texture) - CheckTextureAttribs( Texture ) - collectgarbage() -end - - -TestDrawAttribs = DrawAttribs.Create{ - NumIndices = 128, - IndexType = "VT_UINT16", - NumInstances = 32, - BaseVertex = 48, - IndirectDrawArgsOffset = 1024, - StartVertexLocation = 64, - FirstInstanceLocation = 96, - pIndirectDrawAttribs = TestBuffer2, - IndirectAttribsBufferStateTransitionMode = "RESOURCE_STATE_TRANSITION_MODE_NONE", - Flags = {"DRAW_FLAG_VERIFY_STATES", "DRAW_FLAG_VERIFY_DRAW_ATTRIBS", "DRAW_FLAG_VERIFY_RENDER_TARGETS"} -} -assert( TestDrawAttribs.NumIndices == 128 ) -assert( TestDrawAttribs.IndexType == "VT_UINT16" ) -assert( TestDrawAttribs.NumInstances == 32 ) -assert( TestDrawAttribs.BaseVertex == 48 ) -assert( TestDrawAttribs.IndirectDrawArgsOffset == 1024 ) -assert( TestDrawAttribs.StartVertexLocation == 64 ) -assert( TestDrawAttribs.FirstInstanceLocation == 96 ) ---Context.Draw(TestBuffer2) - - -TestDrawAttribs.NumVertices = 92 -TestDrawAttribs.IndexType = "VT_UINT32" -TestDrawAttribs.NumInstances = 19 -TestDrawAttribs.BaseVertex = 498 -TestDrawAttribs.IndirectDrawArgsOffset = 234 -TestDrawAttribs.FirstIndexLocation = 264 -TestDrawAttribs.FirstInstanceLocation = 946 -TestDrawAttribs.pIndirectDrawAttribs = TestGlobalBuffer -TestDrawAttribs.IndirectAttribsBufferStateTransitionMode = "RESOURCE_STATE_TRANSITION_MODE_TRANSITION" - -TestDrawAttribs2 = DrawAttribs.Create{ - pIndirectDrawAttribs = TestDrawAttribs.pIndirectDrawAttribs -} -assert( TestDrawAttribs.pIndirectDrawAttribs.Name == TestDrawAttribs2.pIndirectDrawAttribs.Name ) - -assert( TestDrawAttribs.NumIndices == 92 ) -assert( TestDrawAttribs.NumVertices == 92 ) -assert( TestDrawAttribs.IndexType == "VT_UINT32" ) -assert( TestDrawAttribs.NumInstances == 19 ) -assert( TestDrawAttribs.BaseVertex == 498 ) -assert( TestDrawAttribs.IndirectDrawArgsOffset == 234 ) -assert( TestDrawAttribs.FirstIndexLocation == 264 ) -assert( TestDrawAttribs.StartVertexLocation == 264 ) -assert( TestDrawAttribs.FirstInstanceLocation == 946 ) -assert( TestDrawAttribs.IndirectAttribsBufferStateTransitionMode == "RESOURCE_STATE_TRANSITION_MODE_TRANSITION" ) - - - -assert( TestGlobalDrawAttribs.NumVertices == 123 ); -assert( TestGlobalDrawAttribs.NumIndices == 123 ); -assert( TestGlobalDrawAttribs.IndexType == "VT_UINT16" ); -assert( TestGlobalDrawAttribs.NumInstances == 19 ); -assert( TestGlobalDrawAttribs.BaseVertex == 97 ); -assert( TestGlobalDrawAttribs.IndirectDrawArgsOffset == 120 ); -assert( TestGlobalDrawAttribs.StartVertexLocation == 98 ); -assert( TestGlobalDrawAttribs.FirstIndexLocation == 98 ); - -function TestDrawAttribsArg(DrawAttrs) - assert( DrawAttrs.NumVertices == 34 ); - assert( DrawAttrs.NumIndices == 34 ); - assert( DrawAttrs.IndexType == "VT_UINT16" ); - assert( DrawAttrs.NumInstances == 139 ); - assert( DrawAttrs.BaseVertex == 937 ); - assert( DrawAttrs.IndirectDrawArgsOffset == 1205 ); - assert( DrawAttrs.StartVertexLocation == 198 ); - assert( DrawAttrs.FirstIndexLocation == 198 ); -end ---getmetatable(TestSampler).__index = {} - -TestResourceMapping = ResourceMapping.Create{ - {Name = "TestShaderName", pObject = DefaultTestSRV}, - {Name = "TestShaderName2", pObject = DefaultTestSRV}, - {Name = "TestBufferName", pObject = TestGlobalBuffer} -} - -assert( TestResourceMapping["TestShaderName"].ViewType == "TEXTURE_VIEW_SHADER_RESOURCE" ) -assert( TestResourceMapping["TestBufferName"].Name == "TestGlobalBuff" ) -assert( type(TestResourceMapping["BadName"]) == "nil" ) - -TestResourceMapping["TestBufferName2"] = TestBuffer -assert( TestResourceMapping["TestBufferName2"].Name == "Test Buffer" ) - -TestResourceMapping["TestShaderName"] = DefaultTestSRV -assert( TestResourceMapping["TestShaderName"].ViewType == "TEXTURE_VIEW_SHADER_RESOURCE" ) - -TestResourceMapping["TestBufferName2"] = nil -assert( type(TestResourceMapping["TestBufferName2"]) == "nil" ) - -assert( TestGlobalResourceMapping["TestGlobalTextureSRV"].ViewType == "TEXTURE_VIEW_SHADER_RESOURCE" ) - -function TestResourceMappingArg(ResMappingArg) - assert( ResMappingArg["TestGlobalTextureSRV2"].ViewType == "TEXTURE_VIEW_SHADER_RESOURCE" ) - ResMappingArg["TestBufferName"] = TestBuffer -end diff --git a/Tests/TestApp/assets/Shaders/CSTest/FillTextureDX.csh b/Tests/TestApp/assets/Shaders/CSTest/FillTextureDX.csh deleted file mode 100644 index 0006edd..0000000 --- a/Tests/TestApp/assets/Shaders/CSTest/FillTextureDX.csh +++ /dev/null @@ -1,14 +0,0 @@ - -RWTexture2D<unorm float4> g_tex2DTestUAV; - -[numthreads(16,16,1)] -void main(uint3 DTid : SV_DispatchThreadID) -{ - uint2 ui2Dim; - g_tex2DTestUAV.GetDimensions(ui2Dim.x, ui2Dim.y); - if( DTid.x >= ui2Dim.x || DTid.y >= ui2Dim.y )return; - - float2 f2UV = float2(DTid.xy) / float2(ui2Dim); - float DistFromCenter = length(f2UV - float2(0.5,0.5)); - g_tex2DTestUAV[DTid.xy] = float4((1-DistFromCenter), abs(f2UV.x-0.5), abs(0.5-f2UV.y), 0.0); -} diff --git a/Tests/TestApp/assets/Shaders/CSTest/FillTextureGL.csh b/Tests/TestApp/assets/Shaders/CSTest/FillTextureGL.csh deleted file mode 100644 index 0459cc1..0000000 --- a/Tests/TestApp/assets/Shaders/CSTest/FillTextureGL.csh +++ /dev/null @@ -1,17 +0,0 @@ - -layout(rgba8, binding = 2) uniform writeonly image2D g_tex2DTestUAV; - -layout (local_size_x = 16, local_size_y = 8, local_size_z = 1) in; - -// Declare main program function which is executed once -// glDispatchCompute is called from the application. -void main() -{ - ivec2 Dim = imageSize(g_tex2DTestUAV); - if( gl_GlobalInvocationID.x >= uint(Dim.x) || gl_GlobalInvocationID.y >= uint(Dim.y) ) - return; - - vec2 f2UV = vec2( ivec2(gl_GlobalInvocationID.xy) % Dim ) / vec2(Dim); - float DistFromCenter = length(f2UV - vec2(0.5,0.5)); - imageStore(g_tex2DTestUAV, ivec2(gl_GlobalInvocationID.xy), vec4((1.0-DistFromCenter), abs(f2UV.x-0.5), abs(0.5-f2UV.y), 0.0) ); -} diff --git a/Tests/TestApp/assets/Shaders/CSTest/UpdateDispatchArgsBuffDX.csh b/Tests/TestApp/assets/Shaders/CSTest/UpdateDispatchArgsBuffDX.csh deleted file mode 100644 index c930789..0000000 --- a/Tests/TestApp/assets/Shaders/CSTest/UpdateDispatchArgsBuffDX.csh +++ /dev/null @@ -1,9 +0,0 @@ - -RWBuffer<uint4> bufIndirectDispatchArgs; - -[numthreads(1,1,1)] -void main(uint3 DTid : SV_DispatchThreadID) -{ - bufIndirectDispatchArgs[0] = uint4(0,0,0,0); - bufIndirectDispatchArgs[1] = uint4(1,1,1,0); -} diff --git a/Tests/TestApp/assets/Shaders/CSTest/UpdateDispatchArgsBuffGL.csh b/Tests/TestApp/assets/Shaders/CSTest/UpdateDispatchArgsBuffGL.csh deleted file mode 100644 index 6f44c48..0000000 --- a/Tests/TestApp/assets/Shaders/CSTest/UpdateDispatchArgsBuffGL.csh +++ /dev/null @@ -1,22 +0,0 @@ - -// Declare input/output buffer from/to wich we will read/write data. -// In this particular shader we only write data into the buffer. -// If you do not want your data to be aligned by compiler try to use: -// packed or shared instead of std140 keyword. -// We also bind the buffer to index 0. You need to set the buffer binding -// in the range [0..3] – this is the minimum range approved by Khronos. -// Notice that various platforms might support more indices than that. -layout(std140, binding = 3) buffer bufIndirectDispatchArgs -{ - uvec4 data[]; -}g_DispatchArgs; - - -layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -// Declare main program function which is executed once -// glDispatchCompute is called from the application. -void main() -{ - g_DispatchArgs.data[0] = uvec4(0,0,0,0); - g_DispatchArgs.data[1] = uvec4(1,1,1,0); -} diff --git a/Tests/TestApp/assets/Shaders/CSTest/UpdateDrawArgsBuffDX.csh b/Tests/TestApp/assets/Shaders/CSTest/UpdateDrawArgsBuffDX.csh deleted file mode 100644 index 2c754d5..0000000 --- a/Tests/TestApp/assets/Shaders/CSTest/UpdateDrawArgsBuffDX.csh +++ /dev/null @@ -1,9 +0,0 @@ - -RWBuffer<uint4> bufIndirectDrawArgs; - -[numthreads(1,1,1)] -void main(uint3 DTid : SV_DispatchThreadID) -{ - bufIndirectDrawArgs[0] = uint4(4,1,0,0); - bufIndirectDrawArgs[1] = uint4(0,0,0,0); -} diff --git a/Tests/TestApp/assets/Shaders/CSTest/UpdateDrawArgsBuffGL.csh b/Tests/TestApp/assets/Shaders/CSTest/UpdateDrawArgsBuffGL.csh deleted file mode 100644 index fda2387..0000000 --- a/Tests/TestApp/assets/Shaders/CSTest/UpdateDrawArgsBuffGL.csh +++ /dev/null @@ -1,12 +0,0 @@ - - -layout(rgba32ui, binding = 3) uniform writeonly uimageBuffer bufIndirectDrawArgs; - -layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -// Declare main program function which is executed once -// glDispatchCompute is called from the application. -void main() -{ - imageStore(bufIndirectDrawArgs, 0, uvec4(4,1,0,0)); - imageStore(bufIndirectDrawArgs, 1, uvec4(0,0,0,0)); -} diff --git a/Tests/TestApp/assets/Shaders/CSTest/UpdateIndBuffDX.csh b/Tests/TestApp/assets/Shaders/CSTest/UpdateIndBuffDX.csh deleted file mode 100644 index af003ae..0000000 --- a/Tests/TestApp/assets/Shaders/CSTest/UpdateIndBuffDX.csh +++ /dev/null @@ -1,8 +0,0 @@ - -RWBuffer<uint4> bufIndices; - -[numthreads(1,1,1)] -void main(uint3 DTid : SV_DispatchThreadID) -{ - bufIndices[0] = uint4(0,1,2,3); -} diff --git a/Tests/TestApp/assets/Shaders/CSTest/UpdateIndBuffGL.csh b/Tests/TestApp/assets/Shaders/CSTest/UpdateIndBuffGL.csh deleted file mode 100644 index 347f8cc..0000000 --- a/Tests/TestApp/assets/Shaders/CSTest/UpdateIndBuffGL.csh +++ /dev/null @@ -1,20 +0,0 @@ - -// Declare input/output buffer from/to wich we will read/write data. -// In this particular shader we only write data into the buffer. -// If you do not want your data to be aligned by compiler try to use: -// packed or shared instead of std140 keyword. -// We also bind the buffer to index 0. You need to set the buffer binding -// in the range [0..3] – this is the minimum range approved by Khronos. -// Notice that various platforms might support more indices than that. -layout(std140, binding = 1) buffer bufIndices -{ - uvec4 data[]; -}g_Indices; - -layout (local_size_x = 2, local_size_y = 1, local_size_z = 1) in; -// Declare main program function which is executed once -// glDispatchCompute is called from the application. -void main() -{ - g_Indices.data[0] = uvec4(0,1,2,3); -} diff --git a/Tests/TestApp/assets/Shaders/CSTest/UpdateVertBuffDX.csh b/Tests/TestApp/assets/Shaders/CSTest/UpdateVertBuffDX.csh deleted file mode 100644 index c84fabd..0000000 --- a/Tests/TestApp/assets/Shaders/CSTest/UpdateVertBuffDX.csh +++ /dev/null @@ -1,35 +0,0 @@ - -RWBuffer<float4> bufPositions : register(u3); -RWBuffer<float4> bufTexcoord; -Buffer<float4> Offsets; - -[numthreads(2,1,1)] -void main(uint3 DTid : SV_DispatchThreadID) -{ - int Ind = int(DTid.x); - - float2 pos[4] = - { - float2(0.0, 0.0), - float2(0.0, 1.0), - float2(1.0, 0.0), - float2(1.0, 1.0) - }; - - float2 CurrPos = pos[Ind]; - float2 Offset = Offsets.Load(Ind); - CurrPos += Offset; - - CurrPos = CurrPos*float2(0.3, 0.3) + float2(0.0, -1.0); - - float2 uv[4] = - { - float2(0.0, 1.0), - float2(0.0, 0.0), - float2(1.0, 1.0), - float2(1.0, 0.0) - }; - - bufPositions[Ind] = float4(CurrPos.xy, 0.0, 0.0); - bufTexcoord[Ind] = float4(uv[Ind],0,0); -} diff --git a/Tests/TestApp/assets/Shaders/CSTest/UpdateVertBuffGL.csh b/Tests/TestApp/assets/Shaders/CSTest/UpdateVertBuffGL.csh deleted file mode 100644 index bb3162b..0000000 --- a/Tests/TestApp/assets/Shaders/CSTest/UpdateVertBuffGL.csh +++ /dev/null @@ -1,35 +0,0 @@ - -layout(rgba32f) uniform writeonly imageBuffer bufPositions; -layout(rgba32f) uniform writeonly imageBuffer bufTexcoord; - -uniform samplerBuffer Offsets; - -layout (local_size_x = 2, local_size_y = 1, local_size_z = 1) in; -// Declare main program function which is executed once -// glDispatchCompute is called from the application. -void main() -{ - int Ind = int(gl_GlobalInvocationID.x); - - vec2 pos[4]; - pos[0] = vec2(0.0, 0.0); - pos[1] = vec2(0.0, 1.0); - pos[2] = vec2(1.0, 0.0); - pos[3] = vec2(1.0, 1.0); - - vec2 CurrPos = pos[Ind]; - - vec4 Offset = texelFetch(Offsets, Ind); - CurrPos += Offset.xy; - - CurrPos = CurrPos*vec2(0.3, 0.3) + vec2(0.0, -1.0); - - vec2 uv[4]; - uv[0] = vec2(0.0, 1.0); - uv[1] = vec2(0.0, 0.0); - uv[2] = vec2(1.0, 1.0); - uv[3] = vec2(1.0, 0.0); - - imageStore(bufPositions, Ind, vec4(CurrPos.xy, 0.0, 0.0)); - imageStore(bufTexcoord, Ind, vec4(uv[Ind].xy, 0.0, 0.0)); -} diff --git a/Tests/TestApp/assets/Shaders/CSTest/UpdateVertBuffGLES.csh b/Tests/TestApp/assets/Shaders/CSTest/UpdateVertBuffGLES.csh deleted file mode 100644 index 01f68ee..0000000 --- a/Tests/TestApp/assets/Shaders/CSTest/UpdateVertBuffGLES.csh +++ /dev/null @@ -1,44 +0,0 @@ - -// Declare input/output buffer from/to wich we will read/write data. -// In this particular shader we only write data into the buffer. -// If you do not want your data to be aligned by compiler try to use: -// packed or shared instead of std140 keyword. -// We also bind the buffer to index 0. You need to set the buffer binding -// in the range [0..3] – this is the minimum range approved by Khronos. -// Notice that various platforms might support more indices than that. -layout(std140, binding = 2) buffer bufPositions -{ - vec4 data[]; -}g_Positions; - -layout(std140) buffer bufTexcoord -{ - vec4 data[]; -}g_Texcoords; - - -layout (local_size_x = 2, local_size_y = 1, local_size_z = 1) in; -// Declare main program function which is executed once -// glDispatchCompute is called from the application. -void main() -{ - int Ind = int(gl_GlobalInvocationID.x); - - vec2 pos[4]; - pos[0] = vec2(0.0, 0.0); - pos[1] = vec2(0.0, 1.0); - pos[2] = vec2(1.0, 0.0); - pos[3] = vec2(1.0, 1.0); - - vec2 CurrPos = pos[Ind]; - CurrPos = CurrPos*vec2(0.3, 0.3) + vec2(0.0, -1.0); - - vec2 uv[4]; - uv[0] = vec2(0.0, 1.0); - uv[1] = vec2(0.0, 0.0); - uv[2] = vec2(1.0, 1.0); - uv[3] = vec2(1.0, 0.0); - - g_Positions.data[Ind] = vec4(CurrPos.xy, 0.0, 0.0); - g_Texcoords.data[Ind] = vec4(uv[Ind], 0.0, 0.0); -} diff --git a/Tests/TestApp/assets/Shaders/GSTestDX.gsh b/Tests/TestApp/assets/Shaders/GSTestDX.gsh deleted file mode 100644 index 4916ff2..0000000 --- a/Tests/TestApp/assets/Shaders/GSTestDX.gsh +++ /dev/null @@ -1,37 +0,0 @@ - -struct VSOutput -{ - float4 f4Position : SV_Position; - float3 f3Color : COLOR; -}; - -struct GSOut -{ - VSOutput VSOut; -}; - - -[maxvertexcount(6)] -void main(point VSOutput In[1], - inout TriangleStream<GSOut> triStream ) -{ - float2 Offsets[3]; - Offsets[0] = float2(-0.05, -0.05); - Offsets[1] = float2(+0.05, -0.05); - Offsets[2] = float2( 0.0, 0.0); - for(int i=0; i<3; i++) - { - GSOut Out; - Out.VSOut = In[0]; - Out.VSOut.f4Position.xy += Offsets[i]; - triStream.Append( Out ); - } - triStream.RestartStrip(); - for(int j=0; j<3; j++) - { - GSOut Out; - Out.VSOut = In[0]; - Out.VSOut.f4Position.xy += Offsets[j]*float2(1.0, -1.0); - triStream.Append( Out ); - } -} diff --git a/Tests/TestApp/assets/Shaders/GSTestDX.psh b/Tests/TestApp/assets/Shaders/GSTestDX.psh deleted file mode 100644 index 9686129..0000000 --- a/Tests/TestApp/assets/Shaders/GSTestDX.psh +++ /dev/null @@ -1,18 +0,0 @@ -struct VSOutput -{ - float4 f4Position : SV_Position; - float3 f3Color : COLOR; -}; - -struct GSOut -{ - VSOutput VSOut; -}; - - - -void main(GSOut In, - out float4 Color : SV_Target) -{ - Color = float4(In.VSOut.f3Color,1.0); -} diff --git a/Tests/TestApp/assets/Shaders/GSTestDX.vsh b/Tests/TestApp/assets/Shaders/GSTestDX.vsh deleted file mode 100644 index a5c43ea..0000000 --- a/Tests/TestApp/assets/Shaders/GSTestDX.vsh +++ /dev/null @@ -1,24 +0,0 @@ - -struct VSIn -{ - uint uiVertexId : SV_VertexID; -}; - -struct VSOutput -{ - float4 f4Position : SV_Position; - float3 f3Color : COLOR; -}; - -void main(VSIn In, - out VSOutput Out) -{ - float4 Positions[2]; - Positions[0] = float4(-0.4,0.3,0.0,1.0); - Positions[1] = float4(-0.35,0.25,0.0,1.0); - float3 Color[2]; - Color[0] = float3(1.0,0.0,0.0); - Color[1] = float3(0.0,1.0,0.0); - Out.f4Position = Positions[In.uiVertexId]; - Out.f3Color = Color[In.uiVertexId]; -} diff --git a/Tests/TestApp/assets/Shaders/RTTest/BlendTexturesPS_DX.hlsl b/Tests/TestApp/assets/Shaders/RTTest/BlendTexturesPS_DX.hlsl deleted file mode 100644 index e6030f0..0000000 --- a/Tests/TestApp/assets/Shaders/RTTest/BlendTexturesPS_DX.hlsl +++ /dev/null @@ -1,23 +0,0 @@ - -Texture2D<float4> g_tex2DTest0 : register(t2); -SamplerState g_tex2DTest0_sampler : register(s3); - -Texture2D<float4> g_tex2DTest1; -SamplerState g_tex2DTest1_sampler; - -Texture2D<float4> g_tex2DTest2; -SamplerState g_tex2DTest2_sampler; - -struct VSOut -{ - float4 f4Position : SV_Position; - float2 f2UV : TEXCOORD; -}; - -float4 main(VSOut In) : SV_Target -{ - float4 Col0 = g_tex2DTest0.Sample( g_tex2DTest0_sampler, In.f2UV ); - float4 Col1 = g_tex2DTest1.Sample( g_tex2DTest1_sampler, In.f2UV ); - float4 Col2 = g_tex2DTest2.Sample( g_tex2DTest2_sampler, In.f2UV ); - return float4(Col0.x, Col1.y, Col2.z, 0.0); -} diff --git a/Tests/TestApp/assets/Shaders/RTTest/BlendTexturesPS_GL.glsl b/Tests/TestApp/assets/Shaders/RTTest/BlendTexturesPS_GL.glsl deleted file mode 100644 index 726dfee..0000000 --- a/Tests/TestApp/assets/Shaders/RTTest/BlendTexturesPS_GL.glsl +++ /dev/null @@ -1,21 +0,0 @@ - -uniform sampler2D g_tex2DTest0; -uniform sampler2D g_tex2DTest1; -uniform sampler2D g_tex2DTest2; - -layout(location = 1)in vec2 ex_UV; - -layout(location = 0) out vec4 out_Color; - -void main() -{ - vec2 UV = vec2( ex_UV.x, ex_UV.y ); -#ifndef TARGET_API_VULKAN - UV.y = 1.0 - UV.y; -#endif - - vec4 Col0 = texture(g_tex2DTest0, UV); - vec4 Col1 = texture(g_tex2DTest1, UV); - vec4 Col2 = texture(g_tex2DTest2, UV); - out_Color = vec4(Col0.x, Col1.y, Col2.z, 0.0); -} diff --git a/Tests/TestApp/assets/Shaders/RTTest/QuadVS_DX.hlsl b/Tests/TestApp/assets/Shaders/RTTest/QuadVS_DX.hlsl deleted file mode 100644 index d47bb59..0000000 --- a/Tests/TestApp/assets/Shaders/RTTest/QuadVS_DX.hlsl +++ /dev/null @@ -1,21 +0,0 @@ - -struct VSIn -{ - float3 f3Position : ATTRIB0; - float2 f2UV : ATTRIB1; -}; - -struct VSOut -{ - float4 f4Position : SV_Position; - float2 f2UV : TEXCOORD; -}; - -VSOut main(VSIn In) -{ - VSOut Out; - Out.f4Position.xyz = In.f3Position; - Out.f4Position.w = 1; - Out.f2UV = In.f2UV; - return Out; -} diff --git a/Tests/TestApp/assets/Shaders/RTTest/QuadVS_GL.glsl b/Tests/TestApp/assets/Shaders/RTTest/QuadVS_GL.glsl deleted file mode 100644 index 77d984e..0000000 --- a/Tests/TestApp/assets/Shaders/RTTest/QuadVS_GL.glsl +++ /dev/null @@ -1,24 +0,0 @@ - -layout(location = 0) in vec3 in_Position; -layout(location = 1) in vec2 in_UV; - -layout(location = 1) out vec2 ex_UV; - -//To use any built-in input or output in the gl_PerVertex and -//gl_PerFragment blocks in separable program objects, shader code must -//redeclare those blocks prior to use. -// -// Declaring this block causes compilation error on NVidia GLES -#ifndef GL_ES -out gl_PerVertex -{ - vec4 gl_Position; -}; -#endif - -void main() -{ - gl_Position.xyz = in_Position; - gl_Position.w = 1.0; - ex_UV = in_UV; -} diff --git a/Tests/TestApp/assets/Shaders/RTTest/RenderToTexturesPS_DX.hlsl b/Tests/TestApp/assets/Shaders/RTTest/RenderToTexturesPS_DX.hlsl deleted file mode 100644 index c3e08bc..0000000 --- a/Tests/TestApp/assets/Shaders/RTTest/RenderToTexturesPS_DX.hlsl +++ /dev/null @@ -1,13 +0,0 @@ -struct VSOut -{ - float4 f4Position : SV_Position; - float2 f2UV : TEXCOORD; -}; - -void main(VSOut In, - out float4 Col0 : SV_Target0, - out float4 Col1 : SV_Target1) -{ - Col0 = float4( 0.5+0.5*cos(In.f2UV.x*3.1415*6.0), 0.0, 0.0, 0.0 ); - Col1 = float4( 0.0, 0.5+0.5*cos(In.f2UV.y*3.1415*8.0), 0.0, 0.0 ); -} diff --git a/Tests/TestApp/assets/Shaders/RTTest/RenderToTexturesPS_GL.glsl b/Tests/TestApp/assets/Shaders/RTTest/RenderToTexturesPS_GL.glsl deleted file mode 100644 index b673f11..0000000 --- a/Tests/TestApp/assets/Shaders/RTTest/RenderToTexturesPS_GL.glsl +++ /dev/null @@ -1,11 +0,0 @@ - -layout(location = 1) in vec2 ex_UV; - -layout (location = 0) out vec4 out_Color0; -layout (location = 1) out vec4 out_Color1; - -void main() -{ - out_Color0 = vec4( 0.5+0.5*cos(ex_UV.x*3.1415*6.0), 0.0, 0.0, 0.0 ); - out_Color1 = vec4( 0.0, 0.5+0.5*cos(ex_UV.y*3.1415*8.0), 0.0, 0.0 ); -} diff --git a/Tests/TestApp/assets/Shaders/SpriteDX.psh b/Tests/TestApp/assets/Shaders/SpriteDX.psh deleted file mode 100644 index 4ec1d7b..0000000 --- a/Tests/TestApp/assets/Shaders/SpriteDX.psh +++ /dev/null @@ -1,14 +0,0 @@ - -Texture2D<float4> g_tex2DTest : register(t2); -SamplerState g_tex2DTest_sampler : register(s3); - -struct VSOut -{ - float4 f4Position : SV_Position; - float2 f2UV : UV; -}; - -float4 main(VSOut In) : SV_Target -{ - return g_tex2DTest.SampleLevel(g_tex2DTest_sampler, In.f2UV, 0); -} diff --git a/Tests/TestApp/assets/Shaders/SpriteGL.psh b/Tests/TestApp/assets/Shaders/SpriteGL.psh deleted file mode 100644 index f2bdd11..0000000 --- a/Tests/TestApp/assets/Shaders/SpriteGL.psh +++ /dev/null @@ -1,11 +0,0 @@ -// Fragment Shader – file "minimal.frag" - -layout(location = 1)in vec2 in_UV; -uniform sampler2D g_tex2DTest; - -layout(location = 0) out vec4 out_Color; - -void main(void) -{ - out_Color = textureLod(g_tex2DTest, in_UV, 0.0); -} diff --git a/Tests/TestApp/assets/Shaders/TessTestDX.psh b/Tests/TestApp/assets/Shaders/TessTestDX.psh deleted file mode 100644 index 9686129..0000000 --- a/Tests/TestApp/assets/Shaders/TessTestDX.psh +++ /dev/null @@ -1,18 +0,0 @@ -struct VSOutput -{ - float4 f4Position : SV_Position; - float3 f3Color : COLOR; -}; - -struct GSOut -{ - VSOutput VSOut; -}; - - - -void main(GSOut In, - out float4 Color : SV_Target) -{ - Color = float4(In.VSOut.f3Color,1.0); -} diff --git a/Tests/TestApp/assets/Shaders/TessTestQuadDX.dsh b/Tests/TestApp/assets/Shaders/TessTestQuadDX.dsh deleted file mode 100644 index 634ac31..0000000 --- a/Tests/TestApp/assets/Shaders/TessTestQuadDX.dsh +++ /dev/null @@ -1,32 +0,0 @@ - -struct DSOutput -{ - float4 f4Position : SV_Position; - float3 f3Color : COLOR; -}; - - -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 */ -void main( HS_CONSTANT_DATA_OUTPUT Input, - float2 QuadUV : SV_DomainLocation, - OutputPatch<HSOutput, 1> QuadPatch, - out DSOutput Out) -{ - Out.f4Position.xy = QuadPatch[0].Position.xy + QuadUV.xy * 0.2; - Out.f4Position.zw = QuadPatch[0].Position.zw; - Out.f3Color = frac( (QuadPatch[0].Color + float3(QuadUV.xy, 1.0)) * float3(4121.35f, 8232.25f, 9124.42f) ); -} diff --git a/Tests/TestApp/assets/Shaders/TessTestQuadDX.hsh b/Tests/TestApp/assets/Shaders/TessTestQuadDX.hsh deleted file mode 100644 index 33e24a3..0000000 --- a/Tests/TestApp/assets/Shaders/TessTestQuadDX.hsh +++ /dev/null @@ -1,46 +0,0 @@ - -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, 1> p, - uint BlockID : SV_PrimitiveID, - out float Inside[2] : SV_InsideTessFactor) -{ - HS_CONSTANT_DATA_OUTPUT Factors; - Factors.Edges[0] = 2.5 + float(BlockID); - Factors.Edges[1] = 4.8 + frac(p[0].f4Position.x*223.145); - Factors.Edges[2] = 5.9 + frac(p[0].f4Position.y*142.512); - Factors.Edges[3] = 7.5 - float(BlockID); - Inside[0] = 6.2 + p[0].f4Position.x*3.4; - Inside[1] = 7.3 + p[0].f4Position.y*1.4; - return Factors; -} - -struct HSOutput -{ - float4 Position : POS; - float3 Color : COL; -}; - -[domain("quad")] -[partitioning("fractional_even")] -[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/Tests/TestApp/assets/Shaders/TessTestQuadDX.vsh b/Tests/TestApp/assets/Shaders/TessTestQuadDX.vsh deleted file mode 100644 index 86042cc..0000000 --- a/Tests/TestApp/assets/Shaders/TessTestQuadDX.vsh +++ /dev/null @@ -1,24 +0,0 @@ - -struct VSIn -{ - uint uiVertexId : SV_VertexID; -}; - -struct VSOutput -{ - float4 f4Position : SV_Position; - float3 f3Color : COLOR; -}; - -void main(VSIn In, - out VSOutput Out) -{ - float4 Positions[2]; - Positions[0] = float4(-0.65,0.4,0.0,1.0); - Positions[1] = float4(-0.65,0.65,0.0,1.0); - float3 Color[2]; - Color[0] = float3(1.0,0.0,0.0); - Color[1] = float3(0.0,1.0,0.0); - Out.f4Position = Positions[In.uiVertexId]; - Out.f3Color = Color[In.uiVertexId]; -} diff --git a/Tests/TestApp/assets/Shaders/TessTestTriDX.dsh b/Tests/TestApp/assets/Shaders/TessTestTriDX.dsh deleted file mode 100644 index 1aa899e..0000000 --- a/Tests/TestApp/assets/Shaders/TessTestTriDX.dsh +++ /dev/null @@ -1,32 +0,0 @@ - -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/Tests/TestApp/assets/Shaders/TessTestTriDX.hsh b/Tests/TestApp/assets/Shaders/TessTestTriDX.hsh deleted file mode 100644 index 6280ebd..0000000 --- a/Tests/TestApp/assets/Shaders/TessTestTriDX.hsh +++ /dev/null @@ -1,44 +0,0 @@ - -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/Tests/TestApp/assets/Shaders/TessTestTriDX.vsh b/Tests/TestApp/assets/Shaders/TessTestTriDX.vsh deleted file mode 100644 index c807662..0000000 --- a/Tests/TestApp/assets/Shaders/TessTestTriDX.vsh +++ /dev/null @@ -1,24 +0,0 @@ - -struct VSIn -{ - uint uiVertexId : SV_VertexID; -}; - -struct VSOutput -{ - float4 f4Position : SV_Position; - float3 f3Color : COLOR; -}; - -void main(VSIn In, - out VSOutput Out) -{ - float4 Positions[2]; - Positions[0] = float4(-0.5,0.15,0.0,1.0); - Positions[1] = float4(-0.65,0.65,0.0,1.0); - float3 Color[2]; - Color[0] = float3(1.0,0.0,0.0); - Color[1] = float3(0.0,1.0,0.0); - Out.f4Position = Positions[In.uiVertexId]; - Out.f3Color = Color[In.uiVertexId]; -} diff --git a/Tests/TestApp/assets/Shaders/TextureIntTestDX.psh b/Tests/TestApp/assets/Shaders/TextureIntTestDX.psh deleted file mode 100644 index 4dfc67f..0000000 --- a/Tests/TestApp/assets/Shaders/TextureIntTestDX.psh +++ /dev/null @@ -1,28 +0,0 @@ - -Texture2D<DATA_TYPE> g_tex2DTest : register(t4); - -struct VSOut -{ - float4 f4Position : SV_Position; - float2 f2UV : UV; -}; - - -float4 main(VSOut In) : SV_Target -{ - float Width, Height; - g_tex2DTest.GetDimensions(Width, Height); - float2 IJ = In.f2UV * float2(Width, Height); - float4 Color0 = g_tex2DTest.Load( int3(IJ, 0) ) / 127.f; - float4 Color1 = g_tex2DTest.Load( int3(IJ/4, 2) ) / 127.f; - float4 Color2 = g_tex2DTest.Load( int3(IJ/16, 4) ) / 127.f; - float4 Color3 = g_tex2DTest.Load( int3(IJ/32, 5) ) / 127.f; - if( In.f2UV.x < 0.5 && In.f2UV.y < 0.5 ) - return Color0; - else if( In.f2UV.x > 0.5 && In.f2UV.y < 0.5 ) - return Color1; - else if( In.f2UV.x < 0.5 && In.f2UV.y > 0.5 ) - return Color2; - else - return Color3; -} diff --git a/Tests/TestApp/assets/Shaders/TextureIntTestGL.psh b/Tests/TestApp/assets/Shaders/TextureIntTestGL.psh deleted file mode 100644 index 23c3532..0000000 --- a/Tests/TestApp/assets/Shaders/TextureIntTestGL.psh +++ /dev/null @@ -1,33 +0,0 @@ -// Fragment Shader – file "minimal.frag" - -layout(location = 1)in vec2 in_UV; -uniform SAMPLER_TYPE g_tex2DTest; - -layout(location = 0) out vec4 out_Color; - -void main(void) -{ - vec2 TexSize; - - TexSize = vec2(textureSize(g_tex2DTest, 0)); - vec4 texel0 = vec4(texelFetch(g_tex2DTest, ivec2(in_UV*TexSize), 0)); - - TexSize = vec2(textureSize(g_tex2DTest, 2)); - vec4 texel1 = vec4(texelFetch(g_tex2DTest, ivec2(in_UV*TexSize), 2)); - - TexSize = vec2(textureSize(g_tex2DTest, 4)); - vec4 texel2 = vec4(texelFetch(g_tex2DTest, ivec2(in_UV*TexSize), 4)); - - TexSize = vec2(textureSize(g_tex2DTest, 5)); - vec4 texel3 = vec4(texelFetch(g_tex2DTest, ivec2(in_UV*TexSize), 5)); - - if( in_UV.x < 0.5 && in_UV.y < 0.5 ) - out_Color = texel0 / 127.f; - else if( in_UV.x > 0.5 && in_UV.y < 0.5 ) - out_Color = texel1 / 127.f; - else if( in_UV.x < 0.5 && in_UV.y > 0.5 ) - out_Color = texel2 / 127.f; - else - out_Color = texel3 / 127.f; -} - diff --git a/Tests/TestApp/assets/Shaders/TextureTestDX.psh b/Tests/TestApp/assets/Shaders/TextureTestDX.psh deleted file mode 100644 index 0d8e57e..0000000 --- a/Tests/TestApp/assets/Shaders/TextureTestDX.psh +++ /dev/null @@ -1,26 +0,0 @@ - -Texture2D<float4> g_tex2DTest : register(t2); -SamplerState g_tex2DTest_sampler : register(s3); - -struct VSOut -{ - float4 f4Position : SV_Position; - float2 f2UV : UV; -}; - - -float4 main(VSOut In) : SV_Target -{ - float4 Color0 = g_tex2DTest.SampleLevel(g_tex2DTest_sampler, In.f2UV, 0); - float4 Color1 = g_tex2DTest.SampleLevel(g_tex2DTest_sampler, In.f2UV, 2); - float4 Color2 = g_tex2DTest.SampleLevel(g_tex2DTest_sampler, In.f2UV, 4); - float4 Color3 = g_tex2DTest.SampleLevel(g_tex2DTest_sampler, In.f2UV, 5); - if( In.f2UV.x < 0.5 && In.f2UV.y < 0.5 ) - return Color0; - else if( In.f2UV.x > 0.5 && In.f2UV.y < 0.5 ) - return Color1; - else if( In.f2UV.x < 0.5 && In.f2UV.y > 0.5 ) - return Color2; - else - return Color3; -} diff --git a/Tests/TestApp/assets/Shaders/TextureTestDX.vsh b/Tests/TestApp/assets/Shaders/TextureTestDX.vsh deleted file mode 100644 index 78e6fd5..0000000 --- a/Tests/TestApp/assets/Shaders/TextureTestDX.vsh +++ /dev/null @@ -1,22 +0,0 @@ - -struct VSIn -{ - float3 f3Position : ATTRIB0; - float2 f2UV : ATTRIB1; -}; - -struct VSOut -{ - float4 f4Position : SV_Position; - float2 f2UV : UV; -}; - -VSOut main(VSIn In) -{ - VSOut Out; - Out.f4Position.xyz = In.f3Position; - //Out.f4Position.x += In.fOffset; - Out.f4Position.w = 1; - Out.f2UV = In.f2UV; - return Out; -} diff --git a/Tests/TestApp/assets/Shaders/TextureTestGL.psh b/Tests/TestApp/assets/Shaders/TextureTestGL.psh deleted file mode 100644 index 3f84f11..0000000 --- a/Tests/TestApp/assets/Shaders/TextureTestGL.psh +++ /dev/null @@ -1,22 +0,0 @@ -// Fragment Shader – file "minimal.frag" - -layout(location = 1)in vec2 in_UV; -uniform sampler2D g_tex2DTest; - -layout(location = 0) out vec4 out_Color; - -void main(void) -{ - vec4 Color0 = textureLod(g_tex2DTest, in_UV, 0.0); - vec4 Color1 = textureLod(g_tex2DTest, in_UV, 2.0); - vec4 Color2 = textureLod(g_tex2DTest, in_UV, 4.0); - vec4 Color3 = textureLod(g_tex2DTest, in_UV, 5.0); - if( in_UV.x < 0.5 && in_UV.y < 0.5 ) - out_Color = Color0; - else if( in_UV.x > 0.5 && in_UV.y < 0.5 ) - out_Color = Color1; - else if( in_UV.x < 0.5 && in_UV.y > 0.5 ) - out_Color = Color2; - else - out_Color = Color3; -} diff --git a/Tests/TestApp/assets/Shaders/TextureTestGL.vsh b/Tests/TestApp/assets/Shaders/TextureTestGL.vsh deleted file mode 100644 index e1faef7..0000000 --- a/Tests/TestApp/assets/Shaders/TextureTestGL.vsh +++ /dev/null @@ -1,25 +0,0 @@ -// Vertex Shader – file "minimal.vert" - -layout(location = 0) in vec3 in_Position; -layout(location = 1) in vec2 in_UV; - -layout(location = 1) out vec2 out_UV; - - -//To use any built-in input or output in the gl_PerVertex and -//gl_PerFragment blocks in separable program objects, shader code must -//redeclare those blocks prior to use. -// -// Declaring this block causes compilation error on NVidia GLES -#ifndef GL_ES -out gl_PerVertex -{ - vec4 gl_Position; -}; -#endif - -void main(void) -{ - out_UV = in_UV; - gl_Position = vec4(in_Position, 1.0); -} diff --git a/Tests/TestApp/assets/Shaders/UniformBufferDX.psh b/Tests/TestApp/assets/Shaders/UniformBufferDX.psh deleted file mode 100644 index fa0d12e..0000000 --- a/Tests/TestApp/assets/Shaders/UniformBufferDX.psh +++ /dev/null @@ -1,21 +0,0 @@ -cbuffer cbTestBlock : register(b5) -{ - float4 g_f4Color; -} - -cbuffer cbTestBlock2 : register(b3) -{ - float4 g_f4Color2; -} - -struct VSOut -{ - float4 f4Position : SV_Position; - float3 f3Color : COLOR; -}; - - -float4 main(VSOut In) : SV_Target -{ - return float4(In.f3Color,1.0) * g_f4Color + g_f4Color2; -} diff --git a/Tests/TestApp/assets/Shaders/UniformBufferGL.psh b/Tests/TestApp/assets/Shaders/UniformBufferGL.psh deleted file mode 100644 index 267e678..0000000 --- a/Tests/TestApp/assets/Shaders/UniformBufferGL.psh +++ /dev/null @@ -1,26 +0,0 @@ -// Fragment Shader – file "minimal.frag" - -layout(location = 1)in vec3 ex_Color; - -uniform cbTestBlock2 -{ - vec4 Color; -}g_TestBlock2; - -uniform cbTestBlock -{ - vec4 Color; -}g_TestBlock; - -layout(location = 0) out vec4 out_Color; - -void main(void) -{ - out_Color = g_TestBlock.Color * vec4(ex_Color,1.0) + g_TestBlock2.Color; - - // Try replacing the above with the following: - //vec3 tmp_Color; - //tmp_Color = ex_Color.rrr; - //out_Color = vec4(tmp_Color,1.0); -} - diff --git a/Tests/TestApp/assets/Shaders/minimalDX.psh b/Tests/TestApp/assets/Shaders/minimalDX.psh deleted file mode 100644 index fe51cd1..0000000 --- a/Tests/TestApp/assets/Shaders/minimalDX.psh +++ /dev/null @@ -1,11 +0,0 @@ -struct VSOut -{ - float4 f4Position : SV_Position; - float3 f3Color : COLOR; -}; - - -float4 main(VSOut In) : SV_Target -{ - return float4(In.f3Color,1); -} diff --git a/Tests/TestApp/assets/Shaders/minimalDX.vsh b/Tests/TestApp/assets/Shaders/minimalDX.vsh deleted file mode 100644 index a8577fd..0000000 --- a/Tests/TestApp/assets/Shaders/minimalDX.vsh +++ /dev/null @@ -1,23 +0,0 @@ - -struct VSIn -{ - float3 f3Position : ATTRIB0; - float3 f3Color : ATTRIB1; - //float fOffset : ATTRIB2; -}; - -struct VSOut -{ - float4 f4Position : SV_Position; - float3 f3Color : COLOR; -}; - -VSOut main(VSIn In) -{ - VSOut Out; - Out.f4Position.xyz = In.f3Position; - //Out.f4Position.x += In.fOffset; - Out.f4Position.w = 1; - Out.f3Color = In.f3Color; - return Out; -} diff --git a/Tests/TestApp/assets/Shaders/minimalGL.psh b/Tests/TestApp/assets/Shaders/minimalGL.psh deleted file mode 100644 index 8aafaa2..0000000 --- a/Tests/TestApp/assets/Shaders/minimalGL.psh +++ /dev/null @@ -1,16 +0,0 @@ -// Fragment Shader – file "minimal.frag" - -layout(location = 1) in vec3 ex_Color; - -layout(location = 0) out vec4 out_Color; - -void main(void) -{ - out_Color = vec4(ex_Color,1.0); - - // Try replacing the above with the following: - //vec3 tmp_Color; - //tmp_Color = ex_Color.rrr; - //out_Color = vec4(tmp_Color,1.0); -} - diff --git a/Tests/TestApp/assets/Shaders/minimalGL.vsh b/Tests/TestApp/assets/Shaders/minimalGL.vsh deleted file mode 100644 index 1ef7dbc..0000000 --- a/Tests/TestApp/assets/Shaders/minimalGL.vsh +++ /dev/null @@ -1,35 +0,0 @@ -// Vertex Shader – file "minimal.vert" - -layout(location = 0) in vec3 in_Position; -layout(location = 1) in vec3 in_Color; - -layout(location = 1) out vec3 ex_Color; - -uniform cbTestBlock3 -{ - vec4 Scale; -}g_TestBlock3; - -uniform cbTestBlock4 -{ - vec4 Scale; -}g_TestBlock4; - -//To use any built-in input or output in the gl_PerVertex and -//gl_PerFragment blocks in separable program objects, shader code must -//redeclare those blocks prior to use. -// -// Declaring this block causes compilation error on NVidia GLES -#ifndef GL_ES -out gl_PerVertex -{ - vec4 gl_Position; -}; -#endif - -void main(void) -{ - ex_Color = in_Color; - gl_Position = vec4(in_Position.x * g_TestBlock3.Scale.x, in_Position.y * g_TestBlock4.Scale.y, in_Position.z, 1.0); -} - diff --git a/Tests/TestApp/assets/Shaders/minimalInstDX.vsh b/Tests/TestApp/assets/Shaders/minimalInstDX.vsh deleted file mode 100644 index 1d0c2e3..0000000 --- a/Tests/TestApp/assets/Shaders/minimalInstDX.vsh +++ /dev/null @@ -1,23 +0,0 @@ - -struct VSIn -{ - float3 f3Position : ATTRIB0; - float3 f3Color : ATTRIB1; - float2 f2Offset : ATTRIB2; -}; - -struct VSOut -{ - float4 f4Position : SV_Position; - float3 f3Color : COLOR; -}; - -VSOut main(VSIn In) -{ - VSOut Out; - Out.f4Position.xyz = In.f3Position; - Out.f4Position.xy += In.f2Offset; - Out.f4Position.w = 1; - Out.f3Color = In.f3Color; - return Out; -} diff --git a/Tests/TestApp/assets/Shaders/minimalInstGL.vsh b/Tests/TestApp/assets/Shaders/minimalInstGL.vsh deleted file mode 100644 index 948b55d..0000000 --- a/Tests/TestApp/assets/Shaders/minimalInstGL.vsh +++ /dev/null @@ -1,27 +0,0 @@ -// Vertex Shader – file "minimal.vert" - -layout(location = 0) in vec3 in_Position; -layout(location = 1) in vec3 in_Color; -layout(location = 2) in vec2 in_Offset; - -layout(location = 1) out vec3 ex_Color; - -//To use any built-in input or output in the gl_PerVertex and -//gl_PerFragment blocks in separable program objects, shader code must -//redeclare those blocks prior to use. -// -// Declaring this block causes compilation error on NVidia GLES -#ifndef GL_ES -out gl_PerVertex -{ - vec4 gl_Position; -}; -#endif - - -void main(void) -{ - ex_Color = in_Color; - gl_Position = vec4(in_Position + vec3(in_Offset.xy,0.0), 1.0); -} - diff --git a/Tests/TestApp/assets/TestComputeShaders.lua b/Tests/TestApp/assets/TestComputeShaders.lua deleted file mode 100644 index 863c8a5..0000000 --- a/Tests/TestApp/assets/TestComputeShaders.lua +++ /dev/null @@ -1,372 +0,0 @@ --- Compute shader test script - -ThreadGroupSizeX = 16 -ThreadGroupSizeY = 8 - -TestTexture = Texture.Create{ - Name = "Compute Shader Test Texture", - Type = "RESOURCE_DIM_TEX_2D", Width = 256, Height = 256, - Format = "TEX_FORMAT_RGBA8_UNORM", - MipLevels = 7, - SampleCount = 1, - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_SHADER_RESOURCE", "BIND_UNORDERED_ACCESS"} -} - -UAVs = { [0] = TestTexture:CreateView{ ViewType = "TEXTURE_VIEW_UNORDERED_ACCESS", AccessFlags = "UAV_ACCESS_FLAG_WRITE"} } -for mip = 1, TestTexture.MipLevels-1 do - UAVs[mip] = TestTexture:CreateView{ ViewType = "TEXTURE_VIEW_UNORDERED_ACCESS", MostDetailedMip = mip, AccessFlags = "UAV_ACCESS_FLAG_WRITE" } - assert(UAVs[mip].AccessFlags[1] == "UAV_ACCESS_FLAG_WRITE" ) -end - -LinearSampler = Sampler.Create{ - MinFilter = "FILTER_TYPE_LINEAR", - MagFilter = "FILTER_TYPE_LINEAR", - MipFilter = "FILTER_TYPE_LINEAR" -} - -TestTexture:GetDefaultView("TEXTURE_VIEW_SHADER_RESOURCE"):SetSampler(LinearSampler) - -PositionsBuffer = Buffer.Create( - { - Name = "Position buffer", - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_VERTEX_BUFFER", "BIND_UNORDERED_ACCESS"}, - Mode = "BUFFER_MODE_FORMATTED", - ElementByteStride = 16, - uiSizeInBytes = (4 + 8) * 4 * 4 - } -) -PositionsBufferUAV = PositionsBuffer:CreateView -{ - Name = "bufPositions UAV", - ViewType = "BUFFER_VIEW_UNORDERED_ACCESS", - Format = {ValueType = "VT_FLOAT32", NumComponents = 4} -} - - -TexcoordBuffer = Buffer.Create( - { - Name = "Texcoord buffer", - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_VERTEX_BUFFER", "BIND_UNORDERED_ACCESS"}, - Mode = "BUFFER_MODE_FORMATTED", - ElementByteStride = 16, - uiSizeInBytes = (4 + 8) * 4 * 4 - } -) - - - -OffsetsBuffer = Buffer.Create( - { - Name = "Offsets buffer", - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_UNORDERED_ACCESS", "BIND_SHADER_RESOURCE"}, - --uiSizeInBytes = 64, - Mode = "BUFFER_MODE_FORMATTED", - ElementByteStride = 16 - }, - "VT_FLOAT32", - {0.03,0,0,0, 0,0.03,0,0, 0.03,0.03,0,0, -0.03,-0.03,0,0} -) -OffsetsBufferSRV = OffsetsBuffer:CreateView -{ - Name = "Offsets UAV", - ViewType = "BUFFER_VIEW_SHADER_RESOURCE", - Format = {ValueType = "VT_FLOAT32", NumComponents = 4} -} - - -IndexBuffer = Buffer.Create( - { - Name = "Index buffer", - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_INDEX_BUFFER", "BIND_UNORDERED_ACCESS"}, - Mode = "BUFFER_MODE_FORMATTED", - ElementByteStride = 16 - }, - "VT_UINT32", - {0,0,0,0} -) -IndexBufferUAV = IndexBuffer:CreateView -{ - Name = "bufIndices UAV", - ViewType = "BUFFER_VIEW_UNORDERED_ACCESS", - Format = {ValueType = "VT_UINT32", NumComponents = 4} -} - - -IndirectDrawArgsBuffer = Buffer.Create( - { - Name = "Indirect Draw Args Buffer", - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_INDIRECT_DRAW_ARGS", "BIND_UNORDERED_ACCESS"}, - ElementByteStride = 16, - Mode = "BUFFER_MODE_FORMATTED", - uiSizeInBytes = 32 - } -) -IndirectDrawArgsBufferUAV = IndirectDrawArgsBuffer:CreateView -{ - Name = "bufIndirectDrawArgs UAV", - ViewType = "BUFFER_VIEW_UNORDERED_ACCESS", - Format = {ValueType = "VT_UINT32", NumComponents = 4} -} - - -IndirectDispatchArgsBuffer = Buffer.Create( - { - Name = "Indirect Dispatch Args Buffer", - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_INDIRECT_DRAW_ARGS", "BIND_UNORDERED_ACCESS"}, - ElementByteStride = 16, - Mode = "BUFFER_MODE_FORMATTED", - uiSizeInBytes = 64 - } -) -IndirectDispatchArgsBufferUAV = IndirectDispatchArgsBuffer:CreateView -{ - Name = "bufIndirectDispatchArgs UAV", - ViewType = "BUFFER_VIEW_UNORDERED_ACCESS", - Format = {ValueType = "VT_UINT32", NumComponents = 4} -} - -TexcoordDataOffset = 2*4*4 -TexCoordUAV = TexcoordBuffer:CreateView -{ - ViewType = "BUFFER_VIEW_UNORDERED_ACCESS", - ByteOffset = TexcoordDataOffset, - ByteWidth = 4*4*4, - Format = {ValueType = "VT_FLOAT32", NumComponents = 4} -} - -ResMapping = ResourceMapping.Create{ - {Name = "g_tex2DTest", pObject = TestTexture:GetDefaultView("TEXTURE_VIEW_SHADER_RESOURCE")}, - {Name = "bufPositions", pObject = PositionsBufferUAV }, - {Name = "bufTexcoord", pObject = TexCoordUAV}, - {Name = "bufIndices", pObject = IndexBufferUAV}, - {Name = "bufIndirectDrawArgs", pObject = IndirectDrawArgsBufferUAV }, - {Name = "bufIndirectDispatchArgs", pObject = IndirectDispatchArgsBufferUAV }, - {Name = "Offsets", pObject = OffsetsBufferSRV} -} - -function GetShaderPath( ShaderName, ShaderExt, GLESSpecial ) - - local ProcessedShaderPath = "" - if Constants.DeviceType == "D3D11" or Constants.DeviceType == "D3D12" then - ProcessedShaderPath = "Shaders\\" .. ShaderName .. "DX." .. ShaderExt - elseif Constants.DeviceType == "OpenGL" or Constants.DeviceType == "Vulkan" or not GLESSpecial then - ProcessedShaderPath = "Shaders\\" .. ShaderName .. "GL." .. ShaderExt - else - ProcessedShaderPath = "Shaders\\" .. ShaderName .. "GLES." .. ShaderExt - end - - return ProcessedShaderPath -end - -FillTextureCS = Shader.Create{ - FilePath = GetShaderPath("CSTest\\FillTexture", "csh"), - UseCombinedTextureSamplers = true, - Desc = - { - ShaderType = "SHADER_TYPE_COMPUTE" - } -} - -UpdateVertBuffCS = Shader.Create{ - FilePath = GetShaderPath("CSTest\\UpdateVertBuff", "csh", true), - UseCombinedTextureSamplers = true, - Desc = {ShaderType = "SHADER_TYPE_COMPUTE"} -} - -UpdateIndBuffCS = Shader.Create{ - FilePath = GetShaderPath("CSTest\\UpdateIndBuff", "csh"), - UseCombinedTextureSamplers = true, - Desc = {ShaderType = "SHADER_TYPE_COMPUTE"} -} - -UpdateDrawArgsBuffCS = Shader.Create{ - FilePath = GetShaderPath("CSTest\\UpdateDrawArgsBuff", "csh"), - UseCombinedTextureSamplers = true, - Desc = {ShaderType = "SHADER_TYPE_COMPUTE"} -} - -UpdateDispatchArgsBuffCS = Shader.Create{ - FilePath = GetShaderPath("CSTest\\UpdateDispatchArgsBuff", "csh"), - UseCombinedTextureSamplers = true, - Desc = {ShaderType = "SHADER_TYPE_COMPUTE"} -} - -RenderVS = Shader.Create{ - FilePath = GetShaderPath("TextureTest", "vsh"), - UseCombinedTextureSamplers = true, - Desc = { ShaderType = "SHADER_TYPE_VERTEX" } -} - -RenderPS = Shader.Create{ - FilePath = GetShaderPath("TextureTest", "psh"), - UseCombinedTextureSamplers = true, - Desc = { ShaderType = "SHADER_TYPE_PIXEL" } -} - -FillTexturePSO = PipelineState.Create -{ - Name = "FillTexturePSO", - ResourceLayout = - { - Variables = {{ShaderStages = "SHADER_TYPE_COMPUTE", Name = "g_tex2DTestUAV", Type = "SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC"}} - }, - IsComputePipeline=true, - ComputePipeline = - { - pCS = FillTextureCS - } -} -assert(FillTexturePSO.ResourceLayout.Variables[1].ShaderStages[1] == "SHADER_TYPE_COMPUTE"); -assert(FillTexturePSO.ResourceLayout.Variables[1].Name == "g_tex2DTestUAV"); -assert(FillTexturePSO.ResourceLayout.Variables[1].Type == "SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC"); - -FillTextureSRB = FillTexturePSO:CreateShaderResourceBinding() - -UpdateVertBuffPSO = PipelineState.Create -{ - Name = "UpdateVertBuffPSO", - IsComputePipeline=true, - ComputePipeline = - { - pCS = UpdateVertBuffCS - } -} -UpdateVertBuffSRB = UpdateVertBuffPSO:CreateShaderResourceBinding() - -UpdateIndBuffPSO = PipelineState.Create -{ - Name = "UpdateIndBuffPSO", - IsComputePipeline=true, - ComputePipeline = - { - pCS = UpdateIndBuffCS - } -} -UpdateIndBuffSRB = UpdateIndBuffPSO:CreateShaderResourceBinding() - -UpdateDrawArgsBuffPSO = PipelineState.Create -{ - Name = "UpdateDrawArgsBuffPSO", - IsComputePipeline=true, - ComputePipeline = - { - pCS = UpdateDrawArgsBuffCS - } -} -UpdateDrawArgsBuffSRB = UpdateDrawArgsBuffPSO:CreateShaderResourceBinding() - -UpdateDispatchArgsBuffPSO = PipelineState.Create -{ - Name = "UpdateDispatchArgsBuffPSO", - IsComputePipeline=true, - ComputePipeline = - { - pCS = UpdateDispatchArgsBuffCS - } -} -UpdateDispatchArgsBuffSRB = UpdateDispatchArgsBuffPSO:CreateShaderResourceBinding() - -RenderPSO = PipelineState.Create -{ - Name = "CS Test - Render PSO", - GraphicsPipeline = - { - RasterizerDesc = - { - FillMode = "FILL_MODE_SOLID", - CullMode = "CULL_MODE_NONE" - }, - DepthStencilDesc = {DepthEnable = false}, - pVS = RenderVS, - pPS = RenderPS, - InputLayout = - { - { InputIndex = 0, BufferSlot = 0, NumComponents = 3, ValueType = "VT_FLOAT32", IsNormalized = false, Stride = 4*4}, - { InputIndex = 1, BufferSlot = 1, NumComponents = 2, ValueType = "VT_FLOAT32", IsNormalized = false, Stride = 4*4} - }, - RTVFormats = {extBackBufferFormat}, - DSVFormat = extDepthBufferFormat, - PrimitiveTopology = "PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP" - } -} -RenderPSO:BindStaticResources({"SHADER_TYPE_VERTEX", "SHADER_TYPE_PIXEL"}, ResMapping, {"BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED"}) -RenderSRB = RenderPSO:CreateShaderResourceBinding() - -UpdateVertBuffPSO:BindStaticResources("SHADER_TYPE_COMPUTE", ResMapping, {"BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED", "BIND_SHADER_RESOURCES_UPDATE_STATIC"} ) -UpdateIndBuffPSO:BindStaticResources("SHADER_TYPE_COMPUTE", ResMapping, {"BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED", "BIND_SHADER_RESOURCES_UPDATE_ALL"}) -UpdateDrawArgsBuffPSO:BindStaticResources("SHADER_TYPE_COMPUTE", ResMapping, {"BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED"}) -UpdateDispatchArgsBuffPSO:BindStaticResources("SHADER_TYPE_COMPUTE", ResMapping, {"BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED"}) - -FillTextureSRB:InitializeStaticResources() -UpdateVertBuffSRB:InitializeStaticResources() -UpdateIndBuffSRB:InitializeStaticResources() -UpdateDrawArgsBuffSRB:InitializeStaticResources() -UpdateDispatchArgsBuffSRB:InitializeStaticResources() -RenderSRB:InitializeStaticResources() - -DrawAttrs = DrawAttribs.Create{ - IndexType = "VT_UINT32", - pIndirectDrawAttribs = IndirectDrawArgsBuffer, - IndirectAttribsBufferStateTransitionMode = "RESOURCE_STATE_TRANSITION_MODE_TRANSITION", - Flags = {"DRAW_FLAG_VERIFY_ALL"} -} - - - -function Draw() - Context.SetPipelineState(RenderPSO) - Context.TransitionShaderResources(RenderPSO, RenderSRB) - Context.CommitShaderResources(RenderSRB) - Context.SetVertexBuffers(PositionsBuffer, 0, TexcoordBuffer, TexcoordDataOffset, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION", "SET_VERTEX_BUFFERS_FLAG_RESET") - Context.SetIndexBuffer(IndexBuffer, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION" ) - Context.Draw(DrawAttrs) -end - - -tex2DTestUAV = FillTextureSRB:GetVariableByName("SHADER_TYPE_COMPUTE", "g_tex2DTestUAV") - -function Dispatch() - - Context.SetPipelineState(FillTexturePSO) - - for Mip = 0, TestTexture.MipLevels-1 do - local NumGroupsX = math.floor( (bit32.rshift(TestTexture.Width, Mip) + ThreadGroupSizeX - 1) / ThreadGroupSizeX ) - local NumGroupsY = math.floor( (bit32.rshift(TestTexture.Height, Mip) + ThreadGroupSizeX - 1) / ThreadGroupSizeY ) - tex2DTestUAV:Set(UAVs[Mip]) - - Context.CommitShaderResources(FillTextureSRB, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION" ) - - Context.DispatchCompute(NumGroupsX, NumGroupsY) - end - - Context.SetPipelineState(UpdateDispatchArgsBuffPSO) - Context.TransitionShaderResources(UpdateDispatchArgsBuffPSO, UpdateDispatchArgsBuffSRB) - Context.CommitShaderResources(UpdateDispatchArgsBuffSRB) - Context.DispatchCompute(1) - - Context.SetPipelineState(UpdateDrawArgsBuffPSO) - Context.CommitShaderResources(UpdateDrawArgsBuffSRB, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - Context.DispatchCompute(IndirectDispatchArgsBuffer, 16, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - - Context.SetPipelineState(UpdateIndBuffPSO) - Context.TransitionShaderResources(UpdateIndBuffPSO, UpdateIndBuffSRB) - Context.CommitShaderResources(UpdateIndBuffSRB) - Context.DispatchCompute(1) - - Context.SetPipelineState(UpdateVertBuffPSO) - Context.CommitShaderResources(UpdateVertBuffSRB, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - Context.DispatchCompute(2) - - return Draw() -end - -function Render() - return Dispatch() -end diff --git a/Tests/TestApp/assets/TestRenderScripts.lua b/Tests/TestApp/assets/TestRenderScripts.lua deleted file mode 100644 index bce79ae..0000000 --- a/Tests/TestApp/assets/TestRenderScripts.lua +++ /dev/null @@ -1,220 +0,0 @@ --- Test render scripts - -TestSampler = Sampler.Create{ - Name = "Test Sampler", - MinFilter = "FILTER_TYPE_POINT", - MagFilter = "FILTER_TYPE_LINEAR", - MipFilter = "FILTER_TYPE_POINT", - AddressU = "TEXTURE_ADDRESS_WRAP", - AddressV = "TEXTURE_ADDRESS_MIRROR", - AddressW = "TEXTURE_ADDRESS_CLAMP", - MipLODBias = 2, - MinLOD = 0.4, - MaxLOD = 10, - MaxAnisotropy = 6, - ComparisonFunc = "COMPARISON_FUNC_GREATER_EQUAL", - BorderColor = {r = 0.0, g = 0.0, b=0.0, a=1.0}, -} - -ErrorTestSampler = Sampler.Create -{ - SomeUndefinedMember = Undefined, - MinFilter = Undefined2 -} - -function GetShaderPath( ShaderName, ShaderExt ) - - local ProcessedShaderPath = "" - if Constants.DeviceType == "D3D11" or Constants.DeviceType == "D3D12" then - ProcessedShaderPath = "Shaders\\" .. ShaderName .. "DX." .. ShaderExt - else - ProcessedShaderPath = "Shaders\\" .. ShaderName .. "GL." .. ShaderExt - end - - return ProcessedShaderPath -end - -MinimalVS = Shader.Create{ - FilePath = GetShaderPath("minimal", "vsh"), - UseCombinedTextureSamplers = true, - Desc = { - ShaderType = "SHADER_TYPE_VERTEX", - Name = "MinimalVS" - } -} - -MinimalInstVS = Shader.Create{ - FilePath = GetShaderPath("minimalInst", "vsh"), - UseCombinedTextureSamplers = true, - Desc = { - ShaderType = "SHADER_TYPE_VERTEX", - Name = "MinimalInstVS" - } -} - -UniformBufferPS = Shader.Create{ - FilePath = GetShaderPath("UniformBuffer", "psh"), - UseCombinedTextureSamplers = true, - Desc = { - ShaderType = "SHADER_TYPE_PIXEL", - Name = "UniformBufferPS" - } -} - -PSO = PipelineState.Create -{ - Name = "Pipeline State", - GraphicsPipeline = - { - DepthStencilDesc = - { - DepthEnable = false - }, - RasterizerDesc = - { - CullMode = "CULL_MODE_NONE" - }, - BlendDesc = - { - IndependentBlendEnable = false, - RenderTargets = { {BlendEnable = false} } - }, - InputLayout = - { - { InputIndex = 0, BufferSlot = 0, NumComponents = 3, ValueType = "VT_FLOAT32", IsNormalized = false}, - { InputIndex = 1, BufferSlot = 1, NumComponents = 4, ValueType = "VT_UINT8", IsNormalized = true}, - }, - PrimitiveTopology = "PRIMITIVE_TOPOLOGY_TRIANGLE_LIST", - pVS = MinimalVS, - pPS = UniformBufferPS, - RTVFormats = extBackBufferFormat, - DSVFormat = extDepthBufferFormat - }, - SRBAllocationGranularity = 16 -} - -SRB = PSO:CreateShaderResourceBinding() -SRB1 = PSO:CreateShaderResourceBinding() -SRB2 = PSO:CreateShaderResourceBinding() -SRB3 = PSO:CreateShaderResourceBinding() - -PSOInst = PipelineState.Create -{ - Name = "Pipeline State", - GraphicsPipeline = - { - DepthStencilDesc = - { - DepthEnable = false - }, - RasterizerDesc = - { - CullMode = "CULL_MODE_NONE" - }, - BlendDesc = - { - IndependentBlendEnable = false, - RenderTargets = { {BlendEnable = false} } - }, - InputLayout = - { - { InputIndex = 0, BufferSlot = 0, NumComponents = 3, ValueType = "VT_FLOAT32", IsNormalized = false, Stride = 4*3}, - { InputIndex = 1, BufferSlot = 1, NumComponents = 4, ValueType = "VT_UINT8", IsNormalized = true, Stride = 4*1}, - { InputIndex = 2, BufferSlot = 2, NumComponents = 2, ValueType = "VT_FLOAT32", IsNormalized = false, Frequency = "FREQUENCY_PER_INSTANCE"}, - }, - PrimitiveTopology = "PRIMITIVE_TOPOLOGY_TRIANGLE_LIST", - pVS = MinimalInstVS, - pPS = UniformBufferPS, - RTVFormats = extBackBufferFormat, - DSVFormat = extDepthBufferFormat - } -} -SRBInst = PSOInst:CreateShaderResourceBinding() - -VertexBuffer1 = Buffer.Create( - { BindFlags = "BIND_VERTEX_BUFFER" }, - "VT_FLOAT32", - {-1.0, 3.0, 0.0, - 3.0, -1.0, 0.0, - -1.0, -1.0, 0.0} -) - -VertexBuffer2 = Buffer.Create( - { BindFlags = "BIND_VERTEX_BUFFER" }, - "VT_FLOAT32", - {0.0, 0.0, 0.0, - 0.0,-0.2, 0.0, - 0.2, 0.0, 0.0} -) - -ColorsBuffer1 = Buffer.Create( - { BindFlags = "BIND_VERTEX_BUFFER" }, - "VT_UINT8", - {127, 0, 0, 0, - 0, 127, 0, 0, - 0, 0, 127, 0} -) - -ColorsBuffer2 = Buffer.Create( - { BindFlags = "BIND_VERTEX_BUFFER" }, - "VT_UINT8", - {255, 255, 0, 0, - 0, 255, 255, 0, - 255, 0, 255, 0 } -) - -InstanceBuffer = Buffer.Create( - { BindFlags = "BIND_VERTEX_BUFFER" }, - "VT_FLOAT32", - {-0.3, 0.0, 0.0, 0.0, 0.3, -0.3} -) - -IndexBuffer = Buffer.Create( - { BindFlags = "BIND_INDEX_BUFFER" }, - "VT_UINT32", - {0,1,2} -) - -UnfiformBuffer1 = Buffer.Create( - { Name = "Test Uniform Buffer", - uiSizeInBytes = 16, - BindFlags = "BIND_UNIFORM_BUFFER", Usage = "USAGE_DYNAMIC", CPUAccessFlags = "CPU_ACCESS_WRITE" } -) - -ResMapping = ResourceMapping.Create{ - {Name = "cbTestBlock", pObject = UnfiformBuffer1} -} - - -function AddConstBufferToMapping(Name, NewConstBuff) - ResMapping[Name] = NewConstBuff -end - -function BindShaderResources() - PSO:BindStaticResources({"SHADER_TYPE_VERTEX", "SHADER_TYPE_PIXEL"}, ResMapping) - PSOInst:BindStaticResources({"SHADER_TYPE_VERTEX", "SHADER_TYPE_PIXEL"}, ResMapping) - SRB:InitializeStaticResources(PSO) - SRBInst:InitializeStaticResources() -end - - -function DrawTris(DrawAttrs) - - if( DrawAttrs.NumInstances == 1 ) then - Context.SetPipelineState(PSO) - Context.SetVertexBuffers(0, VertexBuffer1, 0, ColorsBuffer1, 0, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION", "SET_VERTEX_BUFFERS_FLAG_RESET") - SRB:BindResources({"SHADER_TYPE_VERTEX", "SHADER_TYPE_PIXEL"}, ResMapping, {"BIND_SHADER_RESOURCES_KEEP_EXISTING", "BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED", "BIND_SHADER_RESOURCES_UPDATE_ALL"}) - Context.TransitionShaderResources(PSO, SRB) - Context.CommitShaderResources(SRB) - Context.Draw(DrawAttrs) - else - Context.SetPipelineState(PSOInst) - Context.SetVertexBuffers(0, VertexBuffer2, ColorsBuffer2, 0, InstanceBuffer, 0, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION", "SET_VERTEX_BUFFERS_FLAG_RESET") - Context.SetIndexBuffer(IndexBuffer, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - SRBInst:BindResources({"SHADER_TYPE_VERTEX", "SHADER_TYPE_PIXEL"}, ResMapping, {"BIND_SHADER_RESOURCES_KEEP_EXISTING", "BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED", "BIND_SHADER_RESOURCES_UPDATE_MUTABLE", "BIND_SHADER_RESOURCES_UPDATE_DYNAMIC"}) - Context.TransitionShaderResources(PSOInst, SRBInst) - Context.CommitShaderResources(SRBInst) - Context.Draw(DrawAttrs) - end - -end diff --git a/Tests/TestApp/assets/TestRenderTargets.lua b/Tests/TestApp/assets/TestRenderTargets.lua deleted file mode 100644 index 1a7b163..0000000 --- a/Tests/TestApp/assets/TestRenderTargets.lua +++ /dev/null @@ -1,442 +0,0 @@ --- Render target test script - - -RTWidth = 256 -RTHeight = 256 -TestTexture0 = Texture.Create{ - Type = "RESOURCE_DIM_TEX_2D", Width = RTWidth, Height = RTHeight, - Format = "TEX_FORMAT_RGBA8_UNORM", - MipLevels = 1, - SampleCount = 1, - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_SHADER_RESOURCE", "BIND_RENDER_TARGET"}, - ClearValue = {Color = {r=0.25, g=0.0, b=0.0, a=0.0}} -} - -TestTexture1 = Texture.Create{ - Type = "RESOURCE_DIM_TEX_2D", Width = RTWidth*2, Height = RTHeight*2, - Format = "TEX_FORMAT_RGBA32_FLOAT", -- Note that GLES3.1 only requires signed or unsigned normalized - -- fixed-point or signed or unsigned integer render target formats - MipLevels = 8, - SampleCount = 1, - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_SHADER_RESOURCE", "BIND_RENDER_TARGET"}, - ClearValue = {Color = {r=0.0, g=0.5, b=0.0, a=0.0}} -} - -TestTexture2 = Texture.Create{ - Type = "RESOURCE_DIM_TEX_2D", Width = RTWidth, Height = RTHeight, - Format = "TEX_FORMAT_RGBA16_FLOAT", -- Note that GLES3.1 only requires signed or unsigned normalized - -- fixed-point or signed or unsigned integer render target formats - MipLevels = 1, - SampleCount = 1, - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_SHADER_RESOURCE", "BIND_RENDER_TARGET"}, - ClearValue = {Color = {r=0.0, g=0.0, b=0.75, a=0.0}} -} - -TestDepthTexture = Texture.Create{ - Type = "RESOURCE_DIM_TEX_2D", Width = RTWidth, Height = RTHeight, - Format = "TEX_FORMAT_D32_FLOAT", - MipLevels = 1, - SampleCount = 1, - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_SHADER_RESOURCE", "BIND_DEPTH_STENCIL"}, - ClearValue = {DepthStencil = {Depth=1.0}} -} - -IsGLES = Constants.DeviceType == "OpenGLES" - -TexDesc = { - Type = "RESOURCE_DIM_TEX_2D", Width = RTWidth, Height = RTHeight, - Format = "TEX_FORMAT_RGBA8_UNORM", - MipLevels = 7, - Usage = "USAGE_DEFAULT", - BindFlags = {"BIND_SHADER_RESOURCE", "BIND_RENDER_TARGET"}, - ClearValue = {Color = {r=0.25, g=0.5, b=0.75, a=1.0}} -} -Tex2D = {Texture.Create(TexDesc), Texture.Create(TexDesc), Texture.Create(TexDesc) } - -TexDesc.BindFlags = {"BIND_SHADER_RESOURCE", "BIND_DEPTH_STENCIL"} -TexDesc.Format = "TEX_FORMAT_D32_FLOAT" -TexDS_2D = Texture.Create(TexDesc) - -TexDesc.BindFlags = {"BIND_SHADER_RESOURCE", "BIND_RENDER_TARGET"} -TexDesc.Format = "TEX_FORMAT_RGBA8_UNORM" -TexDesc.Type = "RESOURCE_DIM_TEX_2D_ARRAY" -TexDesc.ArraySize = 16 -Tex2DArr = {Texture.Create(TexDesc), Texture.Create(TexDesc), Texture.Create(TexDesc) } - -TexDesc.BindFlags = {"BIND_SHADER_RESOURCE", "BIND_DEPTH_STENCIL"} -TexDesc.Format = "TEX_FORMAT_D32_FLOAT" -TexDS_2DArr = Texture.Create(TexDesc) - -if not IsGLES then - TexDesc.BindFlags = {"BIND_SHADER_RESOURCE", "BIND_RENDER_TARGET"} - TexDesc.Format = "TEX_FORMAT_RGBA8_UNORM" - TexDesc.Type = "RESOURCE_DIM_TEX_3D" - TexDesc.Depth = 16 - Tex3D= {Texture.Create(TexDesc), Texture.Create(TexDesc), Texture.Create(TexDesc) } - - -- Texture 3D cannot be used as depth stencil (at least in D3D11) -end - -Tex2D_DefRTV = {} -Tex2D_Mip1RTV = {} -TexDS_2D_DefDSV = {} -TexDS_2D_Mip1DSV = {} - -Tex2DArr_DefRTV = {} -Tex2DArr_Mip1RTV = {} -Tex2DArr_Slice2RTV = {} -Tex2DArr_Slice2Mip2RTV = {} - -TexDS_2DArr_DefDSV = {} -TexDS_2DArr_Mip1DSV = {} -TexDS_2DArr_Slice2DSV = {} -TexDS_2DArr_Slice2Mip2DSV = {} - -if not IsGLES then - Tex3D_DefRTV = {} - Tex3D_Mip1RTV = {} - Tex3D_Slice2RTV = {} - Tex3D_Slice2Mip2RTV = {} -end - -for i = 1,3 do - Tex2D_DefRTV[i] = Tex2D[i]:GetDefaultView("TEXTURE_VIEW_RENDER_TARGET") - Tex2DArr_DefRTV[i] = Tex2DArr[i]:GetDefaultView("TEXTURE_VIEW_RENDER_TARGET") - - Tex2D_Mip1RTV[i] = Tex2D[i]:CreateView{ViewType = "TEXTURE_VIEW_RENDER_TARGET", MostDetailedMip = 1} - Tex2DArr_Mip1RTV[i] = Tex2DArr[i]:CreateView{ViewType = "TEXTURE_VIEW_RENDER_TARGET", MostDetailedMip = 1} - Tex2DArr_Slice2RTV[i] = Tex2DArr[i]:CreateView{ViewType = "TEXTURE_VIEW_RENDER_TARGET", FirstArraySlice = 2, NumArraySlices = 1} - Tex2DArr_Slice2Mip2RTV[i] = Tex2DArr[i]:CreateView{ViewType = "TEXTURE_VIEW_RENDER_TARGET", FirstArraySlice = 2, MostDetailedMip = 2, NumArraySlices = 1} - - if not IsGLES then - Tex3D_DefRTV[i] = Tex3D[i]:GetDefaultView("TEXTURE_VIEW_RENDER_TARGET") - Tex3D_Mip1RTV[i] = Tex3D[i]:CreateView{ViewType = "TEXTURE_VIEW_RENDER_TARGET", MostDetailedMip = 1} - Tex3D_Slice2RTV[i] = Tex3D[i]:CreateView{ViewType = "TEXTURE_VIEW_RENDER_TARGET", FirstDepthSlice = 2, NumDepthSlices = 1} - Tex3D_Slice2Mip2RTV[i] = Tex3D[i]:CreateView{ViewType = "TEXTURE_VIEW_RENDER_TARGET", FirstDepthSlice = 2, MostDetailedMip = 2, NumDepthSlices = 1} - end -end - - -Tex2D_DefDSV = TexDS_2D:GetDefaultView("TEXTURE_VIEW_DEPTH_STENCIL") -Tex2DArr_DefDSV = TexDS_2DArr:GetDefaultView("TEXTURE_VIEW_DEPTH_STENCIL") - - -Tex2D_Mip1DSV = TexDS_2D:CreateView{ViewType = "TEXTURE_VIEW_DEPTH_STENCIL", MostDetailedMip = 1} -Tex2DArr_Mip1DSV = TexDS_2DArr:CreateView{ViewType = "TEXTURE_VIEW_DEPTH_STENCIL", MostDetailedMip = 1} -Tex2DArr_Slice2DSV = TexDS_2DArr:CreateView{ViewType = "TEXTURE_VIEW_DEPTH_STENCIL", FirstArraySlice = 2, NumArraySlices = 1} -Tex2DArr_Slice2Mip2DSV = TexDS_2DArr:CreateView{ViewType = "TEXTURE_VIEW_DEPTH_STENCIL", FirstArraySlice = 2, MostDetailedMip = 2, NumArraySlices = 1} - -function SetRTsHelper(RTVs, DSV) - Context.SetRenderTargets(RTVs[1], "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - Context.SetRenderTargets(RTVs[1], RTVs[2], "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - Context.SetRenderTargets(RTVs[1], RTVs[2], RTVs[3], "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - if DSV then - Context.SetRenderTargets(RTVs[1], RTVs[2], RTVs[3], DSV, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - end - Context.ClearRenderTarget(RTVs[1], 0.25, 0.5, 0.75, 1.0, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - Context.ClearRenderTarget(RTVs[2], 0.25, 0.5, 0.75, 1.0, "RESOURCE_STATE_TRANSITION_MODE_VERIFY") - Context.ClearRenderTarget(RTVs[3], 0.25, 0.5, 0.75, 1.0, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - if DSV then - Context.ClearDepthStencil(DSV, "CLEAR_DEPTH_FLAG", 1.0, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - Context.SetRenderTargets(RTVs[1], RTVs[2], DSV, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - Context.SetRenderTargets(RTVs[1], DSV, "RESOURCE_STATE_TRANSITION_MODE_VERIFY") - Context.SetRenderTargets(DSV, "RESOURCE_STATE_TRANSITION_MODE_VERIFY") - end -end - -function TestSetRenderTargets() - SetRTsHelper(Tex2D_DefRTV, Tex2D_DefDSV) - if not IsGLES then - SetRTsHelper(Tex2DArr_DefRTV, Tex2DArr_DefDSV) -- no glFramebufferTexture in ES3.1 - SetRTsHelper(Tex3D_DefRTV) -- no glFramebufferTexture in ES3.1 - end - - SetRTsHelper(Tex2D_Mip1RTV, Tex2D_Mip1DSV) - if not IsGLES then - SetRTsHelper(Tex2DArr_Mip1RTV, Tex2DArr_Mip1DSV) -- no glFramebufferTexture in ES3.1 - SetRTsHelper(Tex3D_Mip1RTV) -- no glFramebufferTexture in ES3.1 - end - - SetRTsHelper(Tex2DArr_Slice2RTV, Tex2DArr_Slice2DSV) - if not IsGLES then - SetRTsHelper(Tex3D_Slice2RTV) -- no glFramebufferTexture3D in ES3.1 - end - - SetRTsHelper(Tex2DArr_Slice2Mip2RTV, Tex2DArr_Slice2Mip2DSV) - if not IsGLES then - SetRTsHelper(Tex3D_Slice2Mip2RTV) -- no glFramebufferTexture3D in ES3.1 - end - - -- It is not allowed to mix different resources as render targets. In particular, we cannot - -- bind Texture2D & Texture3D at the same time - if not IsGLES then - Context.SetRenderTargets(Tex2D_DefRTV[3], Tex2DArr_Slice2RTV[1], Tex2DArr_Slice2DSV, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - Context.SetRenderTargets(Tex2DArr_Slice2Mip2RTV[1], Tex2DArr_Slice2Mip2DSV, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - end -end - - -Positions = { 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 1.0, 0.0, 0.0, - 1.0, 1.0, 0.0 } -FullQuad = {} -for v = 0,3 do - FullQuad[v*3+1] = Positions[v*3+1]*2 - 1 - FullQuad[v*3+2] = Positions[v*3+2]*2 - 1 - FullQuad[v*3+3] = 0 -end - -FullQuadBuffer = Buffer.Create( - { BindFlags = "BIND_VERTEX_BUFFER" }, - "VT_FLOAT32", - FullQuad -) - -ScaledQuad = {} -for v = 0,3 do - ScaledQuad[v*3+1] = Positions[v*3+1]*XExt + MinX - ScaledQuad[v*3+2] = Positions[v*3+2]*YExt + MinY - ScaledQuad[v*3+3] = 0 -end - -ScaledQuadBuffer = Buffer.Create( - { BindFlags = "BIND_VERTEX_BUFFER" }, - "VT_FLOAT32", - ScaledQuad -) - -TexcoordBuffer = Buffer.Create( - { BindFlags = "BIND_VERTEX_BUFFER" }, - "VT_FLOAT32", - { 0.0, 1.0, - 0.0, 0.0, - 1.0, 1.0, - 1.0, 0.0} -) - - -Level0Sampler = Sampler.Create{ - MinFilter = "FILTER_TYPE_LINEAR", - MagFilter = "FILTER_TYPE_LINEAR", - MipFilter = "FILTER_TYPE_POINT", - MaxLOD = 0 -} - -Level1Sampler = Sampler.Create{ - MinFilter = "FILTER_TYPE_LINEAR", - MagFilter = "FILTER_TYPE_LINEAR", - MipFilter = "FILTER_TYPE_POINT", - MaxLOD = 1, - MinLOD = 1 -} - -Tex0SRV = TestTexture0:GetDefaultView("TEXTURE_VIEW_SHADER_RESOURCE") -Tex0SRV:SetSampler(Level0Sampler) -Tex0RTV = TestTexture0:GetDefaultView("TEXTURE_VIEW_RENDER_TARGET") - -Tex1SRV = TestTexture1:GetDefaultView("TEXTURE_VIEW_SHADER_RESOURCE") -Tex1SRV:SetSampler(Level1Sampler) -Tex1RTV = TestTexture1:CreateView{ - ViewType = "TEXTURE_VIEW_RENDER_TARGET", - MostDetailedMip = 1, - } - -Tex2SRV = TestTexture2:GetDefaultView("TEXTURE_VIEW_SHADER_RESOURCE") -Tex2SRV:SetSampler(Level0Sampler) -Tex2RTV = TestTexture2:GetDefaultView("TEXTURE_VIEW_RENDER_TARGET") - -ResMapping = ResourceMapping.Create{ - {Name = "g_tex2DTest0", pObject = Tex0SRV}, - {Name = "g_tex2DTest1", pObject = Tex1SRV}, - {Name = "g_tex2DTest2", pObject = Tex2SRV} -} - -TexDepthTexDSV = TestDepthTexture:GetDefaultView("TEXTURE_VIEW_DEPTH_STENCIL") - - -function GetShaderPath( ShaderName ) - - local ProcessedShaderPath = "" - if Constants.DeviceType == "D3D11" or Constants.DeviceType == "D3D12" then - ProcessedShaderPath = "Shaders\\" .. ShaderName .. "_DX.hlsl" - else - ProcessedShaderPath = "Shaders\\" .. ShaderName .. "_GL.glsl" - end - - return ProcessedShaderPath -end - - -QuadVS = Shader.Create{ - FilePath = GetShaderPath("RTTest\\QuadVS"), - UseCombinedTextureSamplers = true, - Desc = {ShaderType = "SHADER_TYPE_VERTEX"} -} - - -RenderToTexturesPS = Shader.Create{ - FilePath = GetShaderPath("RTTest\\RenderToTexturesPS"), - UseCombinedTextureSamplers = true, - Desc = {ShaderType = "SHADER_TYPE_PIXEL"} -} - -BlendTexturesPS = Shader.Create{ - FilePath = GetShaderPath("RTTest\\BlendTexturesPS"), - UseCombinedTextureSamplers = true, - Desc = - { - ShaderType = "SHADER_TYPE_PIXEL" - } -} - -RenderToTexPSO = PipelineState.Create -{ - Name = "Render to textures PSO", - GraphicsPipeline = - { - RasterizerDesc = - { - FillMode = "FILL_MODE_SOLID", - CullMode = "CULL_MODE_NONE", - ScissorEnable = true - }, - DepthStencilDesc = {DepthEnable = false}, - pVS = QuadVS, - pPS = RenderToTexturesPS, - InputLayout = - { - { InputIndex = 0, BufferSlot = 0, NumComponents = 3, ValueType = "VT_FLOAT32"}, - { InputIndex = 1, BufferSlot = 1, NumComponents = 2, ValueType = "VT_FLOAT32"} - }, - RTVFormats = {TestTexture0.Format, TestTexture1.Format}, - PrimitiveTopology = "PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP" - } -} -RenderToTexPSO:BindStaticResources({"SHADER_TYPE_VERTEX", "SHADER_TYPE_PIXEL"}, ResMapping) -RenderToTexSRB = RenderToTexPSO:CreateShaderResourceBinding(true) - -BlendTexPSO = PipelineState.Create -{ - Name = "Blend textures PSO", - ResourceLayout = - { - StaticSamplers = - { - { - ShaderStages = "SHADER_TYPE_PIXEL", - SamplerOrTextureName = "g_tex2DTest0", - Desc = - { - MinFilter = "FILTER_TYPE_LINEAR", - MagFilter = "FILTER_TYPE_LINEAR", - MipFilter = "FILTER_TYPE_POINT", - MaxLOD = 0 - } - }, - { - ShaderStages = "SHADER_TYPE_PIXEL", - SamplerOrTextureName = "g_tex2DTest2", - Desc = - { - MinFilter = "FILTER_TYPE_LINEAR", - MagFilter = "FILTER_TYPE_LINEAR", - MipFilter = "FILTER_TYPE_POINT", - MaxLOD = 0 - } - } - } - }, - GraphicsPipeline = - { - RasterizerDesc = - { - FillMode = "FILL_MODE_SOLID", - CullMode = "CULL_MODE_NONE" - }, - DepthStencilDesc = {DepthEnable = false}, - pVS = QuadVS, - pPS = BlendTexturesPS, - InputLayout = - { - { InputIndex = 0, BufferSlot = 0, NumComponents = 3, ValueType = "VT_FLOAT32"}, - { InputIndex = 1, BufferSlot = 1, NumComponents = 2, ValueType = "VT_FLOAT32"} - }, - RTVFormats = {extBackBufferFormat}, - DSVFormat = extDepthBufferFormat, - PrimitiveTopology = "PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP" - } -} -assert(BlendTexPSO.ResourceLayout.StaticSamplers[1].ShaderStages[1] == "SHADER_TYPE_PIXEL"); -assert(BlendTexPSO.ResourceLayout.StaticSamplers[1].Desc.MipFilter == "FILTER_TYPE_POINT"); -assert(BlendTexPSO.ResourceLayout.StaticSamplers[2].SamplerOrTextureName == "g_tex2DTest2"); - -BlendTexPSO:BindStaticResources({"SHADER_TYPE_VERTEX", "SHADER_TYPE_PIXEL"}, ResMapping) -BlendTexSRB = BlendTexPSO:CreateShaderResourceBinding(true) - -DrawAttrs = DrawAttribs.Create{ - NumVertices = 4, - Flags = "DRAW_FLAG_VERIFY_ALL" -} - -VP = Viewport.Create { - TopLeftX = 16, - TopLeftY = 32, - Width = RTWidth-16-8, - Height = RTHeight-32-16, - MinDepth = 0, - MaxDepth = 1 -} - -SR = ScissorRect.Create -{ - left = 32, - top = 48, - right = RTWidth-48, - bottom = RTHeight -} - - -function RenderToTextures() - Context.SetVertexBuffers(FullQuadBuffer, TexcoordBuffer, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION", "SET_VERTEX_BUFFERS_FLAG_RESET") - Context.SetPipelineState(RenderToTexPSO) - Context.TransitionShaderResources(RenderToTexPSO, RenderToTexSRB) - Context.CommitShaderResources(RenderToTexSRB) - Context.Draw(DrawAttrs) -end - -function BlendTextures() - Context.SetVertexBuffers(ScaledQuadBuffer, TexcoordBuffer, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION", "SET_VERTEX_BUFFERS_FLAG_RESET") - Context.SetPipelineState(BlendTexPSO) - Context.CommitShaderResources(BlendTexSRB, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - Context.Draw(DrawAttrs) -end - -function Render() - TestSetRenderTargets() - - Context.SetRenderTargets(Tex0RTV, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") -- To test FBO cache - Context.SetRenderTargets(Tex1RTV, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") -- To test FBO cache - Context.SetRenderTargets(TexDepthTexDSV, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") -- To test FBO cache - Context.SetRenderTargets(Tex0RTV, TexDepthTexDSV, "RESOURCE_STATE_TRANSITION_MODE_VERIFY") -- To test FBO cache - Context.SetRenderTargets(Tex1RTV, TexDepthTexDSV, "RESOURCE_STATE_TRANSITION_MODE_VERIFY") -- To test FBO cache - Context.SetRenderTargets(Tex0RTV, Tex1RTV, TexDepthTexDSV, "RESOURCE_STATE_TRANSITION_MODE_VERIFY") -- To test FBO cache - - - Context.SetRenderTargets(Tex2RTV, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - Context.ClearRenderTarget(Tex2RTV, 0, 0, 0.75, "RESOURCE_STATE_TRANSITION_MODE_VERIFY") - Context.SetRenderTargets(Tex0RTV, Tex1RTV, "RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - Context.ClearRenderTarget(Tex0RTV, 0.25, "RESOURCE_STATE_TRANSITION_MODE_VERIFY") - Context.ClearRenderTarget(Tex1RTV, 0.0, 0.5, "RESOURCE_STATE_TRANSITION_MODE_VERIFY") - Context.SetViewports(VP) - Context.SetScissorRects(SR) - RenderToTextures() - - Context.SetRenderTargets("RESOURCE_STATE_TRANSITION_MODE_TRANSITION") - Context.SetViewports() - BlendTextures() -end diff --git a/Tests/TestApp/assets/VPAndSRTest.lua b/Tests/TestApp/assets/VPAndSRTest.lua deleted file mode 100644 index f761dbd..0000000 --- a/Tests/TestApp/assets/VPAndSRTest.lua +++ /dev/null @@ -1,80 +0,0 @@ --- Test script file - -assert( TestGlobalVP.TopLeftX == 16.5); -assert( TestGlobalVP.TopLeftY == 24.25); -assert( TestGlobalVP.Width == 156.125); -assert( TestGlobalVP.Height == 381.625); -assert( TestGlobalVP.MinDepth == 0.25); -assert( TestGlobalVP.MaxDepth == 0.75); - -TestVP = Viewport.Create { - TopLeftX = 15.5, - TopLeftY = 17.25, - Width = 128.125, - Height = 256.625, - MinDepth = 0.125, - MaxDepth = 0.875 -} - -assert( TestVP.TopLeftX == 15.5 ) -assert( TestVP.TopLeftY == 17.25) -assert( TestVP.Width == 128.125) -assert( TestVP.Height == 256.625) -assert( TestVP.MinDepth == 0.125) -assert( TestVP.MaxDepth == 0.875) - -TestVP.TopLeftX = 115.5 -TestVP.TopLeftY = 117.25 -TestVP.Width = 1128.125 -TestVP.Height = 1256.625 -TestVP.MinDepth = 0.25 -TestVP.MaxDepth = 0.75 - -assert( TestVP.TopLeftX == 115.5 ) -assert( TestVP.TopLeftY == 117.25) -assert( TestVP.Width == 1128.125) -assert( TestVP.Height == 1256.625) -assert( TestVP.MinDepth == 0.25) -assert( TestVP.MaxDepth == 0.75) - -function SetViewports() - Context.SetViewports(TestVP) - Context.SetViewports(TestVP, TestGlobalVP) - Context.SetViewports(TestVP, 1024, 768) - Context.SetViewports(TestVP, TestGlobalVP, 1024, 768) - Context.SetViewports() -end - - -assert( TestGlobalSR.left == 10); -assert( TestGlobalSR.top == 30); -assert( TestGlobalSR.right == 200); -assert( TestGlobalSR.bottom == 300); - -TestSR = ScissorRect.Create { - left = 50, - top = 60, - right = 400, - bottom = 500 -} - -assert( TestSR.left == 50 ) -assert( TestSR.top == 60 ) -assert( TestSR.right == 400 ) -assert( TestSR.bottom == 500 ) - -TestSR.left = 55 -TestSR.top = 65 -TestSR.right = 405 -TestSR.bottom = 505 -assert( TestSR.left == 55 ) -assert( TestSR.top == 65 ) -assert( TestSR.right == 405 ) -assert( TestSR.bottom == 505 ) - -function SetScissorRects() - Context.SetScissorRects(TestSR) - Context.SetScissorRects(TestSR, TestGlobalSR) - Context.SetScissorRects(TestSR, 1024, 768) - Context.SetScissorRects(TestSR, TestGlobalSR, 1280, 1024) -end diff --git a/Tests/TestApp/include/TestApp.h b/Tests/TestApp/include/TestApp.h deleted file mode 100644 index b866b40..0000000 --- a/Tests/TestApp/include/TestApp.h +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include <vector> - -#include "NativeAppBase.h" -#include "RefCntAutoPtr.h" -#include "RenderDevice.h" -#include "DeviceContext.h" -#include "SwapChain.h" - -#include "TestDrawCommands.h" -#include "TestBufferAccess.h" -#include "TestTexturing.h" -#include "TestComputeShaders.h" -#include "Timer.h" -#include "TestRenderTarget.h" -#include "TestGeometryShader.h" -#include "TestTessellation.h" - -namespace Diligent -{ - -class TestApp : public NativeAppBase -{ -public: - TestApp(); - ~TestApp(); - virtual void ProcessCommandLine(const char *CmdLine)override final; - virtual const char* GetAppTitle()const override final { return m_AppTitle.c_str(); } - virtual void Update(double CurrTime, double ElapsedTime)override final; - virtual void WindowResize(int width, int height)override final; - virtual void Render()override; - virtual void Present()override; - -protected: - void InitializeDiligentEngine( -#if PLATFORM_LINUX - void *display, -#endif - void *NativeWindowHandle - ); - void InitializeRenderers(); - - DeviceType m_DeviceType = DeviceType::Undefined; - RefCntAutoPtr<IRenderDevice> m_pDevice; - RefCntAutoPtr<IDeviceContext> m_pImmediateContext; - std::vector<RefCntAutoPtr<IDeviceContext> > m_pDeferredContexts; - RefCntAutoPtr<ISwapChain> m_pSwapChain; - std::string m_AppTitle; - - std::unique_ptr<TestDrawCommands> m_pTestDrawCommands; - std::unique_ptr<TestBufferAccess> m_pTestBufferAccess; - std::unique_ptr<TestTexturing> m_pTestTexturing[16]; - std::unique_ptr<TestComputeShaders> m_pTestCS; - std::unique_ptr<TestRenderTarget> m_pTestRT; - TestGeometryShader m_TestGS; - TestTessellation m_TestTessellation; - - RefCntAutoPtr<IBuffer> m_pUniformBuff2, m_pUniformBuff3, m_pUniformBuff4; - RefCntAutoPtr<ITexture> m_pTestTex; - RefCntAutoPtr<IFence> m_pFence; - Uint64 m_NextFenceValue = 1; - - double m_CurrTime = 0; -}; - -} diff --git a/Tests/TestApp/include/TestBufferAccess.h b/Tests/TestApp/include/TestBufferAccess.h deleted file mode 100644 index 2fb27e1..0000000 --- a/Tests/TestApp/include/TestBufferAccess.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "UnitTestBase.h" - -class TestBufferAccess : public UnitTestBase -{ -public: - static const int TriGridSize = 16; - TestBufferAccess(); - - void Init( Diligent::IRenderDevice *pDevice, Diligent::IDeviceContext *pContext, Diligent::ISwapChain *pSwapChain, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent ); - void Draw(float fTime); - -private: - void Define2DVertex(std::vector<float> &VertexData, float fX, float fY, float fR, float fG, float fB); - - Diligent::RefCntAutoPtr<Diligent::IRenderDevice> m_pRenderDevice; - Diligent::RefCntAutoPtr<Diligent::IDeviceContext> m_pDeviceContext; - - static const int NumRows = 5; - static const int NumInstances = 3; - - Diligent::RefCntAutoPtr<Diligent::IPipelineState> m_pPSO; - Diligent::RefCntAutoPtr<Diligent::IBuffer> m_pVertexBuff, m_pInstBuff[7]; - float m_fXExtent, m_fYExtent; -}; diff --git a/Tests/TestApp/include/TestComputeShaders.h b/Tests/TestApp/include/TestComputeShaders.h deleted file mode 100644 index 756cf55..0000000 --- a/Tests/TestApp/include/TestComputeShaders.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "UnitTestBase.h" - -class TestComputeShaders : public UnitTestBase -{ -public: - TestComputeShaders(); - - void Init(Diligent::IRenderDevice *pDevice, Diligent::IDeviceContext *pContext, Diligent::ISwapChain *pSwapChain); - void Draw(); - -private: - Diligent::RefCntAutoPtr<Diligent::IRenderDevice> m_pRenderDevice; - Diligent::RefCntAutoPtr<Diligent::IDeviceContext> m_pDeviceContext; -}; diff --git a/Tests/TestApp/include/TestCopyTexData.h b/Tests/TestApp/include/TestCopyTexData.h deleted file mode 100644 index 949132f..0000000 --- a/Tests/TestApp/include/TestCopyTexData.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "UnitTestBase.h" - -class TestCopyTexData : public UnitTestBase -{ -public: - TestCopyTexData(Diligent::IRenderDevice *pDevice, Diligent::IDeviceContext *pContext); - -private: - Diligent::RefCntAutoPtr<Diligent::IRenderDevice> m_pDevice; - Diligent::RefCntAutoPtr<Diligent::IDeviceContext> m_pContext; - void Test2DTexture( Diligent::TEXTURE_FORMAT Format ); - void Test2DTexArray( Diligent::TEXTURE_FORMAT Format ); - void Test3DTexture( Diligent::TEXTURE_FORMAT Format ); -}; diff --git a/Tests/TestApp/include/TestDrawCommands.h b/Tests/TestApp/include/TestDrawCommands.h deleted file mode 100644 index 83aa099..0000000 --- a/Tests/TestApp/include/TestDrawCommands.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "UnitTestBase.h" - -class TestDrawCommands : public UnitTestBase -{ -public: - TestDrawCommands() : UnitTestBase("Draw commands test"){} - - static const int TriGridSize = 16; - - void Init(Diligent::IRenderDevice *pDevice, Diligent::IDeviceContext *pDeviceContext, Diligent::ISwapChain *pSwapChain, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent); - void Draw(); - -private: - void Define2DVertex(std::vector<float> &VertexData, float fX, float fY, float fR, float fG, float fB); - - Diligent::RefCntAutoPtr<Diligent::IRenderDevice> m_pRenderDevice; - Diligent::RefCntAutoPtr<Diligent::IDeviceContext> m_pDeviceContext; - - Diligent::RefCntAutoPtr<Diligent::IPipelineState> m_pPSO, m_pPSO_2xStride, m_pPSOInst; - Diligent::RefCntAutoPtr<Diligent::IBuffer> m_pVertexBuff, m_pVertexBuff2, m_pIndexBuff, m_pInstanceData, m_pIndirectDrawArgs, m_pIndexedIndirectDrawArgs; - Diligent::RefCntAutoPtr<Diligent::IResourceMapping> m_pResMapping; - Diligent::RefCntAutoPtr<Diligent::IShaderResourceBinding> m_pSRB, m_pSRBInst; -}; diff --git a/Tests/TestApp/include/TestGeometryShader.h b/Tests/TestApp/include/TestGeometryShader.h deleted file mode 100644 index 229fa6b..0000000 --- a/Tests/TestApp/include/TestGeometryShader.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "UnitTestBase.h" - -class TestGeometryShader : public UnitTestBase -{ -public: - TestGeometryShader() : UnitTestBase("Test Geometry Shaders"){} - - void Init(Diligent::IRenderDevice *pDevice, Diligent::IDeviceContext *pDeviceContext, Diligent::ISwapChain *pSwapChain); - void Draw(); - -private: - Diligent::RefCntAutoPtr<Diligent::IDeviceContext> m_pDeviceContext; - Diligent::RefCntAutoPtr<Diligent::IPipelineState> m_pPSO; -}; diff --git a/Tests/TestApp/include/TestRenderTarget.h b/Tests/TestApp/include/TestRenderTarget.h deleted file mode 100644 index 0468f00..0000000 --- a/Tests/TestApp/include/TestRenderTarget.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "UnitTestBase.h" - -class TestRenderTarget : public UnitTestBase -{ -public: - TestRenderTarget(); - - void Init(Diligent::IRenderDevice* pDevice, Diligent::IDeviceContext* pDeviceContext, Diligent::ISwapChain* pSwapChain, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent); - void Draw(); - -private: - - Diligent::RefCntAutoPtr<Diligent::IRenderDevice> m_pRenderDevice; - Diligent::RefCntAutoPtr<Diligent::IDeviceContext> m_pDeviceContext; -}; diff --git a/Tests/TestApp/include/TestTessellation.h b/Tests/TestApp/include/TestTessellation.h deleted file mode 100644 index b3e135d..0000000 --- a/Tests/TestApp/include/TestTessellation.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "UnitTestBase.h" - -class TestTessellation : public UnitTestBase -{ -public: - TestTessellation() : UnitTestBase("Tessellation test") {} - void Init(Diligent::IRenderDevice *pDevice, Diligent::IDeviceContext *pDeviceContext, Diligent::ISwapChain *pSwapChain); - void Draw(); - -private: - Diligent::RefCntAutoPtr<Diligent::IDeviceContext> m_pDeviceContext; - Diligent::RefCntAutoPtr<Diligent::IPipelineState> m_pQuadPSO, m_pTriPSO; -}; diff --git a/Tests/TestApp/include/TestTexturing.h b/Tests/TestApp/include/TestTexturing.h deleted file mode 100644 index c4e6500..0000000 --- a/Tests/TestApp/include/TestTexturing.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "UnitTestBase.h" - -class TestTexturing : public UnitTestBase -{ -public: - TestTexturing(); - - void Init(Diligent::IRenderDevice *pDevice, Diligent::IDeviceContext *pDeviceContext, Diligent::ISwapChain *pSwapChain, Diligent::TEXTURE_FORMAT TexFormat, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent); - void Draw(); - static void GenerateTextureData(Diligent::IRenderDevice *pRenderDevice, std::vector<Diligent::Uint8> &Data, std::vector<Diligent::TextureSubResData> &SubResouces, const Diligent::TextureDesc &TexDesc, const float *ColorOffset = nullptr); - -private: - Diligent::RefCntAutoPtr<Diligent::IRenderDevice> m_pRenderDevice; - Diligent::RefCntAutoPtr<Diligent::IDeviceContext> m_pDeviceContext; - - Diligent::RefCntAutoPtr<Diligent::IPipelineState> m_pPSO; - Diligent::RefCntAutoPtr<Diligent::IShaderResourceBinding> m_pSRB; - Diligent::RefCntAutoPtr<Diligent::IBuffer> m_pVertexBuff; - Diligent::RefCntAutoPtr<Diligent::ISampler> m_pSampler; - Diligent::RefCntAutoPtr<Diligent::ITexture> m_pTexture; - Diligent::RefCntAutoPtr<Diligent::IResourceMapping> m_pResourceMapping; - const Diligent::Uint32 m_iTestTexWidth; - const Diligent::Uint32 m_iTestTexHeight; - const Diligent::Uint32 m_iMipLevels; - Diligent::TEXTURE_FORMAT m_TextureFormat; -}; diff --git a/Tests/TestApp/include/TestVPAndSR.h b/Tests/TestApp/include/TestVPAndSR.h deleted file mode 100644 index 36f038f..0000000 --- a/Tests/TestApp/include/TestVPAndSR.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "UnitTestBase.h" - -class TestVPAndSR : public UnitTestBase -{ -public: - TestVPAndSR(Diligent::IRenderDevice *pDevice, Diligent::IDeviceContext *pContext); - -private: - Diligent::RefCntAutoPtr<Diligent::IRenderDevice> m_pRenderDevice; - Diligent::RefCntAutoPtr<Diligent::IDeviceContext> m_pDeviceContext; -}; diff --git a/Tests/TestApp/include/UnitTestBase.h b/Tests/TestApp/include/UnitTestBase.h deleted file mode 100644 index 8a0ed7d..0000000 --- a/Tests/TestApp/include/UnitTestBase.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include <string> -#include "UnitTestBase.h" - -class UnitTestBase -{ -public: - enum class TestResult - { - Unknown = 0, - Skipped, - Failed, - Succeeded - }; - UnitTestBase(const char *Name); - ~UnitTestBase(); - void SetStatus(TestResult result, const char *info ="") - { - m_TestResult = result; - m_TestResultInfo = info != nullptr ? info : ""; - } - -protected: - std::string m_TestName; - TestResult m_TestResult = TestResult::Unknown; - std::string m_TestResultInfo; - int m_TestNum = 0; - static int m_TotalTests; - static size_t m_MaxNameLen; -}; diff --git a/Tests/TestApp/include/pch.h b/Tests/TestApp/include/pch.h deleted file mode 100644 index 070c9a7..0000000 --- a/Tests/TestApp/include/pch.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include <list> -#include <algorithm> -#include <cassert> -#include <memory> -#include <chrono> -#include <vector> - -#include "PlatformDefinitions.h" - -#include "BasicTypes.h" - -#include "RefCntAutoPtr.h" -#include "DebugUtilities.h" -#include "EngineFactory.h" -#include "RenderDevice.h" -#include "DeviceContext.h" -#include "SwapChain.h" - diff --git a/Tests/TestApp/src/Android/TestAppAndroid.cpp b/Tests/TestApp/src/Android/TestAppAndroid.cpp deleted file mode 100644 index 0563cab..0000000 --- a/Tests/TestApp/src/Android/TestAppAndroid.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. -* -* In no event and under no legal theory, whether in tort (including negligence), -* contract, or otherwise, unless required by applicable law (such as deliberate -* and grossly negligent acts) or agreed to in writing, shall any Contributor be -* liable for any damages, including any direct, indirect, special, incidental, -* or consequential damages of any character arising as a result of this License or -* out of the use or inability to use the software (including but not limited to damages -* for loss of goodwill, work stoppage, computer failure or malfunction, or any and -* all other commercial damages or losses), even if such Contributor has been advised -* of the possibility of such damages. -*/ - -#include "AndroidFileSystem.h" -#include "EngineFactoryOpenGL.h" -#include "TestApp.h" -#include "RenderDeviceGLES.h" - -namespace Diligent -{ - -class TestAppAndroid final : public TestApp -{ -public: - TestAppAndroid() - { - m_DeviceType = DeviceType::OpenGLES; - } - - virtual void Initialize()override final - { - GetEngineFactoryOpenGL()->InitAndroidFileSystem(app_->activity, native_activity_class_name_.c_str()); - AndroidFileSystem::Init(app_->activity, native_activity_class_name_.c_str()); - TestApp::Initialize(); - InitializeDiligentEngine(app_->window); - m_RenderDeviceGLES = RefCntAutoPtr<IRenderDeviceGLES>(m_pDevice, IID_RenderDeviceGLES); - InitializeRenderers(); - } - - virtual int Resume(ANativeWindow* window)override final - { - return m_RenderDeviceGLES->Resume(window); - } - - virtual void TermDisplay()override final - { - // Tear down the EGL context currently associated with the display. - m_RenderDeviceGLES->Suspend(); - } - - virtual void TrimMemory()override final - { - LOGI( "Trimming memory" ); - m_RenderDeviceGLES->Invalidate(); - } - -private: - RefCntAutoPtr<IRenderDeviceGLES> m_RenderDeviceGLES; -}; - -NativeAppBase* CreateApplication() -{ - return new TestAppAndroid; -} - -} diff --git a/Tests/TestApp/src/CMakeLists.txt b/Tests/TestApp/src/CMakeLists.txt deleted file mode 100644 index 20fb0d0..0000000 --- a/Tests/TestApp/src/CMakeLists.txt +++ /dev/null @@ -1,143 +0,0 @@ -cmake_minimum_required (VERSION 3.6) - -project(TestApp) - -file(GLOB SOURCE LIST_DIRECTORIES false Src/*.cpp) -#set(SOURCE -# src/TestApp.cpp -#) - -set(INCLUDE - include/TestApp.h -) - -set(SHADERS) - -set(ASSETS) - -set(ALL_ASSETS ${ASSETS} ${SHADERS}) -add_target_platform_app(TestApp "${SOURCE}" "${INCLUDE}" "${ALL_ASSETS}") - -if(PLATFORM_WIN32) - set(WIN32_SOURCE src/Win32/TestAppWin32.cpp) - target_sources(TestApp PRIVATE ${WIN32_SOURCE}) - source_group("src\\Win32" FILES ${WIN32_SOURCE}) - - set_target_properties(TestApp PROPERTIES - VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets" - ) - copy_required_dlls(TestApp) - -elseif(PLATFORM_UNIVERSAL_WINDOWS) - - set(UWP_SOURCE - src/UWP/TestAppUWP.cpp - ) - target_sources(TestApp PRIVATE ${UWP_SOURCE}) - source_group("src\\UWP" FILES ${UWP_SOURCE}) - target_include_directories(${TestApp} PRIVATE src/UWP) - -elseif(PLATFORM_ANDROID) - set(ANDROID_SOURCE - src/Android/TestAppAndroid.cpp - ) - target_sources(TestApp PRIVATE ${ANDROID_SOURCE}) - source_group("src\\Android" FILES ${ANDROID_SOURCE}) -elseif(PLATFORM_LINUX) - set(LINUX_SOURCE - src/Linux/TestAppLinux.cpp - ) - target_sources(TestApp PRIVATE ${LINUX_SOURCE}) - source_group("src\\Linux" FILES ${LINUX_SOURCE}) -elseif(PLATFORM_MACOS) - - set(MAC_SOURCE - src/MacOS/TestAppMacOS.cpp - ) - target_sources(TestApp PRIVATE ${MAC_SOURCE}) - source_group("src\\McOS" FILES ${MAC_SOURCE}) - -elseif(PLATFORM_IOS) - set(IOS_SOURCE - src/IOS/TestAppIOS.cpp - ) - target_sources(TestApp PRIVATE ${IOS_SOURCE}) - source_group("src\\McOS" FILES ${IOS_SOURCE}) -endif() - -set_common_target_properties(TestApp) -target_include_directories(TestApp -PUBLIC - include -) - - -if(MSVC) - target_compile_options(TestApp PRIVATE -DUNICODE) - - if(PLATFORM_UNIVERSAL_WINDOWS) - # Disable w4189: local variable is initialized but not referenced - # Disable w4063: case is not a valid value for switch of enum - # Consume the windows runtime extensions (/ZW) - target_compile_options(TestApp INTERFACE /wd4189 /wd4063 /ZW) - endif() -endif() - -if(PLATFORM_WIN32) - SET(ENGINE_LIBRARIES - Diligent-GraphicsEngineD3D11-shared - Diligent-GraphicsEngineD3D12-shared - Diligent-GraphicsEngineOpenGL-shared - ) -elseif(PLATFORM_ANDROID) - SET(ENGINE_LIBRARIES - Diligent-GraphicsEngineOpenGL-shared - ) -elseif(PLATFORM_UNIVERSAL_WINDOWS) - SET(ENGINE_LIBRARIES - Diligent-GraphicsEngineD3D11-static - Diligent-GraphicsEngineD3D12-static - ) -elseif(PLATFORM_LINUX) - SET(ENGINE_LIBRARIES - Diligent-GraphicsEngineOpenGL-shared - ) -elseif(PLATFORM_MACOS) - SET(ENGINE_LIBRARIES - Diligent-GraphicsEngineOpenGL-shared - ) -elseif(PLATFORM_IOS) - SET(ENGINE_LIBRARIES - Diligent-GraphicsEngineOpenGL-static - ) -else() - message(FATAL_ERROR "Undefined platform") -endif() - -target_link_libraries(TestApp -PRIVATE - Diligent-BuildSettings -PUBLIC - NativeAppBase - Diligent-Common - Diligent-GraphicsTools - Diligent-TargetPlatform - ${ENGINE_LIBRARIES} -) - -if(PLATFORM_UNIVERSAL_WINDOWS) - target_link_libraries(TestApp PRIVATE dxguid.lib) -elseif(PLATFORM_ANDROID) - target_link_libraries(TestApp PRIVATE GLESv3 PUBLIC native_app_glue) -elseif(PLATFORM_LINUX) - target_link_libraries(TestApp PRIVATE GL X11) -elseif(PLATFORM_MACOS OR PLATFORM_IOS) - -endif() - -source_group("src" FILES ${SOURCE}) -source_group("include" FILES ${INCLUDE}) - -set_target_properties(TestApp PROPERTIES - FOLDER Tests -) diff --git a/Tests/TestApp/src/IOS/TestAppIOS.cpp b/Tests/TestApp/src/IOS/TestAppIOS.cpp deleted file mode 100644 index 2f1c44c..0000000 --- a/Tests/TestApp/src/IOS/TestAppIOS.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. -* -* In no event and under no legal theory, whether in tort (including negligence), -* contract, or otherwise, unless required by applicable law (such as deliberate -* and grossly negligent acts) or agreed to in writing, shall any Contributor be -* liable for any damages, including any direct, indirect, special, incidental, -* or consequential damages of any character arising as a result of this License or -* out of the use or inability to use the software (including but not limited to damages -* for loss of goodwill, work stoppage, computer failure or malfunction, or any and -* all other commercial damages or losses), even if such Contributor has been advised -* of the possibility of such damages. -*/ - -#include <queue> -#include "TestApp.h" - -namespace Diligent -{ - -class TestAppIOS final : public TestApp -{ -public: - TestAppIOS() - { - m_DeviceType = DeviceType::OpenGLES; - } - - virtual void Initialize(int deviceType, void* layer)override final - { - m_DeviceType = static_cast<Diligent::DeviceType>(deviceType); - InitializeDiligentEngine(layer); - InitializeRenderers(); - } - -private: -}; - -NativeAppBase* CreateApplication() -{ - return new TestAppIOS; -} - -} diff --git a/Tests/TestApp/src/Linux/TestAppLinux.cpp b/Tests/TestApp/src/Linux/TestAppLinux.cpp deleted file mode 100644 index 54abfa8..0000000 --- a/Tests/TestApp/src/Linux/TestAppLinux.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. -* -* In no event and under no legal theory, whether in tort (including negligence), -* contract, or otherwise, unless required by applicable law (such as deliberate -* and grossly negligent acts) or agreed to in writing, shall any Contributor be -* liable for any damages, including any direct, indirect, special, incidental, -* or consequential damages of any character arising as a result of this License or -* out of the use or inability to use the software (including but not limited to damages -* for loss of goodwill, work stoppage, computer failure or malfunction, or any and -* all other commercial damages or losses), even if such Contributor has been advised -* of the possibility of such damages. -*/ - -#include "TestApp.h" - -namespace Diligent -{ - -class TestAppLinux final : public TestApp -{ -public: - TestAppLinux() - { - m_DeviceType = DeviceType::OpenGL; - } - - virtual void OnGLContextCreated(Display* display, Window window)override final - { - InitializeDiligentEngine(display, reinterpret_cast<void*>(static_cast<size_t>(window))); - InitializeRenderers(); - } - -#if VULKAN_SUPPORTED - virtual bool InitVulkan(xcb_connection_t* connection, uint32_t window)override final - { - m_DeviceType = DeviceType::Vulkan; - struct XCBInfo - { - xcb_connection_t* connection; - uint32_t window; - }xcbInfo = {connection, window}; - InitializeDiligentEngine(nullptr, &xcbInfo); - InitializeRenderers(); - return true; - } -#endif -}; - -NativeAppBase* CreateApplication() -{ - return new TestAppLinux; -} - -} diff --git a/Tests/TestApp/src/MacOS/TestAppMacOS.cpp b/Tests/TestApp/src/MacOS/TestAppMacOS.cpp deleted file mode 100644 index 3542251..0000000 --- a/Tests/TestApp/src/MacOS/TestAppMacOS.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright 2015-2019 Egor Yusov -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. -* -* In no event and under no legal theory, whether in tort (including negligence), -* contract, or otherwise, unless required by applicable law (such as deliberate -* and grossly negligent acts) or agreed to in writing, shall any Contributor be -* liable for any damages, including any direct, indirect, special, incidental, -* or consequential damages of any character arising as a result of this License or -* out of the use or inability to use the software (including but not limited to damages -* for loss of goodwill, work stoppage, computer failure or malfunction, or any and -* all other commercial damages or losses), even if such Contributor has been advised -* of the possibility of such damages. -*/ - -#include <queue> -#include "TestApp.h" - -namespace Diligent -{ - -class TestAppMacOS final : public TestApp -{ -public: - TestAppMacOS() - { - m_DeviceType = DeviceType::OpenGL; - } - - virtual void Initialize(void* view)override final - { - m_DeviceType = view == nullptr ? DeviceType::OpenGL : DeviceType::Vulkan; - InitializeDiligentEngine(view); - InitializeRenderers(); - } -}; - -NativeAppBase* CreateApplication() -{ - return new TestAppMacOS; -} - -} diff --git a/Tests/TestApp/src/TestApp.cpp b/Tests/TestApp/src/TestApp.cpp deleted file mode 100644 index 36d42e4..0000000 --- a/Tests/TestApp/src/TestApp.cpp +++ /dev/null @@ -1,588 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. -* -* In no event and under no legal theory, whether in tort (including negligence), -* contract, or otherwise, unless required by applicable law (such as deliberate -* and grossly negligent acts) or agreed to in writing, shall any Contributor be -* liable for any damages, including any direct, indirect, special, incidental, -* or consequential damages of any character arising as a result of this License or -* out of the use or inability to use the software (including but not limited to damages -* for loss of goodwill, work stoppage, computer failure or malfunction, or any and -* all other commercial damages or losses), even if such Contributor has been advised -* of the possibility of such damages. -*/ - -#include <sstream> -#include <math.h> -#include <iomanip> - -#include <cstdlib> - -#include "PlatformDefinitions.h" -#include "TestApp.h" -#include "Errors.h" -#include "StringTools.h" - -#if D3D11_SUPPORTED -# include "EngineFactoryD3D11.h" -#endif - -#if D3D12_SUPPORTED -# include "EngineFactoryD3D12.h" -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED -# include "EngineFactoryOpenGL.h" -#endif - -#if VULKAN_SUPPORTED -# include "EngineFactoryVk.h" -#endif - -#if METAL_SUPPORTED -# include "EngineFactoryMtl.h" -#endif - -#include "FileSystem.h" -#include "MapHelper.h" -#include "Errors.h" -#include "TestVPAndSR.h" -#include "TestCopyTexData.h" -#include "PlatformMisc.h" -#include "StringTools.h" - -namespace Diligent -{ - -TestApp::TestApp() : - m_AppTitle("Test app") -{ -} - -TestApp::~TestApp() -{ -} - - -void TestApp::InitializeDiligentEngine( -#if PLATFORM_LINUX - void *display, -#endif - void *NativeWindowHandle - ) -{ - SwapChainDesc SCDesc; - Uint32 NumDeferredCtx = 0; - std::vector<IDeviceContext*> ppContexts; - std::vector<AdapterAttribs> Adapters; - std::vector<std::vector<DisplayModeAttribs>> AdapterDisplayModes; - switch (m_DeviceType) - { -#if D3D11_SUPPORTED - case DeviceType::D3D11: - { - EngineD3D11CreateInfo DeviceAttribs; -#if ENGINE_DLL - GetEngineFactoryD3D11Type GetEngineFactoryD3D11 = nullptr; - // Load the dll and import GetEngineFactoryD3D11() function - LoadGraphicsEngineD3D11(GetEngineFactoryD3D11); -#endif -#ifdef _DEBUG - DeviceAttribs.DebugFlags = D3D11_DEBUG_FLAG_CREATE_DEBUG_DEVICE | - D3D11_DEBUG_FLAG_VERIFY_COMMITTED_RESOURCE_RELEVANCE | - D3D11_DEBUG_FLAG_VERIFY_COMMITTED_SHADER_RESOURCES; -#endif - auto *pFactoryD3D11 = GetEngineFactoryD3D11(); - Uint32 NumAdapters = 0; - pFactoryD3D11->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, 0); - Adapters.resize(NumAdapters); - pFactoryD3D11->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, Adapters.data()); - - for(Uint32 i=0; i < Adapters.size(); ++i) - { - Uint32 NumDisplayModes = 0; - std::vector<DisplayModeAttribs> DisplayModes; - pFactoryD3D11->EnumerateDisplayModes(DIRECT3D_FEATURE_LEVEL_11_0, i, 0, TEX_FORMAT_RGBA8_UNORM, NumDisplayModes, nullptr); - DisplayModes.resize(NumDisplayModes); - pFactoryD3D11->EnumerateDisplayModes(DIRECT3D_FEATURE_LEVEL_11_0, i, 0, TEX_FORMAT_RGBA8_UNORM, NumDisplayModes, DisplayModes.data()); - AdapterDisplayModes.emplace_back(std::move(DisplayModes)); - } - - DeviceAttribs.NumDeferredContexts = NumDeferredCtx; - ppContexts.resize(1 + NumDeferredCtx); - pFactoryD3D11->CreateDeviceAndContextsD3D11(DeviceAttribs, &m_pDevice, ppContexts.data()); - - if(NativeWindowHandle != nullptr) - pFactoryD3D11->CreateSwapChainD3D11(m_pDevice, ppContexts[0], SCDesc, FullScreenModeDesc{}, NativeWindowHandle, &m_pSwapChain); - } - break; -#endif - -#if D3D12_SUPPORTED - case DeviceType::D3D12: - { -#if ENGINE_DLL - GetEngineFactoryD3D12Type GetEngineFactoryD3D12 = nullptr; - // Load the dll and import GetEngineFactoryD3D12() function - LoadGraphicsEngineD3D12(GetEngineFactoryD3D12); -#endif - auto *pFactoryD3D12 = GetEngineFactoryD3D12(); - Uint32 NumAdapters = 0; - pFactoryD3D12->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, 0); - Adapters.resize(NumAdapters); - pFactoryD3D12->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, Adapters.data()); - - for (Uint32 i = 0; i < Adapters.size(); ++i) - { - Uint32 NumDisplayModes = 0; - std::vector<DisplayModeAttribs> DisplayModes; - pFactoryD3D12->EnumerateDisplayModes(DIRECT3D_FEATURE_LEVEL_11_0, i, 0, TEX_FORMAT_RGBA8_UNORM, NumDisplayModes, nullptr); - DisplayModes.resize(NumDisplayModes); - pFactoryD3D12->EnumerateDisplayModes(DIRECT3D_FEATURE_LEVEL_11_0, i, 0, TEX_FORMAT_RGBA8_UNORM, NumDisplayModes, DisplayModes.data()); - AdapterDisplayModes.emplace_back(std::move(DisplayModes)); - } - - EngineD3D12CreateInfo EngD3D12Attribs; - EngD3D12Attribs.EnableDebugLayer = true; - //EngD3D12Attribs.EnableGPUBasedValidation = true; - EngD3D12Attribs.CPUDescriptorHeapAllocationSize[0] = 64; // D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV - EngD3D12Attribs.CPUDescriptorHeapAllocationSize[1] = 32; // D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER - EngD3D12Attribs.CPUDescriptorHeapAllocationSize[2] = 16; // D3D12_DESCRIPTOR_HEAP_TYPE_RTV - EngD3D12Attribs.CPUDescriptorHeapAllocationSize[3] = 16; // D3D12_DESCRIPTOR_HEAP_TYPE_DSV - EngD3D12Attribs.DynamicDescriptorAllocationChunkSize[0] = 8; // D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV - EngD3D12Attribs.DynamicDescriptorAllocationChunkSize[1] = 8; // D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER - ppContexts.resize(1 + NumDeferredCtx); - - EngD3D12Attribs.NumDeferredContexts = NumDeferredCtx; - pFactoryD3D12->CreateDeviceAndContextsD3D12(EngD3D12Attribs, &m_pDevice, ppContexts.data()); - - if (!m_pSwapChain && NativeWindowHandle != nullptr) - pFactoryD3D12->CreateSwapChainD3D12(m_pDevice, ppContexts[0], SCDesc, FullScreenModeDesc{}, NativeWindowHandle, &m_pSwapChain); - } - break; -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED - case DeviceType::OpenGL: - case DeviceType::OpenGLES: - { -#if !PLATFORM_MACOS - VERIFY_EXPR(NativeWindowHandle != nullptr); -#endif -#if EXPLICITLY_LOAD_ENGINE_GL_DLL - // Declare function pointer - GetEngineFactoryOpenGLType GetEngineFactoryOpenGL = nullptr; - // Load the dll and import GetEngineFactoryOpenGL() function - LoadGraphicsEngineOpenGL(GetEngineFactoryOpenGL); -#endif - auto* pFactoryOpenGL = GetEngineFactoryOpenGL(); - EngineGLCreateInfo CreationAttribs; - CreationAttribs.pNativeWndHandle = NativeWindowHandle; -#if PLATFORM_LINUX - CreationAttribs.pDisplay = display; -#endif - if (NumDeferredCtx != 0) - { - LOG_ERROR_MESSAGE("Deferred contexts are not supported in OpenGL mode"); - NumDeferredCtx = 0; - } - ppContexts.resize(1 + NumDeferredCtx); - pFactoryOpenGL->CreateDeviceAndSwapChainGL( - CreationAttribs, &m_pDevice, ppContexts.data(), SCDesc, &m_pSwapChain); - } - break; -#endif - -#if VULKAN_SUPPORTED - case DeviceType::Vulkan: - { -#if EXPLICITLY_LOAD_ENGINE_VK_DLL - GetEngineFactoryVkType GetEngineFactoryVk = nullptr; - // Load the dll and import GetEngineFactoryVk() function - LoadGraphicsEngineVk(GetEngineFactoryVk); -#endif - EngineVkCreateInfo EngVkAttribs; - - EngVkAttribs.EnableValidation = true; - EngVkAttribs.MainDescriptorPoolSize = EngineVkCreateInfo::DescriptorPoolSize{ 64, 64, 256, 256, 64, 32, 32, 32, 32 }; - EngVkAttribs.DynamicDescriptorPoolSize = EngineVkCreateInfo::DescriptorPoolSize{ 64, 64, 256, 256, 64, 32, 32, 32, 32 }; - EngVkAttribs.UploadHeapPageSize = 32*1024; - //EngVkAttribs.DeviceLocalMemoryReserveSize = 32 << 20; - //EngVkAttribs.HostVisibleMemoryReserveSize = 48 << 20; - - auto& Features = EngVkAttribs.EnabledFeatures; - Features.depthBiasClamp = true; - Features.fillModeNonSolid = true; - Features.depthClamp = true; - Features.independentBlend = true; - Features.samplerAnisotropy = true; - Features.geometryShader = true; - Features.tessellationShader = true; - Features.dualSrcBlend = true; - Features.multiViewport = true; - Features.imageCubeArray = true; - Features.textureCompressionBC = true; - Features.vertexPipelineStoresAndAtomics = true; - Features.fragmentStoresAndAtomics = true; - - EngVkAttribs.NumDeferredContexts = NumDeferredCtx; - ppContexts.resize(1 + NumDeferredCtx); - auto* pFactoryVk = GetEngineFactoryVk(); - pFactoryVk->CreateDeviceAndContextsVk(EngVkAttribs, &m_pDevice, ppContexts.data()); - - if (!m_pSwapChain && NativeWindowHandle != nullptr) - pFactoryVk->CreateSwapChainVk(m_pDevice, ppContexts[0], SCDesc, NativeWindowHandle, &m_pSwapChain); - } - break; -#endif - -#if METAL_SUPPORTED - case DeviceType::Metal: - { - EngineMtlCreateInfo MtlAttribs; - - MtlAttribs.NumDeferredContexts = NumDeferredCtx; - ppContexts.resize(1 + NumDeferredCtx); - auto *pFactoryMtl = GetEngineFactoryMtl(); - pFactoryMtl->CreateDeviceAndContextsMtl(MtlAttribs, &m_pDevice, ppContexts.data()); - - if (!m_pSwapChain && NativeWindowHandle != nullptr) - pFactoryMtl->CreateSwapChainMtl(m_pDevice, ppContexts[0], SCDesc, NativeWindowHandle, &m_pSwapChain); - } - break; -#endif - - default: - LOG_ERROR_AND_THROW("Unknown device type"); - break; - } - - - std::stringstream ss; - ss << "Found " << Adapters.size() << " adapters:\n"; - for (Uint32 i = 0; i < Adapters.size(); ++i) - { - ss << Adapters[i].Description << " (" << (Adapters[i].DedicatedVideoMemory >> 20) << " MB). Num outputs: " << Adapters[i].NumOutputs << ". Display modes:\n"; - const auto &DisplayModes = AdapterDisplayModes[i]; - for(Uint32 m=0; m < DisplayModes.size(); ++m) - { - const auto &Mode = DisplayModes[m]; - float RefreshRate = (float)Mode.RefreshRateNumerator / (float)Mode.RefreshRateDenominator; - ss << " " << Mode.Width << 'x' << Mode.Height << " " << std::fixed << std::setprecision(2) << RefreshRate << " Hz\n"; - } - } - auto str = ss.str(); - LOG_INFO_MESSAGE(str); - - m_pImmediateContext.Attach(ppContexts[0]); - m_pDeferredContexts.resize(NumDeferredCtx); - for (Diligent::Uint32 ctx = 0; ctx < NumDeferredCtx; ++ctx) - m_pDeferredContexts[ctx].Attach(ppContexts[1 + ctx]); -} - -void TestApp::InitializeRenderers() -{ - m_TestGS.Init(m_pDevice, m_pImmediateContext, m_pSwapChain); - m_TestTessellation.Init(m_pDevice, m_pImmediateContext, m_pSwapChain); - - const auto* BackBufferFmt = m_pDevice->GetTextureFormatInfo(m_pSwapChain->GetDesc().ColorBufferFormat).Name; - const auto* DepthBufferFmt = m_pDevice->GetTextureFormatInfo(m_pSwapChain->GetDesc().DepthBufferFormat).Name; - - m_pTestDrawCommands.reset(new TestDrawCommands); - m_pTestDrawCommands->Init(m_pDevice, m_pImmediateContext, m_pSwapChain, 0, 0, 1, 1); - - m_pTestBufferAccess.reset(new TestBufferAccess); - m_pTestBufferAccess->Init(m_pDevice, m_pImmediateContext, m_pSwapChain, -1, 0, 0.5, 0.5); - - - TEXTURE_FORMAT TestFormats[16] = - { - TEX_FORMAT_RGBA8_UNORM, TEX_FORMAT_RGBA8_UNORM_SRGB, TEX_FORMAT_RGBA32_FLOAT, TEX_FORMAT_RGBA16_UINT, - TEX_FORMAT_RGBA8_SNORM, TEX_FORMAT_RGBA8_UINT, TEX_FORMAT_RG8_UNORM, TEX_FORMAT_RG8_UINT, - TEX_FORMAT_RG32_FLOAT, TEX_FORMAT_RG16_UINT, TEX_FORMAT_RG8_SNORM, TEX_FORMAT_R8_UNORM, - TEX_FORMAT_R32_FLOAT, TEX_FORMAT_R8_SNORM, TEX_FORMAT_R8_UINT, TEX_FORMAT_R16_UINT - }; - - for (int j = 0; j < 4; ++j) - for (int i = 0; i < 4; ++i) - { - auto Ind = i + j * 4; - m_pTestTexturing[Ind].reset(new TestTexturing); - m_pTestTexturing[Ind]->Init(m_pDevice, m_pImmediateContext, m_pSwapChain, TestFormats[Ind], -1 + (float)i*1.f / 4.f, -1 + (float)j*1.f / 4.f, 0.9f / 4.f, 0.9f / 4.f); - } - - TestCopyTexData TestCopyData(m_pDevice, m_pImmediateContext); - - TestVPAndSR TestVPAndSR(m_pDevice, m_pImmediateContext); - - m_pTestCS.reset(new TestComputeShaders); - m_pTestCS->Init(m_pDevice, m_pImmediateContext, m_pSwapChain); - - m_pTestRT.reset(new TestRenderTarget); - m_pTestRT->Init(m_pDevice, m_pImmediateContext, m_pSwapChain, -0.4f, 0.55f, 0.4f, 0.4f); - - float instance_offsets[] = { -0.3f, 0.0f, 0.0f, 0.0f, +0.3f, -0.3f }; - - { - Diligent::BufferDesc BuffDesc; - BuffDesc.Name = "cbTestBlock2"; - float UniformData[16] = { 1,1,1,1 }; - BuffDesc.uiSizeInBytes = sizeof(UniformData); - BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; - BuffDesc.Usage = USAGE_DYNAMIC; - BuffDesc.CPUAccessFlags = CPU_ACCESS_WRITE; - m_pDevice->CreateBuffer(BuffDesc, nullptr, &m_pUniformBuff2); - } - - { - Diligent::BufferDesc BuffDesc; - BuffDesc.Name = "Test Constant Buffer 3"; - float UniformData[16] = { 1, 1, 1, 1 }; - BuffDesc.uiSizeInBytes = sizeof(UniformData); - BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; - BuffDesc.Usage = USAGE_DEFAULT; - BuffDesc.CPUAccessFlags = CPU_ACCESS_NONE; - Diligent::BufferData BuffData; - BuffData.pData = UniformData; - BuffData.DataSize = sizeof(UniformData); - m_pDevice->CreateBuffer(BuffDesc, &BuffData, &m_pUniformBuff3); - } - - { - Diligent::BufferDesc BuffDesc; - BuffDesc.Name = "Test Constant Buffer 4"; - float UniformData[16] = { 1, 1, 1, 1 }; - BuffDesc.uiSizeInBytes = sizeof(UniformData); - BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; - BuffDesc.Usage = USAGE_DEFAULT; - BuffDesc.CPUAccessFlags = CPU_ACCESS_NONE; - Diligent::BufferData BuffData; - BuffData.pData = UniformData; - BuffData.DataSize = sizeof(UniformData); - m_pDevice->CreateBuffer(BuffDesc, &BuffData, &m_pUniformBuff4); - } - - { - TextureDesc TexDesc; - TexDesc.Type = RESOURCE_DIM_TEX_2D; - TexDesc.Width = 1024; - TexDesc.Height = 1024; - TexDesc.Format = TEX_FORMAT_RGBA8_UNORM; - TexDesc.Usage = USAGE_DEFAULT; - TexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS; - TexDesc.Name = "UniqueTexture"; - - m_pDevice->CreateTexture(TexDesc, nullptr, &m_pTestTex); - - m_pTestTex.Release(); - m_pDevice->CreateTexture(TexDesc, nullptr, &m_pTestTex); - } - - { - m_pImmediateContext->Flush(); - // This is a test for possible bug in D3D12 - TextureDesc TexDesc; - TexDesc.Type = RESOURCE_DIM_TEX_2D; - TexDesc.Width = 512; - TexDesc.Height = 512; - TexDesc.Format = m_pSwapChain->GetDesc().ColorBufferFormat; - TexDesc.Usage = USAGE_DEFAULT; - TexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET; - TexDesc.Name = "UniqueTexture"; - RefCntAutoPtr<ITexture> pTex; - m_pDevice->CreateTexture(TexDesc, nullptr, &pTex); - ITextureView *pRTVs[] = { pTex->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET) }; - - TexDesc.Format = m_pSwapChain->GetDesc().DepthBufferFormat; - RefCntAutoPtr<ITexture> pDepthTex; - TexDesc.BindFlags = BIND_DEPTH_STENCIL; - m_pDevice->CreateTexture(TexDesc, nullptr, &pDepthTex); - auto* pDSV = pDepthTex->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); - - { - MapHelper<float> UniformData(m_pImmediateContext, m_pUniformBuff2, MAP_WRITE, MAP_FLAG_DISCARD); - UniformData[0] = (float)sin(0)*0.1f; - UniformData[1] = (float)cos(0)*0.1f; - UniformData[2] = (float)sin(0)*0.1f; - UniformData[3] = 0; - } - - m_pImmediateContext->SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - float ClearColor[] = {0.1f, 0.2f, 0.4f, 1.0f}; - m_pImmediateContext->ClearRenderTarget(nullptr, ClearColor, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - - // This adds transition barrier for pTex1 - m_pImmediateContext->SetRenderTargets(1, pRTVs, pDSV, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - m_pImmediateContext->ClearRenderTarget(pRTVs[0], ClearColor, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - m_pImmediateContext->ClearDepthStencil(pDSV, CLEAR_DEPTH_FLAG, 1, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - // Generate draw command to the bound render target - m_pImmediateContext->SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - // This will destroy texture and put D3D12 resource into release queue - pTex.Release(); - - - Diligent::BufferDesc BuffDesc; - BuffDesc.Name = "cbTestBlock2"; - float Data[16] = { 1,1,1,1 }; - BuffDesc.uiSizeInBytes = sizeof(Data); - BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; - BuffDesc.Usage = USAGE_DEFAULT; - BuffDesc.CPUAccessFlags = CPU_ACCESS_NONE; - Diligent::BufferData BuffData; - BuffData.pData = Data; - BuffData.DataSize = sizeof(Data); - // This will result in creating and executing another command list - RefCntAutoPtr<IBuffer> pBuff; - m_pDevice->CreateBuffer(BuffDesc, &BuffData, &pBuff); - - // This may cause D3D12 error - m_pImmediateContext->Flush(); - } - - { - FenceDesc fenceDesc; - fenceDesc.Name = "Test fence"; - m_pDevice->CreateFence(fenceDesc, &m_pFence); - } -} - -void TestApp::ProcessCommandLine(const char *CmdLine) -{ - const auto* Key = "-mode "; - const auto *pos = strstr(CmdLine, Key); - if (pos != nullptr) - { - pos += strlen(Key); - if (_stricmp(pos, "D3D11") == 0) - { - m_DeviceType = DeviceType::D3D11; - } - else if (_stricmp(pos, "D3D12") == 0) - { - m_DeviceType = DeviceType::D3D12; - } - else if (_stricmp(pos, "GL") == 0) - { - m_DeviceType = DeviceType::OpenGL; - } - else if (_stricmp(pos, "VK") == 0) - { - m_DeviceType = DeviceType::Vulkan; - } - else - { - LOG_ERROR_AND_THROW("Unknown device type. Only the following types are supported: D3D11, D3D12, GL, VK"); - } - } - else - { -#if D3D12_SUPPORTED - m_DeviceType = DeviceType::D3D12; -#elif VULKAN_SUPPORTED - m_DeviceType = DeviceType::Vulkan; -#elif D3D11_SUPPORTED - m_DeviceType = DeviceType::D3D11; -#elif GL_SUPPORTED || GLES_SUPPORTED - m_DeviceType = DeviceType::OpenGL; -#endif - } - - switch (m_DeviceType) - { - case DeviceType::D3D11: m_AppTitle.append(" (D3D11)"); break; - case DeviceType::D3D12: m_AppTitle.append(" (D3D12)"); break; - case DeviceType::OpenGL: m_AppTitle.append(" (OpenGL)"); break; - case DeviceType::Vulkan: m_AppTitle.append(" (Vulkan)"); break; - default: UNEXPECTED("Unknown device type"); - } -} - -void TestApp::WindowResize(int width, int height) -{ - if (m_pSwapChain) - { - m_pSwapChain->Resize(width, height); - //auto SCWidth = m_pSwapChain->GetDesc().Width; - //auto SCHeight = m_pSwapChain->GetDesc().Height; - - - } -} - -void TestApp::Update(double CurrTime, double ElapsedTime) -{ - m_CurrTime = CurrTime; -} - -void TestApp::Render() -{ - m_pImmediateContext->SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - float ClearColor[] = {0.1f, 0.2f, 0.4f, 1.0f}; - m_pImmediateContext->ClearRenderTarget(nullptr, ClearColor, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - m_pImmediateContext->ClearDepthStencil(nullptr, CLEAR_DEPTH_FLAG, 1.f, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - - double dCurrTime = m_CurrTime; - - - m_pTestDrawCommands->Draw(); - m_pTestBufferAccess->Draw((float)dCurrTime); - - for (int i = 0; i<_countof(m_pTestTexturing); ++i) - { - m_pTestTexturing[i]->Draw(); - } - m_pTestCS->Draw(); - m_pTestRT->Draw(); - m_TestGS.Draw(); - - auto CompletedFenceValue = m_pFence->GetCompletedValue(); - VERIFY_EXPR(CompletedFenceValue < m_NextFenceValue); - m_pImmediateContext->SignalFence(m_pFence, m_NextFenceValue++); - - CompletedFenceValue = m_pFence->GetCompletedValue(); - VERIFY_EXPR(CompletedFenceValue < m_NextFenceValue); - - if (rand() % 10 == 0) - { - if (rand() % 2 == 0) - { - m_pImmediateContext->Flush(); - m_pImmediateContext->SignalFence(m_pFence, m_NextFenceValue++); - } - - m_pImmediateContext->WaitForFence(m_pFence, m_NextFenceValue-1, true); - CompletedFenceValue = m_pFence->GetCompletedValue(); - VERIFY_EXPR(CompletedFenceValue >= m_NextFenceValue-1); - } - - if (rand() % 30 == 0) - { - m_pImmediateContext->WaitForIdle(); - } - - if (rand() % 60 == 0) - { - m_pDevice->IdleGPU(); - } - - m_TestTessellation.Draw(); - - m_pImmediateContext->Flush(); - m_pImmediateContext->InvalidateState(); -} - -void TestApp::Present() -{ - m_pSwapChain->Present(0); -} - -} diff --git a/Tests/TestApp/src/TestBufferAccess.cpp b/Tests/TestApp/src/TestBufferAccess.cpp deleted file mode 100644 index 6e139f9..0000000 --- a/Tests/TestApp/src/TestBufferAccess.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "pch.h" -#include <math.h> -#include "TestBufferAccess.h" -#include "MapHelper.h" - -using namespace Diligent; - -TestBufferAccess::TestBufferAccess() : - UnitTestBase("Buffer access test"), - m_fXExtent(0), - m_fYExtent(0) -{} - -void TestBufferAccess::Init( IRenderDevice *pDevice, IDeviceContext *pContext, ISwapChain *pSwapChain, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent ) -{ - m_pRenderDevice = pDevice; - m_pDeviceContext = pContext; - auto DevType = m_pRenderDevice->GetDeviceCaps().DevType; - bool bUseGLSL = DevType == DeviceType::OpenGL || DevType == DeviceType::OpenGLES || DevType == DeviceType::Vulkan; - - m_fXExtent = fXExtent; - m_fYExtent = fYExtent; - - float vertices[] = { 0.0f,0.0f,0.0f, 0.5f, 0.9f, 0.1f, - 0.5f,1.f,0.0f, 0.9f, 0.3f, 0.7f, - 1.f,0.0f,0.0f, 0.2f, 0.4f, 0.9f }; - for(int iVert=0; iVert < 3; ++iVert) - { - vertices[iVert*6] = (vertices[iVert*6]) / (float)(NumRows+1) * fXExtent + fMinXCoord; - vertices[iVert*6+1] = (vertices[iVert*6+1]) / (float)(NumRows+1) * fYExtent + fMinYCoord; - } - - { - Diligent::BufferDesc BuffDesc; - BuffDesc.uiSizeInBytes = sizeof(vertices); - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - Diligent::BufferData BuffData; - BuffData.pData = vertices; - BuffData.DataSize = BuffDesc.uiSizeInBytes; - m_pRenderDevice->CreateBuffer(BuffDesc, &BuffData, &m_pVertexBuff); - } - - for(int InstBuff = 0; InstBuff < _countof(m_pInstBuff); ++InstBuff) - { - float instance_offsets[NumInstances*2] = - { - 1.f * fXExtent / (float)(NumRows+1), InstBuff*fYExtent / (float)(NumRows+1), - 2.f * fXExtent / (float)(NumRows+1), InstBuff*fYExtent / (float)(NumRows+1), - 3.f * fXExtent / (float)(NumRows+1), InstBuff*fYExtent / (float)(NumRows+1), - }; - - Diligent::BufferDesc BuffDesc; - BuffDesc.uiSizeInBytes = sizeof(instance_offsets); - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - if( InstBuff == 3 ) - { - BuffDesc.Usage = USAGE_DYNAMIC; - BuffDesc.CPUAccessFlags = CPU_ACCESS_WRITE; - } - else if( InstBuff == 4 ) - { - BuffDesc.Usage = USAGE_STAGING; - BuffDesc.BindFlags = BIND_NONE; - BuffDesc.CPUAccessFlags = CPU_ACCESS_READ; - } - else if( InstBuff == 5 ) - { - BuffDesc.Usage = USAGE_STAGING; - BuffDesc.BindFlags = BIND_NONE; - BuffDesc.CPUAccessFlags = CPU_ACCESS_WRITE; - } - else if( InstBuff == 6 ) - { - BuffDesc.Usage = USAGE_STAGING; - BuffDesc.BindFlags = BIND_NONE; - BuffDesc.CPUAccessFlags = CPU_ACCESS_READ; - } - - Diligent::BufferData BuffData; - if(BuffDesc.Usage != USAGE_DYNAMIC && !(BuffDesc.Usage == USAGE_STAGING && (BuffDesc.CPUAccessFlags & CPU_ACCESS_WRITE) != 0)) - { - BuffData.pData = instance_offsets; - BuffData.DataSize = sizeof(instance_offsets); - } - m_pRenderDevice->CreateBuffer(BuffDesc, &BuffData, &m_pInstBuff[InstBuff]); - } - - ShaderCreateInfo CreationAttrs; - RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory; - pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory(nullptr, &pShaderSourceFactory); - CreationAttrs.pShaderSourceStreamFactory = pShaderSourceFactory; - CreationAttrs.UseCombinedTextureSamplers = true; - - RefCntAutoPtr<Diligent::IShader> pVSInst, pPS; - - { - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\minimalInstGL.vsh" : "Shaders\\minimalInstDX.vsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - m_pRenderDevice->CreateShader( CreationAttrs, &pVSInst ); - } - - { - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\minimalGL.psh" : "Shaders\\minimalDX.psh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - m_pRenderDevice->CreateShader( CreationAttrs, &pPS ); - } - - - PipelineStateDesc PSODesc; - PSODesc.Name = "Test buffer access PSO"; - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False; - PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_NONE; - PSODesc.GraphicsPipeline.BlendDesc.IndependentBlendEnable = False; - PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].BlendEnable = False; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = pSwapChain->GetDesc().ColorBufferFormat; - PSODesc.GraphicsPipeline.DSVFormat = pSwapChain->GetDesc().DepthBufferFormat; - PSODesc.GraphicsPipeline.pVS = pVSInst; - PSODesc.GraphicsPipeline.pPS = pPS; - - LayoutElement Elems[] = - { - LayoutElement{ 1, 1, 3, Diligent::VT_FLOAT32, false, sizeof(float) * 3, sizeof(float) * 6 }, - LayoutElement{ 0, 1, 3, Diligent::VT_FLOAT32, false, 0, sizeof(float) * 6 }, - LayoutElement{ 2, 3, 2, Diligent::VT_FLOAT32, false, LayoutElement::AutoOffset, LayoutElement::AutoStride, LayoutElement::FREQUENCY_PER_INSTANCE } - }; - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = Elems; - PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof( Elems ); - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - pDevice->CreatePipelineState(PSODesc, &m_pPSO); -} - -void TestBufferAccess::Draw(float fTime) -{ - m_pDeviceContext->SetPipelineState(m_pPSO); - // No shader resources needed - //m_pDeviceContext->TransitionShaderResources(m_pPSO, nullptr); - //m_pDeviceContext->CommitShaderResources(nullptr); - - IBuffer *pBuffs[] = {nullptr, m_pVertexBuff, nullptr, m_pInstBuff[0], nullptr}; - Uint32 Offsets[_countof( pBuffs )] = {0, 0, 0, 0, 0}; - m_pDeviceContext->SetVertexBuffers( 0, _countof( pBuffs ), pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET ); - - DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); - DrawAttrs.NumVertices = 3; - DrawAttrs.NumInstances = NumInstances; - m_pDeviceContext->Draw(DrawAttrs); - - - float fDX = m_fXExtent / (float)(NumRows+1); - float fDY = m_fYExtent / (float)(NumRows+1); - - float instance_offsets[NumInstances*2]; - for(int Inst = 0; Inst < NumInstances; ++Inst) - { - instance_offsets[Inst*2] = (1+Inst) * fDX; - instance_offsets[Inst*2+1] = 1.f * fDY + sin(fTime) * fDY * 0.3f; - } - m_pDeviceContext->UpdateBuffer(m_pInstBuff[1], sizeof( float ) * 2, sizeof( float ) * 4, &instance_offsets[2], RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); - - pBuffs[3] = m_pInstBuff[1]; - m_pDeviceContext->SetVertexBuffers( 0, _countof( pBuffs ), pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET ); - - m_pDeviceContext->Draw(DrawAttrs); - - - for(int Inst = 0; Inst < NumInstances; ++Inst) - { - instance_offsets[Inst*2] = (1+Inst) * fDX; - instance_offsets[Inst*2+1] = 2.f * fDY + sin(fTime*0.8f) * fDY * 0.3f; - } - m_pDeviceContext->UpdateBuffer(m_pInstBuff[2], sizeof( float ) * 2, sizeof( float ) * 4, &instance_offsets[2], RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); - m_pDeviceContext->CopyBuffer(m_pInstBuff[2], sizeof( float ) * 2, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, m_pInstBuff[1], sizeof( float ) * 2, sizeof( float ) * 4, RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); - StateTransitionDesc Barrier(m_pInstBuff[1], RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_VERTEX_BUFFER, true); - m_pDeviceContext->TransitionResourceStates(1, &Barrier); - m_pDeviceContext->Draw(DrawAttrs); - - for(int Inst = 0; Inst < NumInstances; ++Inst) - { - instance_offsets[Inst*2] = (1+Inst) * fDX; - instance_offsets[Inst*2+1] = 3.f * fDY + sin(fTime*1.2f) * fDY * 0.3f; - } - - // Test updating dynamic buffer - { - MapHelper<float> pInstData( m_pDeviceContext, m_pInstBuff[3], MAP_WRITE, MAP_FLAG_DISCARD ); - memcpy(pInstData, instance_offsets, sizeof(instance_offsets)); - } - - pBuffs[3] = m_pInstBuff[3]; - m_pDeviceContext->SetVertexBuffers( 0, _countof( pBuffs ), pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET ); - - m_pDeviceContext->Draw(DrawAttrs); - - bool TestStagingBuffers = false; - if(TestStagingBuffers) - { - MapHelper<float> pStagingData; - // Test reading data from staging resource - { - m_pDeviceContext->CopyBuffer(m_pInstBuff[3], 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, m_pInstBuff[4], 0, sizeof( instance_offsets ), RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); - pStagingData.Map( m_pDeviceContext, m_pInstBuff[4], MAP_READ, MAP_FLAG_NONE ); - for(int i = 0; i < _countof(instance_offsets); ++i) - assert(pStagingData[i] == instance_offsets[i]); - pStagingData.Unmap(); - } - - // D3D12 does not allow writing to the CPU-readable buffers - if(m_pRenderDevice->GetDeviceCaps().DevType != DeviceType::D3D12) - { - // Test writing data to staging resource - { - pStagingData.Map( m_pDeviceContext, m_pInstBuff[5], MAP_WRITE, MAP_FLAG_NONE ); - for(int Inst = 0; Inst < NumInstances; ++Inst) - { - pStagingData[Inst*2] = (1+Inst) * fDX; - pStagingData[Inst*2+1] = 4.f * fDY + sin(fTime*1.3f) * fDY * 0.3f; - } - pStagingData.Unmap(); - } - - StateTransitionDesc Barriers[2] = - { - StateTransitionDesc{m_pInstBuff[5], RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_COPY_SOURCE, true}, - StateTransitionDesc{m_pInstBuff[2], RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_COPY_DEST, true}, - }; - m_pDeviceContext->TransitionResourceStates(2, Barriers); - m_pDeviceContext->CopyBuffer(m_pInstBuff[5], 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY, m_pInstBuff[2], 0, sizeof( instance_offsets ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); - pBuffs[3] = m_pInstBuff[2]; - m_pDeviceContext->SetVertexBuffers( 0, _countof( pBuffs ), pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET ); - m_pDeviceContext->Draw(DrawAttrs); - - - // Test reading & writing data to the staging resource - /*{ - MapHelper<float> pInstData2( m_pDeviceContext, m_pInstBuff[6], MAP_READ_WRITE, 0 ); - MapHelper<float> pInstData3( std::move(pInstData2) ); - MapHelper<float> pInstData; - pInstData = std::move(pInstData3); - static float fPrevTime = fTime; - for(int Inst = 0; Inst < NumInstances; ++Inst) - { - pInstData[Inst*2] += (fTime-fPrevTime) * sin(fTime)*0.1f * m_fXExtent; - } - fPrevTime = fTime; - }*/ - - m_pDeviceContext->CopyBuffer(m_pInstBuff[6], 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, m_pInstBuff[2], 0, sizeof( instance_offsets ), RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); - m_pDeviceContext->Draw(DrawAttrs); - } - } - - SetStatus(TestResult::Succeeded); -} diff --git a/Tests/TestApp/src/TestComputeShaders.cpp b/Tests/TestApp/src/TestComputeShaders.cpp deleted file mode 100644 index 30a3023..0000000 --- a/Tests/TestApp/src/TestComputeShaders.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "pch.h" -#include "TestComputeShaders.h" -#include "GraphicsUtilities.h" - -using namespace Diligent; - -TestComputeShaders::TestComputeShaders() : - UnitTestBase("Compute shader test") -{ -} - -void TestComputeShaders::Init( IRenderDevice *pDevice, IDeviceContext *pContext, ISwapChain *pSwapChain ) -{ - if(!pDevice->GetDeviceCaps().bComputeShadersSupported) - { - SetStatus(TestResult::Skipped, "Compute shaders are not supported"); - return; - } -#if 0 - m_pRenderDevice = pDevice; - m_pDeviceContext = pContext; - const auto* BackBufferFmt = pDevice->GetTextureFormatInfo(pSwapChain->GetDesc().ColorBufferFormat).Name; - const auto* DepthBufferFmt = pDevice->GetTextureFormatInfo(pSwapChain->GetDesc().DepthBufferFormat).Name; - m_pRenderScript = CreateRenderScriptFromFile( "TestComputeShaders.lua", pDevice, pContext, [BackBufferFmt, DepthBufferFmt]( ScriptParser *pScriptParser ) - { - pScriptParser->SetGlobalVariable( "extBackBufferFormat", BackBufferFmt ); - pScriptParser->SetGlobalVariable( "extDepthBufferFormat", DepthBufferFmt ); - } ); -#endif -} - -void TestComputeShaders::Draw() -{ -#if 0 - if(!m_pDeviceContext) - return; - - m_pRenderScript->Run( m_pDeviceContext, "Render" ); - SetStatus(TestResult::Succeeded); -#endif -} diff --git a/Tests/TestApp/src/TestCopyTexData.cpp b/Tests/TestApp/src/TestCopyTexData.cpp deleted file mode 100644 index ffe3748..0000000 --- a/Tests/TestApp/src/TestCopyTexData.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "pch.h" -#include "TestCopyTexData.h" -#include "RenderDevice.h" -#include "GraphicsUtilities.h" -#include "Errors.h" - -using namespace Diligent; - -TestCopyTexData::TestCopyTexData( IRenderDevice *pDevice, IDeviceContext *pContext ) : - UnitTestBase("Texture data copy test"), - m_pDevice(pDevice), - m_pContext(pContext) -{ - TEXTURE_FORMAT TestFormats[] = - { - TEX_FORMAT_RGBA32_FLOAT, - TEX_FORMAT_RGBA32_UINT, - TEX_FORMAT_RGBA32_SINT, - TEX_FORMAT_RGBA16_FLOAT, - TEX_FORMAT_RGBA16_UINT, - TEX_FORMAT_RGBA16_SINT, - TEX_FORMAT_RGBA8_UNORM, - TEX_FORMAT_RGBA8_SNORM, - TEX_FORMAT_RGBA8_UINT, - TEX_FORMAT_RGBA8_SINT, - - TEX_FORMAT_RG32_FLOAT, - TEX_FORMAT_RG32_UINT, - TEX_FORMAT_RG32_SINT, - TEX_FORMAT_RG16_FLOAT, - TEX_FORMAT_RG16_UINT, - TEX_FORMAT_RG16_SINT, - TEX_FORMAT_RG8_UNORM, - TEX_FORMAT_RG8_SNORM, - TEX_FORMAT_RG8_UINT, - TEX_FORMAT_RG8_SINT, - - TEX_FORMAT_R32_FLOAT, - TEX_FORMAT_R32_UINT, - TEX_FORMAT_R32_SINT, - TEX_FORMAT_R16_FLOAT, - TEX_FORMAT_R16_UINT, - TEX_FORMAT_R16_SINT, - TEX_FORMAT_R8_UNORM, - TEX_FORMAT_R8_SNORM, - TEX_FORMAT_R8_UINT, - TEX_FORMAT_R8_SINT - }; - int NumFormatsTested = 0; - for( auto f = 0; f < _countof( TestFormats ); ++f ) - { - Test2DTexture(TestFormats[f]); - Test2DTexArray(TestFormats[f]); - Test3DTexture(TestFormats[f]); - ++NumFormatsTested; - } - std::stringstream infoss; - infoss << "Formats tested: " << NumFormatsTested; - SetStatus(TestResult::Succeeded, infoss.str().c_str()); -} - -void TestCopyTexData::Test2DTexture( TEXTURE_FORMAT Format ) -{ - TextureDesc TexDesc; - TexDesc.Type = RESOURCE_DIM_TEX_2D; - TexDesc.Format = Format; - TexDesc.Width = 128; - TexDesc.Height = 128; - TexDesc.BindFlags = BIND_SHADER_RESOURCE; - TexDesc.MipLevels = 5; - TexDesc.Usage = USAGE_DEFAULT; - - Diligent::RefCntAutoPtr<ITexture> pSrcTex, pDstTex; - auto FmtAttribs = m_pDevice->GetTextureFormatInfo(Format); - auto TexelSize = Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents}; - std::vector<uint8_t> DummyData(size_t{TexDesc.Width} * size_t{TexDesc.Height} * size_t{TexelSize}); - TextureData InitData; - InitData.NumSubresources = TexDesc.MipLevels; - std::vector<TextureSubResData> SubResData(InitData.NumSubresources); - for(Uint32 mip=0; mip < TexDesc.MipLevels; ++mip) - { - SubResData[mip] = TextureSubResData{DummyData.data(), (TexDesc.Width >> mip) * TexelSize, 0}; - } - InitData.pSubResources = SubResData.data(); - m_pDevice->CreateTexture( TexDesc, &InitData, &pSrcTex ); - m_pDevice->CreateTexture( TexDesc, nullptr, &pDstTex ); - - CopyTextureAttribs CopyAttribs; - CopyAttribs.pSrcTexture = pSrcTex; - CopyAttribs.SrcMipLevel = 2; - CopyAttribs.pDstTexture = pDstTex; - CopyAttribs.DstMipLevel = 1; - CopyAttribs.DstX = 32; - CopyAttribs.DstY = 16; - CopyAttribs.DstZ = 0; - CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; - CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; - m_pContext->CopyTexture(CopyAttribs); - - Box SrcBox; - SrcBox.MinX = 3; - SrcBox.MaxX = 19; - SrcBox.MinY = 1; - SrcBox.MaxY = 32; - CopyAttribs.pSrcBox = &SrcBox; - CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - m_pContext->CopyTexture(CopyAttribs); -} - -void TestCopyTexData::Test2DTexArray( TEXTURE_FORMAT Format ) -{ - TextureDesc TexDesc; - TexDesc.Type = RESOURCE_DIM_TEX_2D_ARRAY; - TexDesc.Format = Format; - TexDesc.Width = 128; - TexDesc.Height = 128; - TexDesc.BindFlags = BIND_SHADER_RESOURCE; - TexDesc.MipLevels = 5; - TexDesc.ArraySize = 8; - TexDesc.Usage = USAGE_DEFAULT; - - Diligent::RefCntAutoPtr<ITexture> pSrcTex, pDstTex; - auto FmtAttribs = m_pDevice->GetTextureFormatInfo(Format); - auto TexelSize = Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents}; - std::vector<uint8_t> DummyData(size_t{TexDesc.Width} * size_t{TexDesc.Height} * size_t{TexelSize}); - TextureData InitData; - InitData.NumSubresources = TexDesc.MipLevels * TexDesc.ArraySize; - std::vector<TextureSubResData> SubResData(InitData.NumSubresources); - Uint32 subres = 0; - for(Uint32 slice=0; slice < TexDesc.ArraySize; ++slice) - { - for(Uint32 mip=0; mip < TexDesc.MipLevels; ++mip) - { - SubResData[subres++] = TextureSubResData{DummyData.data(), (TexDesc.Width >> mip) * TexelSize, 0}; - } - } - VERIFY_EXPR(subres == InitData.NumSubresources); - InitData.pSubResources = SubResData.data(); - - m_pDevice->CreateTexture( TexDesc, &InitData, &pSrcTex ); - m_pDevice->CreateTexture( TexDesc, nullptr, &pDstTex ); - - CopyTextureAttribs CopyAttribs; - CopyAttribs.pSrcTexture = pSrcTex; - CopyAttribs.SrcMipLevel = 2; - CopyAttribs.SrcSlice = 3; - CopyAttribs.pDstTexture = pDstTex; - CopyAttribs.DstMipLevel = 1; - CopyAttribs.DstSlice = 6; - CopyAttribs.DstX = 32; - CopyAttribs.DstY = 16; - CopyAttribs.DstZ = 0; - CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; - CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; - m_pContext->CopyTexture(CopyAttribs); - - Box SrcBox; - SrcBox.MinX = 3; - SrcBox.MaxX = 19; - SrcBox.MinY = 1; - SrcBox.MaxY = 32; - CopyAttribs.DstSlice = 5; - CopyAttribs.pSrcBox = &SrcBox; - CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - m_pContext->CopyTexture(CopyAttribs); -} - -void TestCopyTexData::Test3DTexture( TEXTURE_FORMAT Format ) -{ - TextureDesc TexDesc; - TexDesc.Type = RESOURCE_DIM_TEX_3D; - TexDesc.Format = Format; - TexDesc.Width = 64; - TexDesc.Height = 64; - TexDesc.Depth = 16; - TexDesc.BindFlags = BIND_SHADER_RESOURCE; - TexDesc.MipLevels = 4; - TexDesc.Usage = USAGE_DEFAULT; - - Diligent::RefCntAutoPtr<ITexture> pSrcTex, pDstTex; - auto FmtAttribs = m_pDevice->GetTextureFormatInfo(Format); - auto TexelSize = Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents}; - std::vector<uint8_t> DummyData(size_t{TexDesc.Width} * size_t{TexDesc.Height} * size_t{TexDesc.Depth} * size_t{TexelSize}); - TextureData InitData; - InitData.NumSubresources = TexDesc.MipLevels; - std::vector<TextureSubResData> SubResData(InitData.NumSubresources); - for(Uint32 mip=0; mip < TexDesc.MipLevels; ++mip) - { - SubResData[mip] = TextureSubResData{DummyData.data(), (TexDesc.Width >> mip) * TexelSize, (TexDesc.Width >> mip) * (TexDesc.Height >> mip) * TexelSize}; - } - InitData.pSubResources = SubResData.data(); - m_pDevice->CreateTexture( TexDesc, &InitData, &pSrcTex ); - m_pDevice->CreateTexture( TexDesc, nullptr, &pDstTex ); - - CopyTextureAttribs CopyAttribs; - CopyAttribs.pSrcTexture = pSrcTex; - CopyAttribs.SrcMipLevel = 2; - CopyAttribs.pDstTexture = pDstTex; - CopyAttribs.DstMipLevel = 1; - CopyAttribs.DstX = 16; - CopyAttribs.DstY = 8; - CopyAttribs.DstZ = 0; - CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; - CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; - - m_pContext->CopyTexture(CopyAttribs); - - Box SrcBox; - SrcBox.MinX = 3; - SrcBox.MaxX = 19; - SrcBox.MinY = 1; - SrcBox.MaxY = 32; - CopyAttribs.pSrcBox = &SrcBox; - CopyAttribs.SrcMipLevel = 1; - CopyAttribs.DstMipLevel = 0; - CopyAttribs.DstX = 32; - CopyAttribs.DstY = 16; - CopyAttribs.DstZ = 0; - m_pContext->CopyTexture(CopyAttribs); -} diff --git a/Tests/TestApp/src/TestDrawCommands.cpp b/Tests/TestApp/src/TestDrawCommands.cpp deleted file mode 100644 index 2fdbd76..0000000 --- a/Tests/TestApp/src/TestDrawCommands.cpp +++ /dev/null @@ -1,918 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "pch.h" -#include "TestDrawCommands.h" -#include "MapHelper.h" - -using namespace Diligent; - -void TestDrawCommands::Init(IRenderDevice *pDevice, IDeviceContext *pDeviceContext, ISwapChain *pSwapChain, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent ) -{ - m_pRenderDevice = pDevice; - m_pDeviceContext = pDeviceContext; - - auto DevType = m_pRenderDevice->GetDeviceCaps().DevType; - bool bUseGLSL = DevType == DeviceType::OpenGL || DevType == DeviceType::OpenGLES || DevType == DeviceType::Vulkan; - - std::vector<float> VertexData; - std::vector<float> VertexData2; - std::vector<Uint32> IndexData; - std::vector<float> InstanceData; - Uint32 Ind = 0; - for( int iRow = 0; iRow < TriGridSize; ++iRow ) - for( int iCol = 0; iCol < TriGridSize; ++iCol ) - { - float fTriCenterX = (((float)iCol + 0.5f) / (float)TriGridSize) * fXExtent + fMinXCoord; - float fTriCenterY = (((float)iRow + 0.5f) / (float)TriGridSize) * fYExtent + fMinYCoord; - float fTriSizeX = fXExtent / (float)TriGridSize * 0.9f; - float fTriSizeY = fYExtent / (float)TriGridSize * 0.9f; - Define2DVertex( VertexData, fTriCenterX - 0.5f*fTriSizeX, fTriCenterY - 0.5f*fTriSizeY, 1, 0, 0 ); - Define2DVertex( VertexData, fTriCenterX + 0.5f*fTriSizeX, fTriCenterY - 0.5f*fTriSizeY, 0, 1, 0 ); - Define2DVertex( VertexData, fTriCenterX + 0.0f*fTriSizeX, fTriCenterY + 0.5f*fTriSizeY, 0, 0, 1 ); - - Define2DVertex( VertexData2, fTriCenterX - 0.5f*fTriSizeX, fTriCenterY - 0.5f*fTriSizeY, 1, 1, 0 ); - Define2DVertex( VertexData2, fTriCenterX + 0.5f*fTriSizeX, fTriCenterY - 0.5f*fTriSizeY, 0, 1, 1 ); - Define2DVertex( VertexData2, fTriCenterX + 0.0f*fTriSizeX, fTriCenterY + 0.5f*fTriSizeY, 1, 0, 1 ); - - InstanceData.push_back( (float)iCol / (float)TriGridSize * fXExtent ); - InstanceData.push_back( (float)iRow / (float)TriGridSize * fYExtent ); - - IndexData.push_back( Ind++ ); - IndexData.push_back( Ind++ ); - IndexData.push_back( Ind++ ); - } - - { - BufferDesc BuffDesc; - BuffDesc.Name = "Test Draw Commands: VertexBuff"; - BuffDesc.uiSizeInBytes = (Uint32)VertexData.size()*sizeof( float ); - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - BuffDesc.Usage = USAGE_STATIC; - BufferData BuffData; - BuffData.pData = VertexData.data(); - BuffData.DataSize = (Uint32)VertexData.size()*sizeof( float ); - m_pRenderDevice->CreateBuffer( BuffDesc, &BuffData, &m_pVertexBuff ); - } - - { - BufferDesc BuffDesc; - BuffDesc.Name = "Test Draw Commands: VertexBuff2"; - BuffDesc.uiSizeInBytes = (Uint32)VertexData2.size()*sizeof( float ); - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - BuffDesc.Usage = USAGE_STATIC; - BufferData BuffData; - BuffData.pData = VertexData2.data(); - BuffData.DataSize = (Uint32)VertexData2.size()*sizeof( float ); - m_pRenderDevice->CreateBuffer( BuffDesc, &BuffData, &m_pVertexBuff2 ); - } - - { - BufferDesc BuffDesc; - BuffDesc.Name = "Test Draw Commands: IndexBuff"; - BuffDesc.uiSizeInBytes = (Uint32)IndexData.size() * sizeof( Uint32 ); - BuffDesc.BindFlags = BIND_INDEX_BUFFER; - BuffDesc.Usage = USAGE_STATIC; - BufferData BuffData; - BuffData.pData = IndexData.data(); - BuffData.DataSize = BuffDesc.uiSizeInBytes; - m_pRenderDevice->CreateBuffer( BuffDesc, &BuffData, &m_pIndexBuff ); - } - - { - BufferDesc BuffDesc; - BuffDesc.Name = "Test Draw Commands: InstanceData"; - BuffDesc.uiSizeInBytes = (Uint32)InstanceData.size() * sizeof( float ); - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - BuffDesc.Usage = USAGE_STATIC; - BufferData BuffData; - BuffData.pData = InstanceData.data(); - BuffData.DataSize = BuffDesc.uiSizeInBytes; - m_pRenderDevice->CreateBuffer( BuffDesc, &BuffData, &m_pInstanceData ); - } - - if( m_pRenderDevice->GetDeviceCaps().bIndirectRenderingSupported ) - { - //typedef struct { - // GLuint count; - // GLuint instanceCount; - // GLuint first; - // GLuint baseInstance; - //} DrawArraysIndirectCommand; - - Uint32 IndirectDrawArgs[] = { 3, 2, 0, 0 }; - BufferDesc BuffDesc; - BuffDesc.uiSizeInBytes = sizeof( IndirectDrawArgs ); - // A buffer cannot be created if no bind flags set. We thus have to set this dummy BIND_VERTEX_BUFFER flag - // to be able to create the buffer - BuffDesc.BindFlags = BIND_INDIRECT_DRAW_ARGS | BIND_VERTEX_BUFFER; - BuffDesc.Usage = USAGE_DYNAMIC; - BuffDesc.CPUAccessFlags = CPU_ACCESS_WRITE; - m_pRenderDevice->CreateBuffer( BuffDesc, nullptr, &m_pIndirectDrawArgs ); - } - - { - //typedef struct { - // GLuint count; - // GLuint instanceCount; - // GLuint firstIndex; - // GLuint baseVertex; - // GLuint baseInstance; - //} DrawElementsIndirectCommand; - - Uint32 IndirectDrawArgs[] = { 3, 2, 0, 0, 0 }; - BufferDesc BuffDesc; - BuffDesc.uiSizeInBytes = sizeof( IndirectDrawArgs ); - // A buffer cannot be created if no bind flags set. We thus have to set this dummy flag - // to be able to create the buffer - BuffDesc.BindFlags = BIND_INDIRECT_DRAW_ARGS | BIND_VERTEX_BUFFER; - BuffDesc.Usage = USAGE_DYNAMIC; - BuffDesc.CPUAccessFlags = CPU_ACCESS_WRITE; - m_pRenderDevice->CreateBuffer( BuffDesc, nullptr, &m_pIndexedIndirectDrawArgs ); - } - - - ShaderCreateInfo CreationAttrs; - RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory; - pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory(nullptr, &pShaderSourceFactory); - CreationAttrs.pShaderSourceStreamFactory = pShaderSourceFactory; - CreationAttrs.UseCombinedTextureSamplers = true; - - RefCntAutoPtr<IShader> pVS, pVSInst, pPS; - { - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\minimalGL.vsh" : "Shaders\\minimalDX.vsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - m_pRenderDevice->CreateShader( CreationAttrs, &pVS ); - } - - { - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\minimalInstGL.vsh" : "Shaders\\minimalInstDX.vsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - m_pRenderDevice->CreateShader( CreationAttrs, &pVSInst ); - } - - { - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\minimalGL.psh" : "Shaders\\minimalDX.psh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - m_pRenderDevice->CreateShader( CreationAttrs, &pPS ); - } - - PipelineStateDesc PSODesc; - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False; - PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_NONE; - PSODesc.GraphicsPipeline.BlendDesc.IndependentBlendEnable = False; - PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].BlendEnable = False; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = pSwapChain->GetDesc().ColorBufferFormat; - PSODesc.GraphicsPipeline.DSVFormat = pSwapChain->GetDesc().DepthBufferFormat; - PSODesc.GraphicsPipeline.pPS = pPS; - - BlendStateDesc &BSDesc = PSODesc.GraphicsPipeline.BlendDesc; - BSDesc.IndependentBlendEnable = False; - BSDesc.RenderTargets[0].BlendEnable = True; - BSDesc.RenderTargets[0].SrcBlend = BLEND_FACTOR_ONE; - BSDesc.RenderTargets[0].DestBlend = BLEND_FACTOR_ONE; - BSDesc.RenderTargets[0].BlendOp = BLEND_OPERATION_ADD; - BSDesc.RenderTargets[0].SrcBlendAlpha = BLEND_FACTOR_ONE; - BSDesc.RenderTargets[0].DestBlendAlpha = BLEND_FACTOR_ZERO; - BSDesc.RenderTargets[0].BlendOpAlpha = BLEND_OPERATION_ADD; - - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - { - PSODesc.GraphicsPipeline.pVS = pVS; - - InputLayoutDesc LayoutDesc; - LayoutElement Elems[] = - { - LayoutElement{ 0, 0, 3, VT_FLOAT32, false, 0 }, - LayoutElement{ 1, 0, 3, VT_FLOAT32, false, sizeof( float ) * 3 } - }; - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = Elems; - PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof( Elems ); - m_pRenderDevice->CreatePipelineState( PSODesc, &m_pPSO ); - - Elems[0].Stride = sizeof(float)*6 * 2; - m_pRenderDevice->CreatePipelineState( PSODesc, &m_pPSO_2xStride ); - } - - { - PSODesc.GraphicsPipeline.pVS = pVSInst; - - InputLayoutDesc LayoutDesc; - LayoutElement Elems[] = - { - LayoutElement{ 0, 0, 3, VT_FLOAT32, false, 0 }, - LayoutElement{ 1, 0, 3, VT_FLOAT32, false, sizeof( float ) * 3 }, - LayoutElement{ 2, 1, 2, VT_FLOAT32, false, LayoutElement::AutoOffset, LayoutElement::AutoStride, LayoutElement::FREQUENCY_PER_INSTANCE } - }; - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = Elems; - PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof( Elems ); - m_pRenderDevice->CreatePipelineState( PSODesc, &m_pPSOInst ); - } - - { - BufferDesc BuffDesc; - float UniformData[16] = { 1, 1, 1, 1 }; - BuffDesc.uiSizeInBytes = sizeof( UniformData ); - BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; - BuffDesc.Usage = USAGE_DEFAULT; - BuffDesc.CPUAccessFlags = CPU_ACCESS_NONE; - BufferData BuffData; - BuffData.pData = UniformData; - BuffData.DataSize = sizeof( UniformData ); - RefCntAutoPtr<IBuffer> pUniformBuff3, pUniformBuff4; - BuffDesc.Name = "Test Constant Buffer 3"; - m_pRenderDevice->CreateBuffer( BuffDesc, &BuffData, &pUniformBuff3 ); - BuffDesc.Name = "Test Constant Buffer 4"; - m_pRenderDevice->CreateBuffer( BuffDesc, &BuffData, &pUniformBuff4 ); - - ResourceMappingDesc ResMappingDesc; - ResourceMappingEntry pEtries[] = { { "cbTestBlock3", pUniformBuff3 }, { "cbTestBlock4", pUniformBuff4 }, { nullptr, nullptr } }; - ResMappingDesc.pEntries = pEtries; - m_pRenderDevice->CreateResourceMapping( ResMappingDesc, &m_pResMapping ); - } - - m_pPSO->BindStaticResources(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, m_pResMapping, BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED); - m_pPSOInst->BindStaticResources(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, m_pResMapping, BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED | BIND_SHADER_RESOURCES_UPDATE_STATIC); - m_pPSO_2xStride->BindStaticResources(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, m_pResMapping, BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED | BIND_SHADER_RESOURCES_UPDATE_STATIC); - m_pPSO->CreateShaderResourceBinding(&m_pSRB, true); - m_pPSOInst->CreateShaderResourceBinding(&m_pSRBInst, true); -} - -void TestDrawCommands::Draw() -{ - m_pDeviceContext->SetPipelineState(m_pPSO); - m_pDeviceContext->CommitShaderResources(m_pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - IBuffer *pBuffs[2] = {m_pVertexBuff, m_pInstanceData}; - Uint32 Strides[] = {sizeof(float)*6, sizeof(float)*2}; - Uint32 Offsets[] = {0, 0}; - m_pDeviceContext->SetVertexBuffers( 0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - StateTransitionDesc Barriers[] = - { - {m_pIndirectDrawArgs, m_pIndirectDrawArgs->GetState(), RESOURCE_STATE_INDIRECT_ARGUMENT, false}, - {m_pIndexedIndirectDrawArgs, m_pIndexedIndirectDrawArgs->GetState(), RESOURCE_STATE_INDIRECT_ARGUMENT, false}, - {m_pVertexBuff, m_pVertexBuff->GetState(), RESOURCE_STATE_VERTEX_BUFFER, true}, - {m_pVertexBuff2, m_pVertexBuff2->GetState(), RESOURCE_STATE_VERTEX_BUFFER, true}, - {m_pInstanceData, RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_VERTEX_BUFFER, true}, - {m_pIndexBuff, RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_INDEX_BUFFER, true} - }; - Barriers[0].TransitionType = STATE_TRANSITION_TYPE_BEGIN; - Barriers[1].TransitionType = STATE_TRANSITION_TYPE_BEGIN; - m_pDeviceContext->TransitionResourceStates(_countof(Barriers), Barriers); - - Uint32 NumTestTrianglesInRow[TriGridSize] = { 0 }; - - - // 1ST ROW: simple non-indexed drawing (glDrawArrays/Draw) - - // 0,1: basic drawing - { - // Draw 2 triangles - DrawAttribs DrawAttrs(2*3, DRAW_FLAG_VERIFY_ALL); - m_pDeviceContext->Draw(DrawAttrs); - } - - // 2,3: test StartVertex - { - // Draw 2 triangles - DrawAttribs DrawAttrs(2*3, DRAW_FLAG_VERIFY_ALL); - DrawAttrs.StartVertexLocation = 2*3; - m_pDeviceContext->Draw(DrawAttrs); - } - - // 4,5: test buffer offset - Offsets[0] = 4*3*6*sizeof(float); - m_pDeviceContext->SetVertexBuffers(0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - // Draw 2 triangles - DrawAttribs DrawAttrs(2*3, DRAW_FLAG_VERIFY_ALL); - m_pDeviceContext->Draw(DrawAttrs); - } - - // 6,7: test buffer offset & StartVertex - { - DrawAttribs DrawAttrs(2*3, DRAW_FLAG_VERIFY_ALL); - DrawAttrs.StartVertexLocation = 2*3; - m_pDeviceContext->Draw(DrawAttrs); - } - - // 8,9: test strides - Strides[0] *= 2; - m_pDeviceContext->SetPipelineState(m_pPSO_2xStride); - m_pDeviceContext->CommitShaderResources(m_pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - m_pDeviceContext->SetVertexBuffers(0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawAttribs DrawAttrs(2*3, DRAW_FLAG_VERIFY_ALL);// Draw 2 triangles - DrawAttrs.StartVertexLocation = 4*3/2; // Stride is 2x - m_pDeviceContext->Draw(DrawAttrs); - } - Strides[0] /= 2; - m_pDeviceContext->SetPipelineState(m_pPSO); - m_pDeviceContext->CommitShaderResources(m_pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - NumTestTrianglesInRow[0] = 12; - - - - - // 2ND ROW: simple indexed rendering (glDrawElements/DrawIndexed) - - Offsets[0] = 1*16*3 * 6*sizeof(float); - m_pDeviceContext->SetVertexBuffers(0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - // 0,1 - { - DrawIndexedAttribs DrawAttrs(2*3, VT_UINT32, DRAW_FLAG_VERIFY_ALL);// Draw 2 triangles - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 2,3: test index buffer offset - m_pDeviceContext->SetIndexBuffer( m_pIndexBuff, 2 * 3 * sizeof( Uint32 ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); - - { - DrawIndexedAttribs DrawAttrs(2*3, VT_UINT32, DRAW_FLAG_VERIFY_ALL);// Draw 2 triangles - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - NumTestTrianglesInRow[1] = 4; - - - - // 3RD ROW: indexed rendering with BaseVertex (glDrawElementsBaseVertex/DrawIndexed) - Offsets[0] = (2*16*3 - 10) * 6*sizeof(float); - m_pDeviceContext->SetVertexBuffers(0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - - // 0,1 - { - DrawIndexedAttribs DrawAttrs(2*3, VT_UINT32, DRAW_FLAG_VERIFY_ALL);// Draw 2 triangles - DrawAttrs.BaseVertex = 10; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 2,3: index buffer offset & Base Vertex - m_pDeviceContext->SetIndexBuffer( m_pIndexBuff, 2 * 3 * sizeof( Uint32 ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); - - { - DrawIndexedAttribs DrawAttrs(2*3, VT_UINT32, DRAW_FLAG_VERIFY_ALL);// Draw 2 triangles - DrawAttrs.BaseVertex = 10; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - NumTestTrianglesInRow[2] = 4; - - - // 4TH ROW: Instanced non-indexed rendering (glDrawArraysInstanced/DrawInstanced) - - Barriers[0].TransitionType = STATE_TRANSITION_TYPE_END; - Barriers[1].TransitionType = STATE_TRANSITION_TYPE_END; - Barriers[0].UpdateResourceState = true; - Barriers[1].UpdateResourceState = true; - m_pDeviceContext->TransitionResourceStates(2, Barriers); - - m_pDeviceContext->SetPipelineState(m_pPSOInst); - m_pDeviceContext->TransitionShaderResources(m_pPSOInst, m_pSRBInst); - m_pDeviceContext->CommitShaderResources(m_pSRBInst, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - - Offsets[0] = 3*16*3 * 6*sizeof(float); - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - - // 0,1 - { - DrawAttribs DrawAttrs; - DrawAttrs.NumVertices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->Draw(DrawAttrs); - } - - // 2,3: Test offset in instance buffer - Offsets[1] = 2* Strides[1]; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawAttribs DrawAttrs; - DrawAttrs.NumVertices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->Draw(DrawAttrs); - } - - // 4,5: test start vertex index - { - DrawAttribs DrawAttrs; - DrawAttrs.NumVertices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.StartVertexLocation = 2*3; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->Draw(DrawAttrs); - } - NumTestTrianglesInRow[3] = 6; - - - - - // 5TH ROW: instanced rendering with base instance (glDrawArraysInstancedBaseInstance/DrawInstanced) - Offsets[0] = 4*16*3 * 6*sizeof(float); - Offsets[1] = 0; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - // 0,1 - { - DrawAttribs DrawAttrs; - DrawAttrs.NumVertices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.FirstInstanceLocation = 0; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->Draw(DrawAttrs); - } - - // 2,3 - { - DrawAttribs DrawAttrs; - DrawAttrs.NumVertices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.FirstInstanceLocation = 2; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->Draw(DrawAttrs); - } - - // 4,5: test vertex buffer offset - Offsets[0] += 2*3 * Strides[0]; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawAttribs DrawAttrs; - DrawAttrs.NumVertices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.FirstInstanceLocation = 2; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->Draw(DrawAttrs); - } - - // 6,7: test instance buffer offset - Offsets[1] += 2 * Strides[1]; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawAttribs DrawAttrs; - DrawAttrs.NumVertices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.FirstInstanceLocation = 2; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->Draw(DrawAttrs); - } - NumTestTrianglesInRow[4] = 8; - - - - // 6TH ROW: instanced indexed rendering (glDrawElementsInstanced/DrawIndexedInstanced) - - Offsets[0] = 5*16*3 * 6*sizeof(float); - Offsets[1] = 0; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - // 0,1 - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 2,3: test index buffer offset - m_pDeviceContext->SetIndexBuffer( m_pIndexBuff, 2 * 3 * sizeof( Uint32 ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 4,5: test vertex buffer offset - Offsets[0] += 2*3 * Strides[0]; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 6,7: test instance buffer offset - Offsets[1] += 2 * Strides[1]; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 8,9: test first index location - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.FirstIndexLocation = 2*3; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - NumTestTrianglesInRow[5] = 10; - - - - - // 7TH ROW: instanced indexed rendering with base instance (glDrawElementsInstancedBaseInstance/DrawInstanced) - - Offsets[0] = 6*16*3 * 6*sizeof(float); - Offsets[1] = 0; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - // 0,1 - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - // 2,3 - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.FirstInstanceLocation = 2; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 4,5: test index buffer offset - m_pDeviceContext->SetIndexBuffer( m_pIndexBuff, 2 * 3 * sizeof( Uint32 ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.FirstInstanceLocation = 2; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 6,7: test instance buffer offset - Offsets[1] += Strides[1] * 2; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.FirstInstanceLocation = 2; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 8,9: test first index location - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.FirstInstanceLocation = 2; - DrawAttrs.FirstIndexLocation = 2*3; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - NumTestTrianglesInRow[6] = 10; - - - - // 8TH ROW: instanced indexed rendering with base vertex (glDrawElementsInstancedBaseVertex/DrawInstanced) - - Offsets[0] = 7*16*3 * 6*sizeof(float); - Offsets[1] = 0; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - // 0,1 - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 2,3 - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 2*3; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 4,5: test index buffer offset - m_pDeviceContext->SetIndexBuffer( m_pIndexBuff, 2 * 3 * sizeof( Uint32 ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 2*3; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 6,7: test instance buffer offset - Offsets[1] += Strides[1] * 2; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 2*3; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 8,9: Test first index location - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 2*3; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.FirstIndexLocation = 2*3; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - NumTestTrianglesInRow[7] = 10; - - - - // 9TH ROW: instanced indexed rendering with base vertex & base instance (glDrawElementsInstancedBaseVertexBaseInstance/DrawInstanced) - - Offsets[0] = 8*16*3 * 6*sizeof(float); - Offsets[1] = 0; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - // 0,1 - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 2,3 - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 3; - DrawAttrs.FirstInstanceLocation = 1; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 4,5: test index buffer offset - m_pDeviceContext->SetIndexBuffer( m_pIndexBuff, 2 * 3 * sizeof( Uint32 ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 3; - DrawAttrs.FirstInstanceLocation = 1; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 6,7: test instance buffer offset - Offsets[1] += Strides[1] * 2; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 3; - DrawAttrs.FirstInstanceLocation = 1; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 8,9: test first index location - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 3; - DrawAttrs.FirstInstanceLocation = 1; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.FirstIndexLocation = 2*3; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - NumTestTrianglesInRow[8] = 10; - - - - if( m_pRenderDevice->GetDeviceCaps().bIndirectRenderingSupported ) - { - // 10TH ROW: instanced non-indexed indirect rendering (glDrawArraysIndirect/DrawInstancedIndirect) - - // Test indirect non-indexed drawing - Offsets[0] = 9*16*3 * 6*sizeof(float); - Offsets[1] = 0; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - - // 0,1 - { - MapHelper<Uint32, true> MappedData(m_pDeviceContext, m_pIndirectDrawArgs, MAP_WRITE, MAP_FLAG_DISCARD); - MappedData[0] = 3; // Vertex count - MappedData[1] = 2; // Num instances - MappedData[2] = 0; // Start vertex - MappedData[3] = 0; // Start instance - MappedData.Unmap(); - - DrawIndirectAttribs DrawAttrs(DRAW_FLAG_VERIFY_ALL, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - m_pDeviceContext->DrawIndirect(DrawAttrs, m_pIndirectDrawArgs); - } - - // 2,3: test first vertex location - { - MapHelper<Uint32, true> MappedData( m_pDeviceContext, m_pIndirectDrawArgs, MAP_WRITE, MAP_FLAG_DISCARD ); - MappedData[0] = 3; // Vertex count - MappedData[1] = 2; // Num instances - MappedData[2] = 3*2; // Start vertex - MappedData[3] = 0; // Start instance - MappedData.Unmap(); - DrawIndirectAttribs DrawAttrs(DRAW_FLAG_VERIFY_ALL, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - m_pDeviceContext->DrawIndirect(DrawAttrs, m_pIndirectDrawArgs); - } - - // 4,5: test first instance location - { - MapHelper<Uint32, true> MappedData( m_pDeviceContext, m_pIndirectDrawArgs, MAP_WRITE, MAP_FLAG_DISCARD ); - MappedData[0] = 3; // Vertex count - MappedData[1] = 2; // Num instances - MappedData[2] = 3*2; // Start vertex - MappedData[3] = 2; // Start instance - MappedData.Unmap(); - DrawIndirectAttribs DrawAttrs; - DrawAttrs.IndirectAttribsBufferStateTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndirect(DrawAttrs, m_pIndirectDrawArgs); - } - - NumTestTrianglesInRow[9] = 6; - - - - - // 11TH ROW: instanced indexed indirect rendering (glDrawElementsIndirect/DrawIndexedInstancedIndirect) - - Offsets[0] = 10*16*3 * 6*sizeof(float); - Offsets[1] = 0; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - - // 0,1 - { - MapHelper<Uint32> MappedData( m_pDeviceContext, m_pIndexedIndirectDrawArgs, MAP_WRITE, MAP_FLAG_DISCARD ); - MappedData[0] = 3; // Num indices - MappedData[1] = 2; // Num instances - MappedData[2] = 0; // Start index - MappedData[3] = 0; // Base vertex - MappedData[4] = 0; // Start instance - MappedData.Unmap(); - - DrawIndexedIndirectAttribs DrawAttrs(VT_UINT32, DRAW_FLAG_VERIFY_ALL, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - m_pDeviceContext->DrawIndexedIndirect(DrawAttrs, m_pIndexedIndirectDrawArgs); - } - - // 2,3: test start index location - { - MapHelper<Uint32> MappedData( m_pDeviceContext, m_pIndexedIndirectDrawArgs, MAP_WRITE, MAP_FLAG_DISCARD ); - MappedData[0] = 3; // Num indices - MappedData[1] = 2; // Num instances - MappedData[2] = 6; // Start index - MappedData[3] = 0; // Base vertex - MappedData[4] = 0; // Start instance - MappedData.Unmap(); - - DrawIndexedIndirectAttribs DrawAttrs; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.IndirectAttribsBufferStateTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexedIndirect(DrawAttrs, m_pIndexedIndirectDrawArgs); - } - - // 4,5: test base vertex - { - MapHelper<Uint32> MappedData( m_pDeviceContext, m_pIndexedIndirectDrawArgs, MAP_WRITE, MAP_FLAG_DISCARD ); - MappedData[0] = 3; // Num indices - MappedData[1] = 2; // Num instances - MappedData[2] = 6; // Start index - MappedData[3] = 2*3;// Base vertex - MappedData[4] = 0; // Start instance - MappedData.Unmap(); - - DrawIndexedIndirectAttribs DrawAttrs; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.IndirectAttribsBufferStateTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexedIndirect(DrawAttrs, m_pIndexedIndirectDrawArgs); - } - - // 6,7: test start instance - { - MapHelper<Uint32> MappedData( m_pDeviceContext, m_pIndexedIndirectDrawArgs, MAP_WRITE, MAP_FLAG_DISCARD ); - MappedData[0] = 3; // Num indices - MappedData[1] = 2; // Num instances - MappedData[2] = 6; // Start index - MappedData[3] = 2*3;// Base vertex - MappedData[4] = 2; // Start instance - MappedData.Unmap(); - - DrawIndexedIndirectAttribs DrawAttrs; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.IndirectAttribsBufferStateTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexedIndirect(DrawAttrs, m_pIndexedIndirectDrawArgs); - } - NumTestTrianglesInRow[10] = 8; - } - - // Draw end triangles - Offsets[0] = 0; - pBuffs[0] = m_pVertexBuff2; - m_pDeviceContext->SetVertexBuffers(0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - - m_pDeviceContext->SetPipelineState(m_pPSO); - m_pDeviceContext->CommitShaderResources(m_pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - { - // Draw 1 triangle - DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); - - for(int iRow=0; iRow < TriGridSize; ++iRow) - { - DrawAttrs.StartVertexLocation = 16*3*iRow + 3*(1+NumTestTrianglesInRow[iRow]); - m_pDeviceContext->Draw(DrawAttrs); - } - } - - m_pDeviceContext->SetVertexBuffers( 0, 0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET ); - - SetStatus(TestResult::Succeeded); -} - - -void TestDrawCommands::Define2DVertex(std::vector<float> &VertexData, float fX, float fY, float fR, float fG, float fB) -{ - VertexData.push_back(fX); - VertexData.push_back(fY); - VertexData.push_back(0.5f); - VertexData.push_back(fR); - VertexData.push_back(fG); - VertexData.push_back(fB); -} diff --git a/Tests/TestApp/src/TestGeometryShader.cpp b/Tests/TestApp/src/TestGeometryShader.cpp deleted file mode 100644 index b3dc8df..0000000 --- a/Tests/TestApp/src/TestGeometryShader.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "pch.h" -#include "TestGeometryShader.h" -#include "MapHelper.h" - -using namespace Diligent; - -void TestGeometryShader::Init( IRenderDevice *pDevice, IDeviceContext *pDeviceContext, ISwapChain *pSwapChain) -{ - if(!pDevice->GetDeviceCaps().bGeometryShadersSupported) - { - SetStatus(TestResult::Skipped, "Geometry shaders are not supported"); - return; - } - - m_pDeviceContext = pDeviceContext; - - ShaderCreateInfo CreationAttrs; - RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory; - pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory(nullptr, &pShaderSourceFactory); - CreationAttrs.pShaderSourceStreamFactory = pShaderSourceFactory; - CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - CreationAttrs.UseCombinedTextureSamplers = true; - - RefCntAutoPtr<Diligent::IShader> pVS, pGS, pPS; - { - CreationAttrs.FilePath = "Shaders\\GSTestDX.vsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - pDevice->CreateShader( CreationAttrs, &pVS ); - } - - { - CreationAttrs.FilePath = "Shaders\\GSTestDX.gsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_GEOMETRY; - pDevice->CreateShader( CreationAttrs, &pGS ); - } - - { - CreationAttrs.FilePath = "Shaders\\GSTestDX.psh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - pDevice->CreateShader( CreationAttrs, &pPS ); - } - - PipelineStateDesc PSODesc; - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False; - PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_NONE; - PSODesc.GraphicsPipeline.BlendDesc.IndependentBlendEnable = False; - PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].BlendEnable = False; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = pSwapChain->GetDesc().ColorBufferFormat; - PSODesc.GraphicsPipeline.DSVFormat = pSwapChain->GetDesc().DepthBufferFormat; - PSODesc.GraphicsPipeline.pPS = pPS; - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pGS = pGS; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_POINT_LIST; - - pDevice->CreatePipelineState( PSODesc, &m_pPSO ); -} - -void TestGeometryShader::Draw() -{ - if(!m_pDeviceContext) - return; - - m_pDeviceContext->SetPipelineState(m_pPSO); - m_pDeviceContext->CommitShaderResources(nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - // Draw 2 triangles - Diligent::DrawAttribs DrawAttrs(2, DRAW_FLAG_VERIFY_ALL); - m_pDeviceContext->Draw(DrawAttrs); - - SetStatus(TestResult::Succeeded); -} diff --git a/Tests/TestApp/src/TestRenderTarget.cpp b/Tests/TestApp/src/TestRenderTarget.cpp deleted file mode 100644 index 033dffc..0000000 --- a/Tests/TestApp/src/TestRenderTarget.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "pch.h" -#include "TestRenderTarget.h" -#include "GraphicsUtilities.h" - -using namespace Diligent; - -TestRenderTarget::TestRenderTarget() : - UnitTestBase("Render target test") -{ -} - -void TestRenderTarget::Init( IRenderDevice *pDevice, IDeviceContext *pDeviceContext, ISwapChain* pSwapChain, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent ) -{ -#if PLATFORM_IOS - SetStatus(TestResult::Skipped); - return; -#endif - -#if 0 - m_pRenderDevice = pDevice; - m_pDeviceContext = pDeviceContext; - m_pRenderScript = CreateRenderScriptFromFile( "TestRenderTargets.lua", pDevice, pDeviceContext, [&]( ScriptParser *pScriptParser ) - { - const auto* BackBufferFmt = pDevice->GetTextureFormatInfo(pSwapChain->GetDesc().ColorBufferFormat).Name; - const auto* DepthBufferFmt = pDevice->GetTextureFormatInfo(pSwapChain->GetDesc().DepthBufferFormat).Name; - pScriptParser->SetGlobalVariable( "extBackBufferFormat", BackBufferFmt ); - pScriptParser->SetGlobalVariable( "extDepthBufferFormat", DepthBufferFmt ); - - pScriptParser->SetGlobalVariable( "MinX", fMinXCoord ); - pScriptParser->SetGlobalVariable( "MinY", fMinYCoord ); - pScriptParser->SetGlobalVariable( "XExt", fXExtent ); - pScriptParser->SetGlobalVariable( "YExt", fYExtent ); - } ); -#endif -} - -void TestRenderTarget::Draw() -{ - if(!m_pDeviceContext) - return; -#if 0 - m_pRenderScript->Run( m_pDeviceContext, "Render" ); - SetStatus(TestResult::Succeeded); -#endif -} diff --git a/Tests/TestApp/src/TestTessellation.cpp b/Tests/TestApp/src/TestTessellation.cpp deleted file mode 100644 index 6d9f001..0000000 --- a/Tests/TestApp/src/TestTessellation.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "pch.h" -#include "TestTessellation.h" -#include "MapHelper.h" - -using namespace Diligent; - -void TestTessellation::Init( IRenderDevice *pDevice, IDeviceContext *pDeviceContext, ISwapChain *pSwapChain) -{ - if(!pDevice->GetDeviceCaps().bTessellationSupported) - { - SetStatus(TestResult::Skipped, "Tessellation is not supported"); - return; - } - - m_pDeviceContext = pDeviceContext; - - ShaderCreateInfo CreationAttrs; - RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory; - pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("Shaders", &pShaderSourceFactory); - CreationAttrs.pShaderSourceStreamFactory = pShaderSourceFactory; - CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - CreationAttrs.UseCombinedTextureSamplers = true; - - RefCntAutoPtr<Diligent::IShader> pVS, pHS, pDS, pPS; - { - CreationAttrs.FilePath = "Shaders\\TessTestQuadDX.vsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - pDevice->CreateShader( CreationAttrs, &pVS ); - VERIFY_EXPR(pVS); - } - - { - CreationAttrs.FilePath = "Shaders\\TessTestQuadDX.hsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_HULL; - pDevice->CreateShader( CreationAttrs, &pHS ); - VERIFY_EXPR(pHS); - } - - { - CreationAttrs.FilePath = "Shaders\\TessTestQuadDX.dsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_DOMAIN; - pDevice->CreateShader( CreationAttrs, &pDS ); - VERIFY_EXPR(pDS); - } - - { - CreationAttrs.FilePath = "Shaders\\GSTestDX.psh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - pDevice->CreateShader( CreationAttrs, &pPS ); - VERIFY_EXPR(pPS); - } - - PipelineStateDesc PSODesc; - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False; - PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_NONE; - PSODesc.GraphicsPipeline.RasterizerDesc.FillMode = FILL_MODE_WIREFRAME; - PSODesc.GraphicsPipeline.BlendDesc.IndependentBlendEnable = False; - PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].BlendEnable = False; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = pSwapChain->GetDesc().ColorBufferFormat; - PSODesc.GraphicsPipeline.DSVFormat = pSwapChain->GetDesc().DepthBufferFormat; - PSODesc.GraphicsPipeline.pPS = pPS; - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pHS = pHS; - PSODesc.GraphicsPipeline.pDS = pDS; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST; - - pDevice->CreatePipelineState( PSODesc, &m_pQuadPSO ); - - - { - pVS.Release(); - CreationAttrs.FilePath = "Shaders\\TessTestTriDX.vsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - pDevice->CreateShader( CreationAttrs, &pVS ); - VERIFY_EXPR(pVS); - } - - { - pHS.Release(); - CreationAttrs.FilePath = "Shaders\\TessTestTriDX.hsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_HULL; - pDevice->CreateShader( CreationAttrs, &pHS ); - VERIFY_EXPR(pHS); - } - - { - pDS.Release(); - CreationAttrs.FilePath = "Shaders\\TessTestTriDX.dsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_DOMAIN; - pDevice->CreateShader( CreationAttrs, &pDS ); - VERIFY_EXPR(pDS); - } - - PSODesc.GraphicsPipeline.pPS = pPS; - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pHS = pHS; - PSODesc.GraphicsPipeline.pDS = pDS; - - pDevice->CreatePipelineState( PSODesc, &m_pTriPSO ); -} - -void TestTessellation::Draw() -{ - if(!m_pDeviceContext) - return; - - m_pDeviceContext->SetPipelineState(m_pQuadPSO); - m_pDeviceContext->CommitShaderResources(nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - // Draw 2 quad patches - Diligent::DrawAttribs DrawAttrs(2, DRAW_FLAG_VERIFY_ALL); - m_pDeviceContext->Draw(DrawAttrs); - - m_pDeviceContext->SetPipelineState(m_pTriPSO); - m_pDeviceContext->CommitShaderResources(nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - DrawAttrs.NumVertices = 1; // Draw 1 tri patch - m_pDeviceContext->Draw(DrawAttrs); - - SetStatus(TestResult::Succeeded); -} diff --git a/Tests/TestApp/src/TestTexturing.cpp b/Tests/TestApp/src/TestTexturing.cpp deleted file mode 100644 index 2c1d0a1..0000000 --- a/Tests/TestApp/src/TestTexturing.cpp +++ /dev/null @@ -1,316 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "pch.h" -#include <math.h> -#include "TestTexturing.h" -#include "GraphicsUtilities.h" -#include "ShaderMacroHelper.h" - -using namespace Diligent; - -TestTexturing::TestTexturing() : - UnitTestBase("Texturing test"), - m_iTestTexWidth(512), - m_iTestTexHeight(512), - m_iMipLevels(8), - m_TextureFormat(TEX_FORMAT_UNKNOWN) -{ -} - -void TestTexturing::GenerateTextureData(IRenderDevice *pRenderDevice, std::vector<Uint8> &Data, std::vector<TextureSubResData> &SubResouces, const TextureDesc &TexDesc, const float *ColorOffset) -{ - Data.clear(); - Uint32 CurrLevelOffset = 0; - std::vector<Uint32> LevelDataOffsets(TexDesc.MipLevels); - SubResouces.resize(TexDesc.MipLevels); - - auto PixelFormatAttribs = pRenderDevice->GetTextureFormatInfoExt(TexDesc.Format); - auto PixelSize = Uint32{PixelFormatAttribs.ComponentSize} * Uint32{PixelFormatAttribs.NumComponents}; - - for(Uint32 Level = 0; Level < TexDesc.MipLevels; ++Level) - { - Uint32 MipWidth = TexDesc.Width >> Level; - Uint32 MipHeight = TexDesc.Height >> Level; - auto Stride = (MipWidth + 64) * PixelSize; - - Data.resize(Data.size() + size_t{Stride} * size_t{MipHeight}); - auto *pCurrLevelPtr = &Data[CurrLevelOffset]; - LevelDataOffsets[Level] = CurrLevelOffset; - SubResouces[Level].Stride = Stride; - for(Uint32 j=0; j<MipHeight; ++j) - for(Uint32 i=0; i<MipWidth; ++i) - { - float Color[4] = - { - (float)i/(float)MipWidth * 1.5f + (ColorOffset ? ColorOffset[0] : 0.f), - (float)j/(float)MipHeight * 1.7f+ (ColorOffset ? ColorOffset[1] : 0.f), - (float)j/(float)MipHeight / 1.3f + (float)i/(float)MipWidth/1.1f + (ColorOffset ? ColorOffset[2] : 0.f), - 1.f + (ColorOffset ? ColorOffset[3] : 0.f) - }; - for(Uint32 iCmp = 0; iCmp < PixelFormatAttribs.NumComponents; ++iCmp) - { - float fCurrCmpCol = Color[iCmp]; - fCurrCmpCol = fCurrCmpCol - floor(fCurrCmpCol); - void *pDstCmp = pCurrLevelPtr + (i*size_t{PixelSize} + iCmp * size_t{PixelFormatAttribs.ComponentSize} + j*size_t{Stride}); - switch(PixelFormatAttribs.ComponentType) - { - case COMPONENT_TYPE_FLOAT: - *((float*)pDstCmp) = fCurrCmpCol; - break; - - case COMPONENT_TYPE_SNORM: - if( PixelFormatAttribs.ComponentSize == 1 ) - *((Int8*)pDstCmp) = (Int8) std::min( std::max(fCurrCmpCol*127.f, -127.f), 127.f ); - else if( PixelFormatAttribs.ComponentSize == 2 ) - *((Int16*)pDstCmp) = (Int16) std::min( std::max(fCurrCmpCol*32767.f, -32767.f), 32767.f ); - else - assert(false); - break; - - case COMPONENT_TYPE_UNORM_SRGB: - case COMPONENT_TYPE_UNORM: - if( PixelFormatAttribs.ComponentSize == 1 ) - *((Uint8*)pDstCmp) = (Uint8) std::min( std::max(fCurrCmpCol*255,0.f), 255.f ); - else if( PixelFormatAttribs.ComponentSize == 2 ) - *((Uint16*)pDstCmp) = (Uint16) std::min( std::max(fCurrCmpCol*65535.f,0.f), 65535.f ); - else - assert(false); - break; - - case COMPONENT_TYPE_SINT: - if( PixelFormatAttribs.ComponentSize == 1 ) - *((Int8*)pDstCmp) = (Int8) std::min( std::max(fCurrCmpCol*127.f, -127.f), 127.f ); - else if( PixelFormatAttribs.ComponentSize == 2 ) - *((Int16*)pDstCmp) = (Int16) std::min( std::max(fCurrCmpCol*127.f, -127.f), 127.f ); - else - assert(false); - break; - - case COMPONENT_TYPE_UINT: - if( PixelFormatAttribs.ComponentSize == 1 ) - *((Uint8*)pDstCmp) = (Uint8) std::min( std::max(fCurrCmpCol*255,0.f), 255.f ); - else if( PixelFormatAttribs.ComponentSize == 2 ) - *((Uint16*)pDstCmp) = (Uint16) std::min( std::max(fCurrCmpCol*255,0.f), 255.f ); - else - assert(false); - break; - - default: assert("Unsupport component type" && false); - } - } - } - CurrLevelOffset += Stride * MipHeight; - } - for(Uint32 Level = 0; Level < TexDesc.MipLevels; ++Level) - { - SubResouces[Level].pData = Data.data() + LevelDataOffsets[Level]; - } -} - - -void TestTexturing::Init( IRenderDevice *pDevice, IDeviceContext *pDeviceContext, ISwapChain *pSwapChain, TEXTURE_FORMAT TexFormat, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent ) -{ - m_pRenderDevice = pDevice; - m_TextureFormat = TexFormat; - m_pDeviceContext = pDeviceContext; - auto DevType = m_pRenderDevice->GetDeviceCaps().DevType; - bool bUseGLSL = DevType == DeviceType::OpenGL || DevType == DeviceType::OpenGLES || DevType == DeviceType::Vulkan; - - float Vertices[] = - { - 0, 0, 0, 0,1, - 0, 1, 0, 0,0, - 1, 0, 0, 1,1, - 1, 1, 0, 1,0 - }; - for(int v=0; v < 4; ++v) - { - Vertices[v*5+0] = Vertices[v*5+0] * fXExtent + fMinXCoord; - Vertices[v*5+1] = Vertices[v*5+1] * fYExtent + fMinYCoord; - } - - { - Diligent::BufferDesc BuffDesc; - BuffDesc.uiSizeInBytes = sizeof(Vertices); - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - BuffDesc.Usage = USAGE_STATIC; - Diligent::BufferData BuffData; - BuffData.pData = Vertices; - BuffData.DataSize = BuffDesc.uiSizeInBytes; - m_pRenderDevice->CreateBuffer(BuffDesc, &BuffData, &m_pVertexBuff); - } - - auto PixelFormatAttribs = m_pRenderDevice->GetTextureFormatInfoExt(m_TextureFormat); - - ShaderCreateInfo CreationAttrs; - RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory; - pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("Shaders", &pShaderSourceFactory); - CreationAttrs.pShaderSourceStreamFactory = pShaderSourceFactory; - CreationAttrs.UseCombinedTextureSamplers = true; - - RefCntAutoPtr<Diligent::IShader> pVS, pPS; - { - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\TextureTestGL.vsh" : "Shaders\\TextureTestDX.vsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - m_pRenderDevice->CreateShader( CreationAttrs, &pVS ); - } - - bool bIsIntTexture = false; - { - ShaderMacroHelper Macros; - if (PixelFormatAttribs.ComponentType == COMPONENT_TYPE_UINT || - PixelFormatAttribs.ComponentType == COMPONENT_TYPE_SINT) - { - if (bUseGLSL) - { - CreationAttrs.FilePath = "Shaders\\TextureIntTestGL.psh"; - Macros.AddShaderMacro("SAMPLER_TYPE", PixelFormatAttribs.ComponentType == COMPONENT_TYPE_UINT ? "usampler2D" : "isampler2D"); - } - else - { - CreationAttrs.FilePath = "Shaders\\TextureIntTestDX.psh"; - Macros.AddShaderMacro("DATA_TYPE", PixelFormatAttribs.ComponentType == COMPONENT_TYPE_UINT ? "uint4" : "int4"); - } - - bIsIntTexture = true; - } - else - { - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\TextureTestGL.psh" : "Shaders\\TextureTestDX.psh"; - bIsIntTexture = false; - } - CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - CreationAttrs.Macros = Macros; - m_pRenderDevice->CreateShader( CreationAttrs, &pPS ); - } - - { - SamplerDesc SamplerDesc; - // On Intel HW, only point filtering sampler correctly works with an integer texture. - // If the sampler defines linear filtering, the texture is not properly bound to the - // sampler unit and zero is always returned. - // Note that on NVidia HW this works fine. - auto FilterType = bIsIntTexture ? FILTER_TYPE_POINT : FILTER_TYPE_LINEAR; - SamplerDesc.MinFilter = FilterType; - SamplerDesc.MagFilter = FilterType; - SamplerDesc.MipFilter = FilterType; - m_pRenderDevice->CreateSampler( SamplerDesc, &m_pSampler ); - } - - { - TextureDesc TexDesc; - TexDesc.Type = RESOURCE_DIM_TEX_2D; - TexDesc.Width = m_iTestTexWidth; - TexDesc.Height = m_iTestTexHeight; - TexDesc.MipLevels = m_iMipLevels; - TexDesc.Usage = USAGE_STATIC; - TexDesc.Format = m_TextureFormat; - TexDesc.BindFlags = BIND_SHADER_RESOURCE; - TexDesc.Name = "Test Texture"; - - std::vector<Uint8> Data; - std::vector<TextureSubResData> SubResouces; - GenerateTextureData(m_pRenderDevice, Data, SubResouces, TexDesc); - TextureData TexData; - TexData.pSubResources = SubResouces.data(); - TexData.NumSubresources = (Uint32)SubResouces.size(); - - m_pRenderDevice->CreateTexture( TexDesc, &TexData, &m_pTexture ); - } - - { - RefCntAutoPtr<ITextureView> pDefaultSRV; - TextureViewDesc ViewDesc; - ViewDesc.ViewType = TEXTURE_VIEW_SHADER_RESOURCE; - ViewDesc.NumMipLevels = TextureViewDesc::RemainingMipLevels; - ViewDesc.NumArraySlices = TextureViewDesc::RemainingArraySlices; - m_pTexture->CreateView( ViewDesc, &pDefaultSRV ); - pDefaultSRV->SetSampler( m_pSampler ); - ResourceMappingEntry Entries[] = { { "g_tex2DTest", pDefaultSRV }, {nullptr, nullptr} }; - ResourceMappingDesc ResourceMapping; - ResourceMapping.pEntries = Entries; - m_pRenderDevice->CreateResourceMapping( ResourceMapping, &m_pResourceMapping ); - } - PipelineStateDesc PSODesc; - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False; - PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_NONE; - PSODesc.GraphicsPipeline.BlendDesc.IndependentBlendEnable = False; - PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].BlendEnable = False; - PSODesc.GraphicsPipeline.RTVFormats[0] = pSwapChain->GetDesc().ColorBufferFormat; - PSODesc.GraphicsPipeline.DSVFormat = pSwapChain->GetDesc().DepthBufferFormat; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pPS = pPS; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; - - LayoutElement Elems[] = - { - LayoutElement{ 0, 0, 3, Diligent::VT_FLOAT32, false, 0 }, - LayoutElement{ 1, 0, 2, Diligent::VT_FLOAT32, false, sizeof( float ) * 3 } - }; - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = Elems; - PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof( Elems ); - - StaticSamplerDesc StaticSampler; - // On Intel HW, only point filtering sampler correctly works with an integer texture. - // If the sampler defines linear filtering, the texture is not properly bound to the - // sampler unit and zero is always returned. - // Note that on NVidia HW this works fine. - auto FilterType = bIsIntTexture ? FILTER_TYPE_POINT : FILTER_TYPE_LINEAR; - StaticSampler.Desc.MinFilter = FilterType; - StaticSampler.Desc.MagFilter = FilterType; - StaticSampler.Desc.MipFilter = FilterType; - StaticSampler.ShaderStages = SHADER_TYPE_PIXEL; - StaticSampler.SamplerOrTextureName = "g_tex2DTest"; - PSODesc.ResourceLayout.NumStaticSamplers = !(bIsIntTexture && pDevice->GetDeviceCaps().IsD3DDevice()) ? 1 : 0; - PSODesc.ResourceLayout.StaticSamplers = &StaticSampler; - - pDevice->CreatePipelineState(PSODesc, &m_pPSO); - - m_pPSO->BindStaticResources(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, m_pResourceMapping, 0); - - m_pPSO->CreateShaderResourceBinding(&m_pSRB, true); - - auto *FmtName = pDevice->GetTextureFormatInfo(TexFormat).Name; - m_TestName.append(" ("); - m_TestName.append(FmtName); - m_TestName.append(")"); -} - -void TestTexturing::Draw() -{ - m_pDeviceContext->SetPipelineState(m_pPSO); - m_pDeviceContext->TransitionShaderResources(m_pPSO, m_pSRB); - m_pDeviceContext->CommitShaderResources(m_pSRB, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - - IBuffer *pBuffs[] = {m_pVertexBuff}; - Uint32 Offsets[] = {0}; - m_pDeviceContext->SetVertexBuffers( 0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET ); - - // Draw quad - Diligent::DrawAttribs DrawAttrs(4, DRAW_FLAG_VERIFY_ALL); - m_pDeviceContext->Draw( DrawAttrs ); - - SetStatus(TestResult::Succeeded); -} diff --git a/Tests/TestApp/src/TestVPAndSR.cpp b/Tests/TestApp/src/TestVPAndSR.cpp deleted file mode 100644 index 8cd9f86..0000000 --- a/Tests/TestApp/src/TestVPAndSR.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "pch.h" -#include "TestVPAndSR.h" -#include "GraphicsUtilities.h" - -using namespace Diligent; - -TestVPAndSR::TestVPAndSR(IRenderDevice *pDevice, IDeviceContext *pContext ) : - UnitTestBase("Viewport and scissor rect test") -{ - m_pRenderDevice = pDevice; - m_pDeviceContext = pContext; -#if 0 - m_pRenderScript = CreateRenderScriptFromFile( "VPAndSRTest.lua", pDevice, pContext, []( ScriptParser *pScriptParser ) - { - Viewport VP(16.5, 24.25, 156.125, 381.625, 0.25, 0.75); - pScriptParser->SetGlobalVariable( "TestGlobalVP", VP ); - - Rect SR(10, 30, 200, 300); - pScriptParser->SetGlobalVariable( "TestGlobalSR", SR ); - } ); - - m_pRenderScript->Run( m_pDeviceContext, "SetViewports" ); - m_pRenderScript->Run( m_pDeviceContext, "SetScissorRects" ); -#endif - SetStatus(TestResult::Succeeded); -} diff --git a/Tests/TestApp/src/UWP/TestAppUWP.cpp b/Tests/TestApp/src/UWP/TestAppUWP.cpp deleted file mode 100644 index 3c8fa2e..0000000 --- a/Tests/TestApp/src/UWP/TestAppUWP.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. -* -* In no event and under no legal theory, whether in tort (including negligence), -* contract, or otherwise, unless required by applicable law (such as deliberate -* and grossly negligent acts) or agreed to in writing, shall any Contributor be -* liable for any damages, including any direct, indirect, special, incidental, -* or consequential damages of any character arising as a result of this License or -* out of the use or inability to use the software (including but not limited to damages -* for loss of goodwill, work stoppage, computer failure or malfunction, or any and -* all other commercial damages or losses), even if such Contributor has been advised -* of the possibility of such damages. -*/ - -#include "TestApp.h" -#include "RenderDeviceD3D12.h" -#include "RenderDeviceD3D11.h" -#include "SwapChainD3D12.h" -#include "SwapChainD3D11.h" -#include "EngineFactoryD3D11.h" -#include "EngineFactoryD3D12.h" - -namespace Diligent -{ - -class TestAppUWP final : public TestApp -{ -public: - TestAppUWP() - { - m_DeviceType = DeviceType::D3D12; - } - - virtual void OnWindowSizeChanged()override final - { - InitWindowSizeDependentResources(); - } - - virtual void Render()override - { - // Don't try to render anything before the first Update. - if (m_timer.GetFrameCount() == 0) - { - return; - } - TestApp::Render(); - m_bFrameReady = true; - } - - // Notifies the app that it is being suspended. - virtual void OnSuspending()override final - { - // TODO: Replace this with your app's suspending logic. - - // Process lifetime management may terminate suspended apps at any time, so it is - // good practice to save any state that will allow the app to restart where it left off. - - //m_sceneRenderer->SaveState(); - - // If your application uses video memory allocations that are easy to re-create, - // consider releasing that memory to make it available to other applications. - } - - // Notifes the app that it is no longer suspended. - virtual void OnResuming()override final - { - // TODO: Replace this with your app's resuming logic. - } - - // Notifies renderers that device resources need to be released. - virtual void OnDeviceRemoved()override final - { - // TODO: Save any necessary application or renderer state and release the renderer - // and its resources which are no longer valid. - //m_sceneRenderer->SaveState(); - } - - virtual void Present()override - { - m_pSwapChain->Present(); - - //// If the device was removed either by a disconnection or a driver upgrade, we - //// must recreate all device resources. - //if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) - //{ - // m_deviceRemoved = true; - //} - //else - //{ - // DX::ThrowIfFailed(hr); - //} - } - - virtual std::shared_ptr<DX::DeviceResources> InitDeviceResources()override - { - InitializeDiligentEngine(nullptr); - - ID3D12Device *pd3d12Device = nullptr; - ID3D11Device *pd3d11Device = nullptr; - if (m_DeviceType == DeviceType::D3D12) - { - // Store pointers to the Direct3D 11.1 API device and immediate context. - RefCntAutoPtr<IRenderDeviceD3D12> pRenderDeviceD3D12(m_pDevice, IID_RenderDeviceD3D12); - pd3d12Device = pRenderDeviceD3D12->GetD3D12Device(); - } - else if (m_DeviceType == DeviceType::D3D11) - { - RefCntAutoPtr<IRenderDeviceD3D11> pRenderDeviceD3D11(m_pDevice, IID_RenderDeviceD3D11); - pd3d11Device = pRenderDeviceD3D11->GetD3D11Device(); - } - else - { - UNEXPECTED("Unexpected device type"); - } - m_DeviceResources = std::make_shared<DX::DeviceResources>(pd3d11Device, pd3d12Device); - - return m_DeviceResources; - } - - virtual void InitWindowSizeDependentResources()override - { - m_DeviceResources->UpdateRenderTargetSize(); - auto backBufferWidth = m_DeviceResources->GetBackBufferWidth(); - auto backBufferHeight = m_DeviceResources->GetBackBufferHeight(); - - if (m_swapChain != nullptr) - { - m_swapChain.Reset(); - - // If the swap chain already exists, resize it. - m_pSwapChain->Resize(backBufferWidth, backBufferHeight); - - #if 0 - if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) - { - // If the device was removed for any reason, a new device and swap chain will need to be created. - m_deviceRemoved = true; - - // Do not continue execution of this method. DeviceResources will be destroyed and re-created. - return; - } - else - { - DX::ThrowIfFailed(hr); - } - #endif - } - else - { - //DXGI_SCALING scaling = DisplayMetrics::SupportHighResolutions ? DXGI_SCALING_NONE : DXGI_SCALING_STRETCH; - SwapChainDesc SCDesc; - SCDesc.Width = backBufferWidth; - SCDesc.Height = backBufferHeight; - SCDesc.ColorBufferFormat = TEX_FORMAT_RGBA8_UNORM_SRGB; - SCDesc.DepthBufferFormat = TEX_FORMAT_D32_FLOAT; - auto window = m_DeviceResources->GetWindow(); - IDXGISwapChain3 *pDXGISwapChain3 = nullptr; - if (m_DeviceType == DeviceType::D3D12) - { - GetEngineFactoryD3D12()->CreateSwapChainD3D12(m_pDevice, m_pImmediateContext, SCDesc, FullScreenModeDesc{}, reinterpret_cast<IUnknown*>(window), &m_pSwapChain); - } - else if (m_DeviceType == DeviceType::D3D11) - { - GetEngineFactoryD3D11()->CreateSwapChainD3D11(m_pDevice, m_pImmediateContext, SCDesc, FullScreenModeDesc{}, reinterpret_cast<IUnknown*>(window), &m_pSwapChain); - } - else - UNEXPECTED("Unexpected device type"); - } - - IDXGISwapChain3 *pDXGISwapChain3 = nullptr; - if (m_DeviceType == DeviceType::D3D12) - { - RefCntAutoPtr<ISwapChainD3D12> pSwapChainD3D12(m_pSwapChain, IID_SwapChainD3D12); - pSwapChainD3D12->GetDXGISwapChain()->QueryInterface(__uuidof(pDXGISwapChain3), reinterpret_cast<void**>(&pDXGISwapChain3)); - } - else if (m_DeviceType == DeviceType::D3D11) - { - RefCntAutoPtr<ISwapChainD3D11> pSwapChainD3D11(m_pSwapChain, IID_SwapChainD3D11); - pSwapChainD3D11->GetDXGISwapChain()->QueryInterface(__uuidof(pDXGISwapChain3), reinterpret_cast<void**>(&pDXGISwapChain3)); - } - else - UNEXPECTED("Unexpected device type"); - m_swapChain.Attach(pDXGISwapChain3); - - m_DeviceResources->SetSwapChainRotation(m_swapChain.Get()); - } - - virtual void CreateRenderers()override - { - InitializeRenderers(); - } - -private: - Microsoft::WRL::ComPtr<IDXGISwapChain3> m_swapChain; -}; - - -NativeAppBase* CreateApplication() -{ - return new TestAppUWP; -} - -} diff --git a/Tests/TestApp/src/UnitTestBase.cpp b/Tests/TestApp/src/UnitTestBase.cpp deleted file mode 100644 index 5421c7a..0000000 --- a/Tests/TestApp/src/UnitTestBase.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include <iomanip> -#include <ios> - -#include "pch.h" -#include "UnitTestBase.h" -#include "Errors.h" - -using namespace Diligent; - -int UnitTestBase::m_TotalTests = 0; -size_t UnitTestBase::m_MaxNameLen = 0; - -UnitTestBase::UnitTestBase(const char *Name) : - m_TestName(Name) -{ - m_MaxNameLen = std::max(m_MaxNameLen, m_TestName.length()); - m_TestNum = ++m_TotalTests; - LOG_INFO_MESSAGE("Created test ", m_TestNum, ": ", Name); -} - -UnitTestBase::~UnitTestBase() -{ - const char* TestResltStr[] = - { - "UNKNOWN", - "SKIPPED", - "FAILED", - "SUCCEEDED" - }; - LOG_INFO_MESSAGE("Test ", std::setw(2), m_TestNum, "/", m_TotalTests, " - ", std::setw(m_MaxNameLen), std::left, m_TestName, " : ", - TestResltStr[static_cast<int>(m_TestResult)], ". ", m_TestResultInfo); -} diff --git a/Tests/TestApp/src/Win32/TestAppWin32.cpp b/Tests/TestApp/src/Win32/TestAppWin32.cpp deleted file mode 100644 index 5365123..0000000 --- a/Tests/TestApp/src/Win32/TestAppWin32.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. -* -* In no event and under no legal theory, whether in tort (including negligence), -* contract, or otherwise, unless required by applicable law (such as deliberate -* and grossly negligent acts) or agreed to in writing, shall any Contributor be -* liable for any damages, including any direct, indirect, special, incidental, -* or consequential damages of any character arising as a result of this License or -* out of the use or inability to use the software (including but not limited to damages -* for loss of goodwill, work stoppage, computer failure or malfunction, or any and -* all other commercial damages or losses), even if such Contributor has been advised -* of the possibility of such damages. -*/ - -#include "TestApp.h" - -namespace Diligent -{ - -class TestAppWin32 final : public TestApp -{ -public: - virtual void OnWindowCreated(HWND hWnd, LONG WindowWidth, LONG WindowHeight)override final - { - InitializeDiligentEngine(hWnd); - InitializeRenderers(); - } -}; - -NativeAppBase* CreateApplication() -{ - return new TestAppWin32; -} - -} diff --git a/Tests/TestApp/src/pch.cpp b/Tests/TestApp/src/pch.cpp deleted file mode 100644 index ee46a4a..0000000 --- a/Tests/TestApp/src/pch.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -// stdafx.cpp : source file that includes just the standard includes -// EngineSandbox.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "pch.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file |
