and though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here

You need to sign in or sign up before continuing.
...
 
Commits (11)
......@@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.10.2)
project(Tests)
add_subdirectory(DisplayModeSelectionTest)
add_subdirectory(ClearScreenTest)
#add_subdirectory(DefaultPipelineTest)
add_subdirectory(TextureLoadingTest)
add_subdirectory(GTAModelLoadingTest)
add_subdirectory(InterprocessEngineTest)
cmake_minimum_required(VERSION 3.12)
set(CMAKE_CXX_STANDARD 20)
project(ClearScreenTest)
......@@ -14,8 +13,10 @@ include(../../rw_rh_engine_lib/install_rw_library.cmake)
add_executable(ClearScreenTest WIN32 ${SOURCES})
target_link_libraries(ClearScreenTest ${DEPENDENCY_LIB_LIST} rh_engine_lib)
install_rw_library()
#set_property(TARGET ClearScreenTest PROPERTY
# MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 20
)
add_custom_command(TARGET ${PROJECT_NAME}
COMMAND ${CMAKE_COMMAND} -E copy
......
cmake_minimum_required(VERSION 3.12)
set(CMAKE_CXX_STANDARD 20)
project(DefaultPipelineTest)
set(SOURCES
SimpleSample.cpp
forward_pbr_pipeline.cpp
clump_read_funcs.cpp
rp_atomic_funcs.cpp
rp_clump_funcs.cpp
rp_geometry_binmesh_read_funcs.cpp
rp_geometry_funcs.cpp
rp_geometry_read_funcs.cpp
rp_material_funcs.cpp
rp_material_read_funcs.cpp
rp_matlist_funcs.cpp
rp_matlist_read_funcs.cpp
rw_frame_funcs.cpp
rw_framelist_read_funcs.cpp
rw_geometrylist_read_funcs.cpp
main.cpp
)
include_directories(../../RHEngineLib ${DEPENDENCY_INCLUDE_LIST})
add_executable(DefaultPipelineTest WIN32 ${SOURCES})
target_link_libraries(DefaultPipelineTest ${DEPENDENCY_LIB_LIST} RHEngineLib)
# Copy shaders to build destination
add_custom_command(TARGET DefaultPipelineTest PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/shaders $<TARGET_FILE_DIR:DefaultPipelineTest>/shaders)
add_custom_command(TARGET DefaultPipelineTest
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:DefaultPipelineTest>
"C:/Users/peter/Documents/Visual Studio 2015/Projects/gtaRenderHook/Win32Build/Release")
#
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{afe1c4e8-63a2-465c-a690-b588c37e9084}</ProjectGuid>
<RootNamespace>DefaultPipelineTest</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="DependencyPaths.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="DependencyPaths.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="DependencyPaths.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="DependencyPaths.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(RH_ENGINE);$(PLUGIN_SDK_DIR)\shared;$(PLUGIN_SDK_DIR)\plugin_sa;$(VULKAN_SDK)\Include;$(IncludePath)</IncludePath>
<LibraryPath>$(RH_ENGINE)\$(Platform)Build\$(Configuration)\;$(PLUGIN_SDK_DIR)\output\lib;$(VULKAN_SDK)\Lib32\;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)$(Platform)Build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(RH_ENGINE);$(PLUGIN_SDK_DIR)\shared;$(PLUGIN_SDK_DIR)\plugin_sa;$(VULKAN_SDK)\Include;$(IncludePath)</IncludePath>
<LibraryPath>$(RH_ENGINE)\$(Platform)Build\$(Configuration)\;$(PLUGIN_SDK_DIR)\output\lib;$(VULKAN_SDK)\Lib\;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)$(Platform)Build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(RH_ENGINE);$(PLUGIN_SDK_DIR)\shared;$(PLUGIN_SDK_DIR)\plugin_sa;$(VULKAN_SDK)\Include;C:\Users\peter\Source\Repos\GSL\include;$(IncludePath)</IncludePath>
<LibraryPath>$(RH_ENGINE)\$(Platform)Build\$(Configuration)\;$(PLUGIN_SDK_DIR)\output\lib;$(VULKAN_SDK)\Lib32\;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)$(Platform)Build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>$(RH_ENGINE);$(PLUGIN_SDK_DIR)\shared;$(PLUGIN_SDK_DIR)\plugin_sa;$(VULKAN_SDK)\Include;$(IncludePath)</IncludePath>
<LibraryPath>$(RH_ENGINE)\$(Platform)Build\$(Configuration)\;$(PLUGIN_SDK_DIR)\output\lib;$(VULKAN_SDK)\Lib\;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)$(Platform)Build\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<BrowseInformation>true</BrowseInformation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalDependencies>vulkan-1.lib;dxgi.lib;d3d11.lib;d3dcompiler.lib;dinput8.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Bscmake>
<PreserveSbr>true</PreserveSbr>
</Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalDependencies>vulkan-1.lib;dxgi.lib;d3d11.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>vulkan-1.lib;dxgi.lib;d3d11.lib;d3dcompiler.lib;dinput8.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>vulkan-1.lib;dxgi.lib;d3d11.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="clump_read_funcs.cpp" />
<ClCompile Include="forward_pbr_pipeline.cpp" />
<ClCompile Include="rp_atomic_funcs.cpp" />
<ClCompile Include="rp_clump_funcs.cpp" />
<ClCompile Include="rp_geometry_binmesh_read_funcs.cpp" />
<ClCompile Include="rp_geometry_funcs.cpp" />
<ClCompile Include="rp_geometry_read_funcs.cpp" />
<ClCompile Include="rp_material_funcs.cpp" />
<ClCompile Include="rp_material_read_funcs.cpp" />
<ClCompile Include="rp_matlist_funcs.cpp" />
<ClCompile Include="rp_matlist_read_funcs.cpp" />
<ClCompile Include="rw_framelist_read_funcs.cpp" />
<ClCompile Include="rw_frame_funcs.cpp" />
<ClCompile Include="rw_geometrylist_read_funcs.cpp" />
<ClCompile Include="SimpleSample.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="clump_read_funcs.h" />
<ClInclude Include="forward_pbr_pipeline.h" />
<ClInclude Include="gta_map_loader.h" />
<ClInclude Include="rh_pipeline_core.h" />
<ClInclude Include="rp_atomic_funcs.h" />
<ClInclude Include="rp_clump_funcs.h" />
<ClInclude Include="rp_geometry_binmesh_read_funcs.h" />
<ClInclude Include="rp_geometry_funcs.h" />
<ClInclude Include="rp_geometry_read_funcs.h" />
<ClInclude Include="rp_material_funcs.h" />
<ClInclude Include="rp_material_read_funcs.h" />
<ClInclude Include="rp_matlist_funcs.h" />
<ClInclude Include="rp_matlist_read_funcs.h" />
<ClInclude Include="rw_framelist_read_funcs.h" />
<ClInclude Include="rw_frame_funcs.h" />
<ClInclude Include="rw_geometrylist_read_funcs.h" />
<ClInclude Include="rw_pipeline_wrapper.h" />
<ClInclude Include="SimpleSample.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\RHEngineLib\RHEngineLib.vcxproj">
<Project>{62d003a2-7deb-47c6-ba8f-6754cbaed312}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="Shaders\d3d11\engine\Im2D.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0</ShaderModel>
<FileType>Text</FileType>
<DeploymentContent>true</DeploymentContent>
<TreatOutputAsContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</TreatOutputAsContent>
<TreatOutputAsContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</TreatOutputAsContent>
<TreatOutputAsContent Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</TreatOutputAsContent>
<TreatOutputAsContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</TreatOutputAsContent>
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)\shaders\d3d11\engine</DestinationFolders>
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)\shaders\d3d11\engine</DestinationFolders>
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\shaders\d3d11\engine</DestinationFolders>
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\shaders\d3d11\engine</DestinationFolders>
</CopyFileToFolders>
</ItemGroup>
<ItemGroup>
<None Include="DependencyPaths.props" />
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="Shaders\d3d11\simple_pipeline.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
<FileType>Document</FileType>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
<DestinationFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(RelativeDir)%(Filename)%(Extension)</DestinationFileName>
<DestinationFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(RelativeDir)%(Filename)%(Extension)</DestinationFileName>
</CopyFileToFolders>
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="Shaders\d3d11\forward_pbr_pipeline.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
<FileType>Document</FileType>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
<DestinationFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(RelativeDir)%(Filename)%(Extension)</DestinationFileName>
<DestinationFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(RelativeDir)%(Filename)%(Extension)</DestinationFileName>
<DestinationFileName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(RelativeDir)%(Filename)%(Extension)</DestinationFileName>
<DestinationFileName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(RelativeDir)%(Filename)%(Extension)</DestinationFileName>
</CopyFileToFolders>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Исходные файлы">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Файлы заголовков">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Файлы ресурсов">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Shaders">
<UniqueIdentifier>{bb1e30d1-d94c-4c18-9c50-4c934dfa322d}</UniqueIdentifier>
</Filter>
<Filter Include="Shaders\d3d11">
<UniqueIdentifier>{01f3af60-6555-43c0-9f46-d227f49293b7}</UniqueIdentifier>
</Filter>
<Filter Include="Shaders\d3d11\engine">
<UniqueIdentifier>{fe7f1a90-f7f3-4c13-aa58-69b39c41f347}</UniqueIdentifier>
</Filter>
<Filter Include="Файлы заголовков\rw_funcs">
<UniqueIdentifier>{c3525bd5-fe24-4ae4-9eba-9f3b5dba16ad}</UniqueIdentifier>
</Filter>
<Filter Include="Исходные файлы\rw_funcs">
<UniqueIdentifier>{c97f4b43-ca96-4162-81a1-b7732d7e62b9}</UniqueIdentifier>
</Filter>
<Filter Include="Исходные файлы\rw_io_funcs">
<UniqueIdentifier>{ebe3584e-7e81-4c3a-a99e-b1b542c6770b}</UniqueIdentifier>
</Filter>
<Filter Include="Файлы заголовков\rw_io_funcs">
<UniqueIdentifier>{db7e9abc-0714-40e0-978a-981f095ad893}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="SimpleSample.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="rp_atomic_funcs.cpp">
<Filter>Исходные файлы\rw_funcs</Filter>
</ClCompile>
<ClCompile Include="rp_clump_funcs.cpp">
<Filter>Исходные файлы\rw_funcs</Filter>
</ClCompile>
<ClCompile Include="rp_geometry_funcs.cpp">
<Filter>Исходные файлы\rw_funcs</Filter>
</ClCompile>
<ClCompile Include="rp_material_funcs.cpp">
<Filter>Исходные файлы\rw_funcs</Filter>
</ClCompile>
<ClCompile Include="rp_matlist_funcs.cpp">
<Filter>Исходные файлы\rw_funcs</Filter>
</ClCompile>
<ClCompile Include="rw_frame_funcs.cpp">
<Filter>Исходные файлы\rw_funcs</Filter>
</ClCompile>
<ClCompile Include="rp_geometry_binmesh_read_funcs.cpp">
<Filter>Исходные файлы\rw_io_funcs</Filter>
</ClCompile>
<ClCompile Include="rp_geometry_read_funcs.cpp">
<Filter>Исходные файлы\rw_io_funcs</Filter>
</ClCompile>
<ClCompile Include="rp_material_read_funcs.cpp">
<Filter>Исходные файлы\rw_io_funcs</Filter>
</ClCompile>
<ClCompile Include="rp_matlist_read_funcs.cpp">
<Filter>Исходные файлы\rw_io_funcs</Filter>
</ClCompile>
<ClCompile Include="rw_framelist_read_funcs.cpp">
<Filter>Исходные файлы\rw_io_funcs</Filter>
</ClCompile>
<ClCompile Include="rw_geometrylist_read_funcs.cpp">
<Filter>Исходные файлы\rw_io_funcs</Filter>
</ClCompile>
<ClCompile Include="clump_read_funcs.cpp">
<Filter>Исходные файлы\rw_io_funcs</Filter>
</ClCompile>
<ClCompile Include="forward_pbr_pipeline.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="SimpleSample.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="rp_atomic_funcs.h">
<Filter>Файлы заголовков\rw_funcs</Filter>
</ClInclude>
<ClInclude Include="rp_clump_funcs.h">
<Filter>Файлы заголовков\rw_funcs</Filter>
</ClInclude>
<ClInclude Include="rp_geometry_funcs.h">
<Filter>Файлы заголовков\rw_funcs</Filter>
</ClInclude>
<ClInclude Include="rp_material_funcs.h">
<Filter>Файлы заголовков\rw_funcs</Filter>
</ClInclude>
<ClInclude Include="rp_matlist_funcs.h">
<Filter>Файлы заголовков\rw_funcs</Filter>
</ClInclude>
<ClInclude Include="rw_frame_funcs.h">
<Filter>Файлы заголовков\rw_funcs</Filter>
</ClInclude>
<ClInclude Include="clump_read_funcs.h">
<Filter>Файлы заголовков\rw_io_funcs</Filter>
</ClInclude>
<ClInclude Include="rp_geometry_binmesh_read_funcs.h">
<Filter>Файлы заголовков\rw_io_funcs</Filter>
</ClInclude>
<ClInclude Include="rp_geometry_read_funcs.h">
<Filter>Файлы заголовков\rw_io_funcs</Filter>
</ClInclude>
<ClInclude Include="rp_material_read_funcs.h">
<Filter>Файлы заголовков\rw_io_funcs</Filter>
</ClInclude>
<ClInclude Include="rp_matlist_read_funcs.h">
<Filter>Файлы заголовков\rw_io_funcs</Filter>
</ClInclude>
<ClInclude Include="rw_framelist_read_funcs.h">
<Filter>Файлы заголовков\rw_io_funcs</Filter>
</ClInclude>
<ClInclude Include="rw_geometrylist_read_funcs.h">
<Filter>Файлы заголовков\rw_io_funcs</Filter>
</ClInclude>
<ClInclude Include="rw_pipeline_wrapper.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="rh_pipeline_core.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="gta_map_loader.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="forward_pbr_pipeline.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="DependencyPaths.props" />
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="Shaders\d3d11\engine\Im2D.hlsl">
<Filter>Shaders\d3d11\engine</Filter>
</CopyFileToFolders>
<CopyFileToFolders Include="Shaders\d3d11\simple_pipeline.hlsl">
<Filter>Shaders\d3d11</Filter>
</CopyFileToFolders>
<CopyFileToFolders Include="Shaders\d3d11\forward_pbr_pipeline.hlsl" />
</ItemGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros">
<RH_ENGINE>C:\Users\peter\Documents\Visual Studio 2015\Projects\gtaRenderHook\RHEngineLib</RH_ENGINE>
</PropertyGroup>
<PropertyGroup />
<ItemDefinitionGroup />
<ItemGroup>
<BuildMacro Include="RH_ENGINE">
<Value>$(RH_ENGINE)</Value>
</BuildMacro>
</ItemGroup>
</Project>
\ No newline at end of file
//--------------------------------------------------------------------------------------
// Bindings
//--------------------------------------------------------------------------------------
Texture2D t0 : register(t0);
SamplerState s0 : register(s0);
//--------------------------------------------------------------------------------------
// Structures
//--------------------------------------------------------------------------------------
struct VS_IM2D_IN
{
float4 vPosition : POSITION;
float4 cColor : COLOR;
float2 vTexCoord : TEXCOORD;
};
struct PS_IM2D_IN
{
float4 vPosition : SV_POSITION;
float4 cColor : COLOR;
float2 vTexCoord : TEXCOORD;
};
//--------------------------------------------------------------------------------------
// Vertex Shaders
//--------------------------------------------------------------------------------------
PS_IM2D_IN BaseVS(VS_IM2D_IN i)
{
PS_IM2D_IN o;
float fScreenWidth = 1280;
float fScreenHeight = 720;
o.vTexCoord = i.vTexCoord;
o.cColor = i.cColor.bgra;
o.vPosition = float4((i.vPosition.x) * 2 / fScreenWidth - 1.0f,
1.0f - (i.vPosition.y) * 2 / fScreenHeight,
i.vPosition.z, 1.0); // transform to screen space
return o;
}
//--------------------------------------------------------------------------------------
// Pixel Shaders
//--------------------------------------------------------------------------------------
float4 NoTexPS( PS_IM2D_IN i ) : SV_Target
{
float4 OutColor;
OutColor = i.cColor;
return OutColor;
}
float4 TexPS( PS_IM2D_IN i ) : SV_Target
{
float4 OutColor;
OutColor = t0.Sample( s0, i.vTexCoord );
//OutColor.a = 1;
return OutColor;
}
\ No newline at end of file
Texture2D t0 : register( t0 );
SamplerState s0 : register( s0 );
cbuffer SceneConstants : register( b0 )
{
float4x4 mView;
float4x4 mProjection;
float4x4 mViewProjection;
float4 vViewDir;
float4 vViewPos;
};
cbuffer ModelConstants : register( b1 )
{
float4x4 mWorld;
};
cbuffer MaterialConstants : register( b2 )
{
float4 MaterialColor;
float Roughness;
float Metallness;
float IOR;
float Emmisivness;
};
struct VS_MAIN_IN
{
float4 vPosition : POSITION;
float4 vColor : COLOR;
float2 vUV : TEXCOORD;
float3 vNormals : NORMAL;
};
struct PS_IN
{
float4 vPosition : SV_POSITION;
float4 vColor : COLOR;
float3 vNormals : NORMAL;
float3 vWorldPos : TEXCOORD0;
float2 vUV : TEXCOORD1;
};
PS_IN BaseVS( VS_MAIN_IN i )
{
PS_IN res;
float4 res_pos = mul( mWorld, float4( i.vPosition.xyz, 1 ) );
res.vWorldPos = res_pos;
res.vPosition = mul( mViewProjection, res_pos );
res.vColor = i.vColor;
res.vUV = i.vUV;
res.vNormals = mul( float4( i.vNormals.xyz, 1 ), mWorld ).xyz;
return res;
}
float4 NoTexPS( PS_IN i ) : SV_Target
{
return float4( i.vColor.rgb, 1.0f );
}
inline float LambertDiffuse( in float3 vNormal, in float3 vLightDir )
{
float fCosA = dot( vNormal, vLightDir ); // cosine of angle between normal and light vector
return max( fCosA, 0.0f );
}
const float PI = 3.14f;
const float EPS = 1e-10f;
inline float BlinnPhongNDF( in float3 halfDir, in float3 normal, in float roughnessSq )
{
float rsq = roughnessSq * roughnessSq + EPS;
float power = 2.0f / rsq - 2.0f;
return pow( max( dot( halfDir, normal ), 0.0f ), power ) /*/ ( rsq * PI )*/;
}
inline float BeckmannNDF( in float3 halfDir, in float3 normal, in float roughnessSq )
{
float rsq = roughnessSq * roughnessSq + EPS;
float power = 2.0f / rsq - 2.0f;
float alpha = max( dot( halfDir, normal ), 0.0f );
float alphaSq = alpha * alpha;
float denom = alphaSq * alphaSq * rsq * PI;
return exp( ( alphaSq - 1.0f ) / ( alphaSq * rsq ) ) /* denom*/;
}
float chiGGX( float v )
{
return v > 0 ? 1 : 0;
}
float GGX_NDF( in float3 halfDir, in float3 normal, in float roughnessSq )
{
float alpha = dot( halfDir, normal );
float alphaSq = alpha * alpha;
float TanNdotHSqr = ( 1 - alphaSq ) / alphaSq;
float denom = ( alphaSq * ( roughnessSq + TanNdotHSqr ) );
return ( 1.0 / 3.1415926535 ) * roughnessSq / ( denom * denom );
//float den = alphaSq * ( rsq * rsq - 1 ) + 1;
// return ( rsq * rsq ) / ( PI * den * den );
}
// normal distribution function,
// represents approximation of microfacet normal distribution over point on surface
float NDF( in float3 halfDir, in float3 normal, in float roughnessSq )
{
return GGX_NDF( halfDir, normal, roughnessSq );
}
float CookTorranceGSF( float NdotL, float NdotV,
float VdotH, float NdotH )
{
float Gs = min( 1.0, min( 2 * NdotH * NdotV / VdotH,
2 * NdotH * NdotL / VdotH ) );
return ( Gs );
}
float MixFunction( float i, float j, float x ) {
return j * x + i * ( 1.0 - x );
}
float SchlickFresnel( float i ) {
float x = clamp( 1.0 - i, 0.0, 1.0 );
float x2 = x * x;
return x2 * x2* x;
}
//normal incidence reflection calculation
float F0( float NdotL, float NdotV, float LdotH, float roughness ) {
float FresnelLight = SchlickFresnel( NdotL );
float FresnelView = SchlickFresnel( NdotV );
float FresnelDiffuse90 = 0.5 + 2.0 * LdotH * LdotH * roughness;
return MixFunction( 1, FresnelDiffuse90, FresnelLight )* MixFunction( 1, FresnelDiffuse90, FresnelView );
}
float4 TexPS( PS_IN i ) : SV_Target
{
float4 texColor = t0.Sample( s0, i.vUV ) * MaterialColor;
texColor.a *= i.vColor.a;
clip( texColor.a < 0.3 ? -1 : 1 );
float3 lightDir = normalize( float3( 0.5, 0.3, -1 ) );
float3 viewDir = normalize( i.vWorldPos - vViewPos );
float3 normalDir = normalize( i.vNormals );
float3 lighting = LambertDiffuse( i.vNormals, lightDir ).xxx;
float3 halfDir = normalize( lightDir + viewDir );
float NoV = max( dot( normalDir, viewDir ), 0.0f );
float NoL = max( dot( normalDir, lightDir ), 0.0f );
float VoH = max( dot( halfDir, viewDir ), 0.0f );
float NoH = max( dot( halfDir, normalDir ), 0.0f );
float LoH = max( dot( halfDir, lightDir ), 0.0f );
float roughness = saturate( texColor.x * 1.5f + 0.1f );
float ndf = NDF( halfDir, normalDir, roughness * roughness );
float geom = CookTorranceGSF( NoL, NoV, VoH, NoH );
float fresnel = SchlickFresnel( LoH );//F0( NoL, NoV, LoH, Roughness );
float denominator = max( 4 * NoL * NoV, 0.001f );
float specularBRDF = ( ndf * geom * fresnel ) / denominator;
float3 specularColor = lerp( float3( 1, 1, 1 ), texColor, Metallness );
float3 result = ( texColor * ( 1 - Metallness ) * (NoL + 0.2f) + specularColor * specularBRDF ) ;
return float4( result, min( max( texColor.a, specularBRDF ), 1 ) );//float4( * float4( lighting + 0.2f.xxx , 1 ) );
}
float4 SelectedPS( PS_IN i ) : SV_Target
{
return float4( 1.0, 0, 0, 1.0 );
}
\ No newline at end of file
Texture2D t0 : register( t0 );
SamplerState s0 : register( s0 );
cbuffer SceneConstants : register( b0 )
{
float4x4 mView;
float4x4 mProjection;
float4x4 mViewProjection;
};
cbuffer ModelConstants : register( b1 )
{
float4x4 mWorld;
};
struct VS_MAIN_IN
{
float4 vPosition : POSITION;
float4 vColor : COLOR;
float2 vUV : TEXCOORD;
float3 vNormals : NORMAL;
};
struct PS_IN
{
float4 vPosition : SV_POSITION;
float4 vColor : COLOR;
float2 vUV : TEXCOORD;
float3 vNormals : NORMAL;
};
PS_IN BaseVS( VS_MAIN_IN i )
{
PS_IN res;
float4 res_pos = mul( mWorld, float4( i.vPosition.xyz, 1 ) );
res.vPosition = mul( mViewProjection, res_pos );
res.vColor = i.vColor;
res.vUV = i.vUV;
res.vNormals = i.vNormals;
return res;
}
float4 NoTexPS( PS_IN i ) : SV_Target
{
return float4( i.vColor.rgb, 1.0f );
}
inline float LambertDiffuse( in float3 vNormal, in float3 vLightDir ) {
float fCosA = dot( vNormal, vLightDir ); // cosine of angle between normal and light vector
return max( fCosA, 0.0f );
}
float4 TexPS( PS_IN i ) : SV_Target
{
//return float4( i.vNormals, 1 );
float4 texColor = t0.Sample( s0, i.vUV );
clip( texColor.a < 0.3 ? -1 : 1 );
//if( texColor.a < 0.1 )
// discard;
float3 lightDir = float3( 0.5, 0.3, -1 );
float3 lighting = LambertDiffuse( i.vNormals, lightDir ).xxx;
return float4( texColor*float4( lighting + 0.2f.xxx , 1) );
}
float4 TexSelectedPS( PS_IN i ) : SV_Target
{
//return float4( i.vNormals, 1 );
float4 texColor = t0.Sample( s0, i.vUV ) * float4( 1.0, 0, 0, 1.0 );
clip( texColor.a < 0.8f ? -1 : 1 );
float3 lightDir = float3( 0.5, 0.3, -1 );
float3 lighting = LambertDiffuse( i.vNormals, lightDir ).xxx;
return float4( texColor * float4( lighting + 0.2f.xxx , 1 ) );
}
\ No newline at end of file
This diff is collapsed.
#pragma once
#include <TestUtils\TestSample.h>
#include <dinput.h>
#include <unordered_map>
#include <atomic>
#include <condition_variable>
#include <array>
#include "forward_pbr_pipeline.h"
namespace RHEngine
{
class IRenderingContext;
class D3D11ConstantBuffer;
class D3D11PrimitiveBatch;
}
class ForwardPBRPipeline;
struct ModelData
{
RpClump* object;
float drawDist;
float boundSphereRad;
bool hasAlpha;
std::string dffname;
std::string txdname;
};
struct ModelInfo
{
uint32_t modelId;
DirectX::XMMATRIX transform;
bool selected = false;
};
struct RenderingData
{
ModelData data;
ModelInfo info;
};
extern std::unordered_map<std::string, RwTexture*> g_ideTextureList;
extern std::vector<std::string> g_ideLoadedTextureList;
extern std::unordered_map<std::string, MaterialCB> g_materialBuffer;
class MaterialBufferProvider : public IMaterialBufferProvider
{
MaterialCB* GetBuffer( std::string name )
{
if( g_materialBuffer.find( name ) != g_materialBuffer.end() )
return &g_materialBuffer[name];
else
return nullptr;
}
};
struct RenderBatch
{
uint32_t start = 0, end = 0;
};
extern MaterialBufferProvider g_materialBufferProvider;
/**
* @brief Simple test sample for RenderHook, write your own code as you wish
*
*/
class SimpleSample : public RHTests::TestSample
{
public:
SimpleSample( RHEngine::RHRenderingAPI api, HINSTANCE inst ) : RHTests::TestSample( api, inst ) { }
virtual ~SimpleSample() {};
void CustomRender() override;
bool CustomInitialize() override;
void CustomUpdate( float dt ) override;
void CustomShutdown() override;
private:
void RenderUI();
void LoadIDE( const RHEngine::String& path );
void LoadIPL( const RHEngine::String& path, int32_t version );
void LoadIPLBinary( const RHEngine::String& path );
void LoadDFFForIPL( const RHEngine::String& models_path );
void DrawClump( RHEngine::IRenderingContext* context, RpClump* clump, bool selected, DirectX::XMMATRIX transf_mult );
void RenderWorker( std::uint32_t id );
private:
std::unordered_map<uint32_t, ModelData> m_ideModelList{};
std::vector<ModelInfo> m_iplModelInfoMap{};
std::vector<RenderingData> m_vCurrentFrameRenderList{};
std::vector<RenderingData> m_vCurrentFrameAlphaRenderList{};
uint32_t m_nVisibleObjects =0;
bool button_toggled[4] = { false, false, false, false };
bool mouse_aq = false;
bool m_bThreadShouldStaph = false;
bool m_bUseConstDrawDist = false;
float m_fMaxDrawDist = 300;
float m_fCamSpeed = 1;
char m_sTexFilter[32] = {};
char m_sModelFilter[32] = {};
float m_fFPS = 0;
float m_fCullingTime = 0;
float m_fRenderingTime = 0;
int32_t m_nMinMeshPerThread = 100;
std::vector<float> m_fRenderingThreadTime;
const uint32_t m_nMaxThreadCount = 64;
std::vector<void*> m_aCommandListBuffer{};
std::atomic<uint32_t> m_nCmdListCount;
std::vector<HANDLE> m_nBeginRenderingEvents;
std::vector<HANDLE> m_nEndRenderingEvents;
std::vector<std::thread> m_tWorkers;
std::condition_variable m_main_thread_cond;
std::mutex m_main_thread_mutex;
std::mutex m_io_mtx;
std::vector<RenderBatch> m_batches;
int32_t m_nWorkerThreadCount = 0;
ForwardPBRPipeline* m_pForwardPBRPipeline = nullptr;
RHEngine::D3D11ConstantBuffer* mBaseConstantBuffer = nullptr;
RHEngine::D3D11ConstantBuffer* mPerModelConstantBuffer = nullptr;
std::vector<RHEngine::IRenderingContext*> mDeferredContextList;
DirectX::XMMATRIX mObjTransformMatrix{};
DirectX::XMMATRIX mCurrentTransformMultiplier{};
};
\ No newline at end of file
#include "clump_read_funcs.h"
#include <DebugUtils/DebugLogger.h>
#include "rp_clump_funcs.h"
#include "rw_framelist_read_funcs.h"
#include "rw_geometrylist_read_funcs.h"
#include "rp_geometry_read_funcs.h"
#include "rp_geometry_funcs.h"
#include "rp_atomic_funcs.h"
using namespace std;
using namespace std::experimental::filesystem;
namespace RH_RWAPI
{
typedef struct rpAtomicBinary _rpAtomicBinary;
struct rpAtomicBinary
{
RwInt32 frameIndex;
RwInt32 geomIndex;
RwInt32 flags;
RwInt32 unused;
};
static RpAtomic* _ClumpAtomicStreamRead( void* stream, rwFrameList* fl, rpGeometryList* gl )
{
RwBool status;
RwUInt32 size;
RwUInt32 version;
status = RwStreamFindChunk( stream, rwID_STRUCT, &size, &version );
if( !status )
{
//RWERROR( ( E_RW_READ ) );
return nullptr;
}
RpAtomic* atom;
_rpAtomicBinary a;
RpGeometry* geom;
/* Read the atomic */
memset( &a, 0, sizeof( a ) );
status = ( size == RwStreamRead( stream, &a, size ) );
if( !status )
{
//RWERROR( ( E_RW_READ ) );
return nullptr;
}
atom = _RpAtomicCreate();
if( !atom )
{
return nullptr;
}
/* Set the atomic types */
rwObjectSetFlags( atom, a.flags );
if( fl->numFrames )
{
_RpAtomicSetFrame( atom, fl->frames[a.frameIndex] );
}
/* get the geometry */
if( gl->numGeoms )
{
_RpAtomicSetGeometry( atom, gl->geometries[a.geomIndex], 0 );
}
else
{
status = RwStreamFindChunk( stream, rwID_GEOMETRY,
(RwUInt32*)NULL, &version );
if( !status )
{
//RpAtomicDestroy( atom );
//RWERROR( ( E_RW_READ ) );
return nullptr;
}
geom = _RpGeometryStreamRead( stream );
status = ( NULL != geom );
if( !status )
{
//RpAtomicDestroy( atom );
//RWERROR( ( E_RW_READ ) );
return nullptr;
}
_RpAtomicSetGeometry( atom, geom, 0 );
/* Bring the geometry reference count back down, so that
* when the atomic is destroyed, so is the geometry.
*/
_RpGeometryDestroy( geom );
}
return ( atom );
}
static rpGeometryList* GeometryListDeinitialize( rpGeometryList* geomList )
{
RwInt32 i;
/* remove the read reference to each geometry */
for( i = 0; i < geomList->numGeoms; i++ )
{
_RpGeometryDestroy( geomList->geometries[i] );
}
if( geomList->geometries )
{
free( geomList->geometries );
geomList->geometries = (RpGeometry * *)NULL;
}
return ( geomList );
}
RpClump* _RpClumpStreamRead( void* stream )
{
using logger = RHDebug::DebugLogger;
RwBool status;
RwUInt32 size;
RwUInt32 version;
status = RwStreamFindChunk( stream, rwID_STRUCT, &size, &version );
if( !status )
{
return nullptr;
}
RwUInt32 chunkversion;
_rpClump cl{};
rwFrameList fl{};
rpGeometryList gl{};
RpAtomic* atom;
logger::Log( "RpClumpStreamRead: reading _rpClump info:\n" );
if( version > 0x33000 ) {
status = ( sizeof( cl ) == RwStreamRead( stream, &cl, sizeof( cl ) ) );
logger::Log( "numAtomics:" +
std::to_string( cl.numAtomics ) +
"\tnumCameras:" +
std::to_string( cl.numCameras ) +
"\tnumLights:" +
std::to_string( cl.numLights )
);
}
else {
status = ( sizeof( cl.numAtomics ) == RwStreamRead( stream, &cl.numAtomics, sizeof( cl.numAtomics ) ) );
logger::Log( "numAtomics:" +
std::to_string( cl.numAtomics ) );
}
RpClump * clump = _RpClumpCreate();
status = RwStreamFindChunk( stream, (RwUInt32)rwID_FRAMELIST,
(RwUInt32*)NULL, &chunkversion );
status = ( NULL != _rwFrameListStreamRead( stream, &fl ) );
rwObjectSetParent( clump, fl.frames[0] );
status = RwStreamFindChunk( stream, (RwUInt32)rwID_GEOMETRYLIST, (RwUInt32*)NULL, &chunkversion );
status = ( NULL != _GeometryListStreamRead( stream, &gl ) );
if( !status )
{
if( fl.numFrames )
free( fl.frames );
_RpClumpDestroy( clump );
logger::Error( "RpClumpStreamRead: failed to read geometry list!" );
return nullptr;
}
/* Iterate over the atomics */
for( uint32_t i = 0; i < static_cast<uint32_t> (cl.numAtomics); i++ )
{
status = RwStreamFindChunk( stream, (RwUInt32)rwID_ATOMIC,
(RwUInt32*)NULL, &version );
if( status )
{
atom = _ClumpAtomicStreamRead( stream, &fl, &gl );
status = ( NULL != atom );
}
else
{
GeometryListDeinitialize( &gl );
if( fl.numFrames )
free( fl.frames );
_RpClumpDestroy( clump );
logger::Error( "RpClumpStreamRead: failed to read atomic!" );
return nullptr;
}
/* Add the atomic to the clump */
_RpClumpAddAtomic( clump, atom );
}
/* Dont need the geometry list anymore */
GeometryListDeinitialize( &gl );
/* Dont need the frame list anymore */
if( fl.numFrames )
free( fl.frames );
return clump;
}
bool LoadClump( RpClump* &clump, const path& dff_path )
{
RHDebug::DebugLogger::Log( "LoadClump begin " + dff_path.filename().generic_string() );
ifstream stream( dff_path, ios_base::in | ios_base::binary );
if( RH_RWAPI::RwStreamFindChunk( &stream, rwID_CLUMP, nullptr, nullptr ) )
clump = _RpClumpStreamRead( &stream );
return clump != nullptr;
}
}
\ No newline at end of file
#pragma once
#include <RWUtils/RwAPI.h>
#include <filesystem>
namespace RH_RWAPI
{
bool LoadClump( RpClump* &clump, const std::experimental::filesystem::path& dff_path );
}
\ No newline at end of file
#include "forward_pbr_pipeline.h"
#include <Engine/Common/IRenderingContext.h>
#include <Engine/D3D11Impl/D3D11PrimitiveBatch.h>
#include <RWUtils/RwAPI.h>
#include <Engine/Definitions.h>
#include <Engine/IRenderer.h>
#include <Engine/D3D11Impl/Buffers/D3D11ConstantBuffer.h>
ForwardPBRPipeline::ForwardPBRPipeline( IMaterialBufferProvider* matbuf_prov ):
mMatBufferProvider( matbuf_prov )
{
RHEngine::IGPUAllocator* allocator = RHEngine::g_pRHRenderer->GetGPUAllocator();
allocator->AllocateShader( { TEXT( "shaders/d3d11/forward_pbr_pipeline.hlsl" ), TEXT( "BaseVS" ), RHEngine::RHShaderStage::Vertex },
mBaseVS );
allocator->AllocateShader( { TEXT( "shaders/d3d11/forward_pbr_pipeline.hlsl" ), TEXT( "NoTexPS" ), RHEngine::RHShaderStage::Pixel },
mNoTexPS );
allocator->AllocateShader( { TEXT( "shaders/d3d11/forward_pbr_pipeline.hlsl" ), TEXT( "TexPS" ), RHEngine::RHShaderStage::Pixel },
mTexPS );
allocator->AllocateShader( { TEXT( "shaders/d3d11/forward_pbr_pipeline.hlsl" ), TEXT( "SelectedPS" ), RHEngine::RHShaderStage::Pixel },
mSelectedPS );
RHEngine::RHInputLayoutInfo layout_info;
layout_info.inputElements =
{
{ RHEngine::RHInputElementType::Vec4fp32, "POSITION" },
{ RHEngine::RHInputElementType::Vec4fp8, "COLOR" },
{ RHEngine::RHInputElementType::Vec2fp32, "TEXCOORD" },
{ RHEngine::RHInputElementType::Vec3fp32, "NORMAL" }
};
layout_info.shaderPtr = mBaseVS;
allocator->AllocateInputLayout( layout_info, mVertexDecl );
allocator->AllocateConstantBuffer( { sizeof( MaterialCB ) }, (void*&)mMaterialCB );
}
ForwardPBRPipeline::~ForwardPBRPipeline()
{
delete mMaterialCB;
}
void ForwardPBRPipeline::DrawObject( RHEngine::IRenderingContext* context, RHEngine::D3D11PrimitiveBatch* model,
const PBRRenderingParams& params )
{
uint32_t strides[] = { sizeof( RHVertexDescPosColorUVNormals ) };
uint32_t offsets[] = { 0 };
context->BindShader( mBaseVS );
context->BindInputLayout( mVertexDecl );
context->SetPrimitiveTopology( model->PrimitiveType() );
context->BindIndexBuffer( model->IndexBuffer() );
context->BindVertexBuffers( { model->VertexBuffer() }, strides, offsets );
if( params.highlightModel )
context->BindShader( mSelectedPS );
for( const RHEngine::MeshSplitData& meshData : model->SplitData() )
{
if( !params.highlightModel )
{
if( meshData.material&& meshData.material->texture )
{
RH_RWAPI::RwD3D11SetTexture( context, meshData.material->texture, 0, RHEngine::RwRenderShaderStage::PixelShader );
if( mMatBufferProvider &&
mMatBufferProvider->GetBuffer( std::string( meshData.material->texture->name ) ) != nullptr )
{
context->UpdateBuffer( (void*)mMaterialCB, (void*)mMatBufferProvider->GetBuffer( std::string( meshData.material->texture->name ) ), -1 );
}
else
{
context->UpdateBuffer( (void*)mMaterialCB, (void*)& mDefMaterialCBData, -1 );
}
context->BindConstantBuffers( RHEngine::RHShaderStage::Pixel, { { 2, (void*)mMaterialCB } } );
context->BindShader( mTexPS );
}
else
{
RH_RWAPI::RwD3D11SetTexture( context, nullptr, 0, RHEngine::RwRenderShaderStage::PixelShader );
context->BindShader( mNoTexPS );
}
}
else {
RH_RWAPI::RwD3D11SetTexture( context, nullptr, 0, RHEngine::RwRenderShaderStage::PixelShader );
}
context->FlushCache();
context->RecordDrawCallIndexed( meshData.numIndex, meshData.startIndex, 0 );
}
}
#pragma once
#include <common.h>
namespace RHEngine
{
class IRenderingContext;
class D3D11ConstantBuffer;
class D3D11PrimitiveBatch;
}
struct RHVertexDescPosOnly
{
float x, y, z, w;
};
struct RHVertexDescPosColor : RHVertexDescPosOnly
{
RwRGBA color;
};
struct RHVertexDescPosColorUV : RHVertexDescPosColor
{
float u, v;
};
struct RHVertexDescPosColorUVNormals : RHVertexDescPosColorUV
{
float nx, ny, nz;
};
struct MaterialCB
{
float MaterialColor[4] = {1,1,1,1};
float Roughness=1.0f;
float Metallness=0;
float IOR;
float Emmisivness;
};
class IMaterialBufferProvider
{
public:
virtual MaterialCB* GetBuffer( std::string texture_name ) = 0;
};
struct PBRRenderingParams
{
bool highlightModel = false;
};
class ForwardPBRPipeline
{
public:
ForwardPBRPipeline( IMaterialBufferProvider* matbuf_prov );
~ForwardPBRPipeline();
void DrawObject( RHEngine::IRenderingContext* context, RHEngine::D3D11PrimitiveBatch* model, const PBRRenderingParams& params );
private:
MaterialCB mDefMaterialCBData{};
RHEngine::D3D11ConstantBuffer* mMaterialCB = nullptr;
IMaterialBufferProvider* mMatBufferProvider = nullptr;
void* mBaseVS = nullptr;
void* mNoTexPS = nullptr;
void* mTexPS = nullptr;
void* mVertexDecl = nullptr;
void* mSelectedPS = nullptr;
};
\ No newline at end of file
#pragma once
#include <common.h>
#include <unordered_map>
struct ModelData
{
RpClump* object;
float drawDist;
float boundSphereRad;
std::string dffname;
std::string txdname;
};
struct ModelInfo
{
uint32_t modelId;
DirectX::XMMATRIX transform;
};
class GTAMapLoader
{
private:
std::unordered_map<uint32_t, ModelData> m_ideModelList{};
std::vector<ModelInfo> m_iplModelInfoMap{};
};
\ No newline at end of file
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Scene info]
Pos=60,60
Size=221,203
Collapsed=0
#include <TestUtils\WindowsSampleWrapper.h>
#include <DebugUtils\DebugLogger.h>
#include <Engine\Definitions.h>
#include "SimpleSample.h"
int APIENTRY wWinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nCmdShow )
{
UNREFERENCED_PARAMETER( hPrevInstance );
UNREFERENCED_PARAMETER( lpCmdLine );
// Window params initialization
RHTests::WindowsSampleParams initParams{};
initParams.instance = hInstance;
initParams.sampleTitle = TEXT( "SimpleSample" );
initParams.windowClass = TEXT( "RHSimpleSAMPLE" );
const RHEngine::RHRenderingAPI renderingAPI = RHEngine::RHRenderingAPI::DX11;
RHEngine::String logFilePath = ToRHString( "RHDebug.log" );
RHDebug::DebugLogger::Init( logFilePath, RHDebug::LogLevel::Info );
RHTests::WindowsSampleWrapper sample(
initParams,
std::make_unique<SimpleSample>( renderingAPI, hInstance )
);
// Initialize test sample.
if ( !sample.Init() ) return FALSE;
// Run test sample!
sample.Run();
return TRUE;
}
\ No newline at end of file
#include "rp_atomic_funcs.h"
#include "rp_geometry_funcs.h"
#include "rw_frame_funcs.h"
static RwObjectHasFrame* _AtomicSync( RwObjectHasFrame* object )
{
RpAtomic* atomic = (RpAtomic*)object;
RpInterpolator* interpolator;
interpolator = &atomic->interpolator;
/*if( interpolator->flags & rpINTERPOLATORDIRTYSPHERE )
{
_rpAtomicResyncInterpolatedSphere( atomic );
}*/
/* This doesn't do much.
* The work is done in the function that the world adds to this chain */
rwObjectSetPrivateFlags( object,
rwObjectGetPrivateFlags( object ) |
rpATOMICPRIVATEWORLDBOUNDDIRTY );
return ( object );
}
void __rwObjectHasFrameSetFrame( void* object, RwFrame* frame )
{
RwObjectHasFrame* ohf = (RwObjectHasFrame*)object;
if( rwObjectGetParent( ohf ) )
{
rwLinkListRemoveLLLink( &ohf->lFrame );
}
/* Set the pointer */
rwObjectSetParent( object, frame );
/* Add it to the frames list of objects */
if( frame )
{
rwLinkListAddLLLink( &frame->objectList, &ohf->lFrame );
/* Force the objects using this frame to be updated */
RH_RWAPI::_RwFrameUpdateObjects( frame );
}
}
RpAtomic* RH_RWAPI::_RpAtomicCreate( void )
{
RpAtomic* atomic;
atomic = (RpAtomic*)malloc( sizeof( RpAtomic ) );
if( !atomic )
{
return nullptr;
}
/* We don't care about the sub type */
rwObjectHasFrameInitialize( atomic, rpATOMIC, 0, _AtomicSync );
/* NOTE: the repEntry is set to NULL because (a) if the geom is
* non-animated then IT will hold the repEntry and (b) if the geom is
* animated then the atomic will have a repEntry created during its
* next pipeline execute. [A similar argument applies to the PS2
* rwMeshCache plugin set up during rwPluginRegistryInitObject, below] */
atomic->repEntry = (RwResEntry*)NULL;
/* Flag the atomic as dirty -> ie vertices need expanding,
* and the world space bounding sphere too...
*/
rwObjectSetFlags( atomic, rpATOMICCOLLISIONTEST | rpATOMICRENDER );
rwObjectSetPrivateFlags( atomic, rpATOMICPRIVATEWORLDBOUNDDIRTY );
/* No frame yet */
_RpAtomicSetFrame( atomic, nullptr );
/* Set up clump status */
atomic->geometry = (RpGeometry*)NULL;
/* And the bounding sphere's (these get updated during frame
* synchronization and instancing)
*/
atomic->boundingSphere.radius = (RwReal)( 0 );
atomic->boundingSphere.center.x = (RwReal)( 0 );
atomic->boundingSphere.center.y = (RwReal)( 0 );
atomic->boundingSphere.center.z = (RwReal)( 0 );
atomic->worldBoundingSphere.radius = (RwReal)( 0 );
atomic->worldBoundingSphere.center.x = (RwReal)( 0 );
atomic->worldBoundingSphere.center.y = (RwReal)( 0 );
atomic->worldBoundingSphere.center.z = (RwReal)( 0 );
/* Set up the default render callback */
//RpAtomicSetRenderCallBack( atomic, AtomicDefaultRenderCallBack );
/* Set on the first frame of the geometry */
atomic->interpolator.startMorphTarget = 0;
atomic->interpolator.endMorphTarget = 0;
atomic->interpolator.time = (RwReal)( 1.0 );
atomic->interpolator.recipTime = (RwReal)( 1.0 );
atomic->interpolator.position = (RwReal)( 0.0 );
atomic->interpolator.flags = (RwInt32)
( rpINTERPOLATORDIRTYINSTANCE | rpINTERPOLATORDIRTYSPHERE );
/* membership of clump */
rwLLLinkInitialize( &atomic->inClumpLink );
atomic->clump = (RpClump*)NULL;
/* use the default atomic object pipeline */
atomic->pipeline = (RxPipeline*)NULL;
/* Not in any atomic sectors */
rwLinkListInitialize( &atomic->llWorldSectorsInAtomic );
/* Initialize memory allocated to toolkits */
//rwPluginRegistryInitObject( &atomicTKList, atomic );
return ( atomic );
}
RpAtomic* RH_RWAPI::_RpAtomicSetFrame( RpAtomic* atomic, RwFrame* frame )
{
__rwObjectHasFrameSetFrame( atomic, frame );
/* World bounding sphere is no longer valid */
rwObjectSetPrivateFlags( atomic, rwObjectGetPrivateFlags( atomic ) |
rpATOMICPRIVATEWORLDBOUNDDIRTY );
return ( atomic );
}
RpAtomic* RH_RWAPI::_RpAtomicSetGeometry( RpAtomic* atomic, RpGeometry* geometry, RwUInt32 flags )
{
if( geometry != atomic->geometry )
{
//RwFrame* frame;
if( geometry )
{
/* Add ref the new geometry */
_RpGeometryAddRef( geometry );
}
if( atomic->geometry )
{
/* Reduce refrence count on the old geometry */
_RpGeometryDestroy( atomic->geometry );
}
/* The instanced copy will be updated when the
* mesh serial numbers don't match during instancing
*/
/* Point to the geometry used */
atomic->geometry = geometry;
if( !( flags & rpATOMICSAMEBOUNDINGSPHERE ) )
{
if( geometry )
{
atomic->boundingSphere =
geometry->morphTarget[0].boundingSphere;
}
//frame = (RwFrame *)rwObjectGetParent( atomic );
//if( frame && RpAtomicGetWorld( atomic ) )
//{
// /* Mark the frame as dirty so the ties get updated. */
// RwFrameUpdateObjects( frame );
//}
}
/* The instanced copy will be updated when the
* mesh serial numbers don't match during instancing
*/
}
return ( atomic );
}
void RH_RWAPI::_RpAtomicDestroy( RpAtomic* atomic )
{
if( atomic->repEntry )
{
if( atomic->repEntry->destroyNotify )
atomic->repEntry->destroyNotify( atomic->repEntry );
if( atomic->repEntry->ownerRef )
{
*( atomic->repEntry->ownerRef ) = (RwResEntry*)NULL;
}
free( atomic->repEntry );
}
if( atomic->geometry )
{
RH_RWAPI::_RpGeometryDestroy( atomic->geometry );
}
free( atomic );
}
#pragma once
#include <RWUtils/RwAPI.h>
namespace RH_RWAPI
{
RpAtomic* _RpAtomicCreate( void );
RpAtomic* _RpAtomicSetFrame( RpAtomic* atomic, RwFrame* frame );
RpAtomic* _RpAtomicSetGeometry( RpAtomic* atomic, RpGeometry* geometry, RwUInt32 flags );
void _RpAtomicDestroy( RpAtomic* atomic );
}
\ No newline at end of file
#include "rp_clump_funcs.h"
namespace RH_RWAPI {
RpClump *_RpClumpCreate( void ) noexcept
{
RpClump *clump;
clump = (RpClump *) malloc( sizeof( RpClump ) );
if ( !clump ) {
return ( clump );
}
rwObjectInitialize( clump, rpCLUMP, 0 );
//_RpClumpSetFrame( clump, NULL );
/* Contains nothing */
rwLinkListInitialize( &clump->atomicList );
rwLinkListInitialize( &clump->lightList );
rwLinkListInitialize( &clump->cameraList );
/* Its not in the world */
rwLLLinkInitialize( &clump->inWorldLink );
/* Set the callback */
// RpClumpSetCallBack( clump, (RpClumpCallBack)NULL );
/* Initialize memory allocated to toolkits */
// rwPluginRegistryInitObject( &clumpTKList, clump );
/* All Done */
return ( clump );
}
RwBool _RpClumpDestroy( RpClump *clump )
{
// RwFrame* frame = nullptr;
/* De-init the clump plugin registered memory */
// rwPluginRegistryDeInitObject( &clumpTKList, clump );
// RpClumpForAllAtomics( clump, DestroyClumpAtomic, NULL );
// RpClumpForAllLights( clump, DestroyClumpLight, NULL );
// RpClumpForAllCameras( clump, DestroyClumpCamera, NULL );
/* Destroy the frame hierarchy if one exists */
// frame = RpClumpGetFrame( clump );
/*if( frame )
{
RwFrameDestroyHierarchy( frame );
}*/
/* Destroy the clump */
free( clump );
return ( TRUE );
}
RpClump *_RpClumpAddAtomic( RpClump *clump, RpAtomic *atomic ) noexcept
{
/* It is assumed the atomic is NOT in the world although the
* clump might be
*/
rwLinkListAddLLLink( &clump->atomicList, &atomic->inClumpLink );
atomic->clump = clump;
return ( clump );
}
} // namespace RH_RWAPI
#pragma once
#include <RWUtils/RwAPI.h>
namespace RH_RWAPI
{
RpClump* _RpClumpCreate( void ) noexcept;
RwBool _RpClumpDestroy( RpClump* clump );
RpClump* _RpClumpAddAtomic( RpClump* clump, RpAtomic* atomic ) noexcept;
}
\ No newline at end of file
#include "rp_geometry_binmesh_read_funcs.h"
#include "rp_geometry_funcs.h"
#include "rp_matlist_funcs.h"
#include <DebugUtils/DebugLogger.h>
uint32_t RH_RWAPI::g_nMeshSerialNum = 0;
#define RWINDEXBUFFERSIZE 256
typedef RwUInt32 RpIndexBuffer[RWINDEXBUFFERSIZE];
RpMeshHeader* RH_RWAPI::rpMeshRead( void* stream, const RpGeometry* geometry, const RpMaterialList* matList ) noexcept
{
binMeshHeader bmh;
RpMeshHeader* meshHeader;
RwUInt32 size;
/* Read in a header */
if( !RwStreamRead( stream, &bmh, sizeof( bmh ) ) )
{
/* Failure */
return nullptr;
}
/* Figure out the size (little bit of slack for alignment) */
size = ( sizeof( RpMeshHeader ) + ( ( sizeof( RpMesh ) + 4 ) * bmh.numMeshes ) );
if( !( rpGEOMETRYNATIVE & geometry->flags ) )
{
size += ( sizeof( RxVertexIndex ) * bmh.totalIndicesInMesh );
}
/* Allocate memory for the mesh */
//RHDebug::DebugLogger::Log( "mesh sz:" + std::to_string( size ) );
meshHeader = (RpMeshHeader*)malloc( size );
if( !meshHeader )
return nullptr;
memset( meshHeader, 0, size );
//_rpMeshHeaderCreate( size );
if( meshHeader )
{
RpMesh* mesh = (RpMesh*)( meshHeader + 1 );
RxVertexIndex * meshIndices = (RxVertexIndex*)( mesh + bmh.numMeshes );
RwUInt32 numMeshes;
meshHeader->flags = bmh.flags;
meshHeader->numMeshes = (RwUInt16)bmh.numMeshes;
meshHeader->serialNum = g_nMeshSerialNum;
meshHeader->totalIndicesInMesh = (RwUInt32)bmh.totalIndicesInMesh;
meshHeader->firstMeshOffset = 0;
g_nMeshSerialNum++;
/* Then for each mesh... */
numMeshes = meshHeader->numMeshes;
while( numMeshes-- > 0 )
{
binMesh bm;
/* ... do another header... */
if( NULL == RwStreamRead( stream, & bm, sizeof( bm ) ) )
{
/* Failure */
return nullptr;
}
mesh->numIndices = bm.numIndices;
mesh->material = matList->materials[bm.matIndex];
mesh->indices = meshIndices;
if( !( rpGEOMETRYNATIVE & geometry->flags ) )
{
RwUInt32 remainingIndices;
/* ...and all the indices */
remainingIndices = mesh->numIndices;
while( remainingIndices > 0 )
{
RpIndexBuffer IndexBuffer;
RwInt32* source = (RwInt32*)& IndexBuffer[0];
RwUInt32 readIndices;
readIndices = ( remainingIndices < RWINDEXBUFFERSIZE ) ?
( remainingIndices ) : ( RWINDEXBUFFERSIZE );
if( !RwStreamRead( stream, source,
sizeof( RwInt32 ) * readIndices ) )
{
/* Failure */
return nullptr;
}
remainingIndices -= readIndices;
while( readIndices-- > 0 )
{
*meshIndices++ = (RxVertexIndex)( *source++ );
}
}
}
mesh++;
}
}
/* All done */
return ( meshHeader );
}
bool RH_RWAPI::readGeometryMesh( void* stream, RpGeometry* geometry ) noexcept
{
if( !RwStreamFindChunk( stream, rwID_EXTENSION, nullptr, nullptr ) )
return false;
if( !RwStreamFindChunk( stream, rwID_BINMESHPLUGIN, nullptr, nullptr ) )
return false;
geometry->mesh = rpMeshRead( stream, geometry, &geometry->matList );
return geometry->mesh != nullptr;
}
\ No newline at end of file
#pragma once
#include <RWUtils/RwAPI.h>
namespace RH_RWAPI
{
struct binMeshHeader
{
RwUInt32 flags;
RwUInt32 numMeshes;
RwUInt32 totalIndicesInMesh;
};
struct binMesh
{
RwUInt32 numIndices;
RwInt32 matIndex;
};
RpMeshHeader* rpMeshRead( void* stream, const RpGeometry* geometry, const RpMaterialList* matList ) noexcept;
bool readGeometryMesh( void* stream, RpGeometry* geometry ) noexcept;
extern uint32_t g_nMeshSerialNum;
}
\ No newline at end of file
#include "rp_geometry_funcs.h"
#include <DebugUtils/DebugLogger.h>
#include "rp_matlist_funcs.h"
constexpr RwInt32 RH_RWAPI::GeometryFormatGetNumTexCoordSets( RwInt32 _fmt )
{
return ( ( ( _fmt ) & 0xff0000 ) ? ( ( ( _fmt ) & 0xff0000 ) >> 16 ) :
( ( (_fmt)& rpGEOMETRYTEXTURED2 ) ? 2 :
( ( (_fmt)& rpGEOMETRYTEXTURED ) ? 1 : 0 ) ) );
}
RpGeometry* RH_RWAPI::_RpGeometryCreate( RwInt32 numVerts, RwInt32 numTriangles, RwUInt32 format )
{
using logger = RHDebug::DebugLogger;
RpGeometry* geometry = nullptr;
RwUInt8* goffset = nullptr;
RwUInt32 gsize=0;
RwUInt32 numTexCoordSets=0;
RwInt32 flags=0;
// input values check
if( ( numVerts < 0 ) || ( numVerts >= 65536 ) || ( numTriangles < 0 ) )
{
if( numVerts < 0 )
{
logger::Error( "You cannot construct an RpGeometry with a negative number of vertices." );
}
else if( numVerts >= 65536 )
{
logger::Error( "Vertex overflow(for 16bit index buffer at least)" );
}
if( numTriangles < 0 )
{
logger::Error( "You cannot construct an RpGeometry with a negative number of triangles." );
}
return nullptr;
}
flags = format & rpGEOMETRYFLAGSMASK;
gsize = sizeof( RpGeometry );//geometryTKList.sizeOfStruct;
numTexCoordSets = GeometryFormatGetNumTexCoordSets( format );
flags = ( flags & ~( rpGEOMETRYTEXTURED | rpGEOMETRYTEXTURED2 ) )
| ( ( numTexCoordSets == 1 ) ? rpGEOMETRYTEXTURED :
( ( numTexCoordSets > 1 ) ? rpGEOMETRYTEXTURED2 : 0 ) );
if( !( rpGEOMETRYNATIVE& format ) )
{
if( flags & static_cast<RwInt32> ( rpGEOMETRYPRELIT ) )
{
gsize += sizeof( RwRGBA ) * numVerts;
}
if( numTexCoordSets > 0 )
{
/* Include space for tex coords */
gsize += sizeof( RwTexCoords ) * numVerts * numTexCoordSets;
}
gsize += sizeof( RpTriangle ) * numTriangles;
}
geometry = (RpGeometry*)malloc( gsize );
if( !geometry )
return nullptr;
_rpMaterialListInitialize( geometry->matList );
/* Allocate initial array of morph targets (0) */
geometry->morphTarget = nullptr;
/* Set up key frames */
geometry->numMorphTargets = 0;
/* Set up type */
rwObjectInitialize( geometry, rpGEOMETRY, 0 );
/* Set the instancing information */
geometry->repEntry = nullptr;
/* Nothing locked since last time */
geometry->lockedSinceLastInst = 0;
/* Initialise ref count */
geometry->refCount = 1;
/* Set up the device information -> its locked! */
geometry->mesh = nullptr;
/* Set up texture coords */
geometry->numTexCoordSets = numTexCoordSets;
memset( geometry->texCoords, 0, rwMAXTEXTURECOORDS * sizeof( RwTexCoords* ) );
geometry->preLitLum = nullptr;
/* Set up the triangles */
geometry->triangles = nullptr;
geometry->numTriangles = numTriangles;
/* Set the geometries flags */
geometry->flags = flags | ( rpGEOMETRYNATIVEFLAGSMASK & format );
geometry->numVertices = numVerts;
if( !( rpGEOMETRYNATIVE & format ) )
{
/* step past structure to allocate arrays */
goffset = (RwUInt8*)geometry + sizeof( RpGeometry );
/* Create prelight values if necessary */
if( ( flags & (RwInt32)rpGEOMETRYPRELIT ) && numVerts )
{
geometry->preLitLum = (RwRGBA*)goffset;
goffset += sizeof( RwRGBA* ) * numVerts;
}
/* Create texture coordinates if necessary - in the right place */
if( numTexCoordSets > 0 && numVerts )
{
RwUInt32 i;
for( i = 0; i < numTexCoordSets; i++ )
{
geometry->texCoords[i] = (RwTexCoords*)goffset;
goffset += sizeof( RwTexCoords ) * numVerts;
}
}
/* Set up the triangles */
if( numTriangles )
{
geometry->triangles = (RpTriangle*)goffset;
goffset += sizeof( RpTriangle ) * numTriangles;
/* Setup all of the materials */
for( RwInt32 i = 0; i < numTriangles; i++ )
{
geometry->triangles[i].matIndex = 0xFFFF;
}
}
}
/* Allocate one key frame, because geometry is useless without it */
if( _RpGeometryAddMorphTarget( *geometry ) < 0 )
{
_rpMaterialListDeinitialize( geometry->matList );
free( geometry );
return nullptr;
}
/* Initialize the plugin memory */
//rwPluginRegistryInitObject( &geometryTKList, geometry );
/* All done */
return geometry;
}
RwBool RH_RWAPI::_GeometryAnnihilate( RpGeometry* geometry )
{
/* Temporarily bump up reference count to avoid assertion failures */
geometry->refCount++;
/* Lock it so it can be destroyed */
//RpGeometryLock( geometry, ( rpGEOMETRYLOCKALL ) );
/* DeInitialize the plugin memory */
//rwPluginRegistryDeInitObject( &geometryTKList, geometry );
/* destroy morphTargets */
if( geometry->morphTarget )
{
free( geometry->morphTarget );
geometry->morphTarget = nullptr;
}
_rpMaterialListDeinitialize( geometry->matList );
/* Reinstate reference count */
--geometry->refCount;
free( geometry );
return ( TRUE );
}
RwBool RH_RWAPI::_RpGeometryDestroy( RpGeometry* geometry )
{
RwBool result = TRUE;
/* Do we actually need to blow it away ? */
if( ( geometry->refCount - 1 ) <= 0 )
{
/* Blow away it's instance copy if it has one */
if( geometry->repEntry )
{
if( geometry->repEntry->destroyNotify )
geometry->repEntry->destroyNotify( geometry->repEntry );
if( geometry->repEntry->ownerRef )
{
*( geometry->repEntry->ownerRef ) = (RwResEntry*)NULL;
}
free( geometry->repEntry );
//RwResourcesFreeResEntry( geometry->repEntry );
}
/* RWCRTCHECKMEMORY(); */
/*
* Don't decrement the refCount until after the resource
* entry has been destroyed as we many need to call API
* geometry functions.
*/
--geometry->refCount;
/* RWCRTCHECKMEMORY(); */
result = _GeometryAnnihilate( geometry );
}
else
{
/* RWCRTCHECKMEMORY(); */
--geometry->refCount;
/* RWCRTCHECKMEMORY(); */
}
return ( result );
}
RwInt32 RH_RWAPI::_RpGeometryAddMorphTargets( RpGeometry& geometry, RwInt32 mtcount ) noexcept
{
RwUInt32 mtsize = 0, bytes = 0;
RpMorphTarget* morphTarget = nullptr;
RwV3d* vertexData = nullptr;
if( rpGEOMETRYNATIVE& geometry.flags )
{
mtsize = sizeof( RpMorphTarget );
}
else
{
mtsize = sizeof( RpMorphTarget ) + sizeof( RwV3d ) * geometry.numVertices;
if( rpGEOMETRYNORMALS& geometry.flags )
{
mtsize += sizeof( RwV3d ) * geometry.numVertices;
}
}
bytes = mtsize * ( geometry.numMorphTargets + mtcount );
/* Is it a realloc or a first time alloc? */
if( geometry.morphTarget )
{
RwUInt8* src = nullptr, * dst = nullptr;
RwInt32 len = 0;
morphTarget = (RpMorphTarget*)realloc( geometry.morphTarget, bytes );
if( !morphTarget )
{
/* Failed to allocate memory for the new morph target array */
// RWERROR( ( E_RW_NOMEM, ( bytes ) ) );
return ( -1 );
}
/* we want the MorphTarget structures at the beginning so we need to
open a gap for mtcount MorphTargets */
src = (RwUInt8*)morphTarget + ( mtsize * geometry.numMorphTargets ) - 1;
dst = src + ( sizeof( RpMorphTarget ) * mtcount );
len = ( mtsize * geometry.numMorphTargets ) - ( sizeof( RpMorphTarget ) * geometry.numMorphTargets );
while( len-- )
{
*dst-- = *src--;
}
}
else
{
morphTarget = (RpMorphTarget*)malloc( bytes );
if( !morphTarget )
{
/* Failed to allocate memory for the new morph target array */
//RWERROR( ( E_RW_NOMEM, ( bytes ) ) );
return ( -1 );
}
}
/* Add the extra frames */
geometry.numMorphTargets += mtcount;
/* Memory allocation is successful, so install */
geometry.morphTarget = morphTarget;
/* setup ALL pointers */
vertexData = (RwV3d*)( (RwUInt8*)morphTarget +
( sizeof( RpMorphTarget ) *
geometry.numMorphTargets ) );
for( RwInt32 i = 0; i < geometry.numMorphTargets; i++ )
{
RpMorphTarget* aMorph = &geometry.morphTarget[i];
aMorph->verts = nullptr;
aMorph->normals = nullptr;
if( !( rpGEOMETRYNATIVE & ( geometry.flags ) ) )
{
if( geometry.numVertices )
{
aMorph->verts = vertexData;
vertexData += geometry.numVertices;
if( rpGEOMETRYNORMALS & ( geometry.flags ) )
{
aMorph->normals = vertexData;
vertexData += geometry.numVertices;
}
}
}
}
/* just initialize new ones */
for( RwInt32 i = geometry.numMorphTargets - mtcount; i < geometry.numMorphTargets; i++ )
{
RpMorphTarget* aMorph = &geometry.morphTarget[i];
/* Initialize */
aMorph->boundingSphere.center.x = (RwReal)( 0 );
aMorph->boundingSphere.center.y = (RwReal)( 0 );
aMorph->boundingSphere.center.z = (RwReal)( 0 );
aMorph->boundingSphere.radius = (RwReal)( 0 );
aMorph->parentGeom = &geometry;
}
/* Done */
return ( geometry.numMorphTargets - mtcount );
}
RwInt32 RH_RWAPI::_RpGeometryAddMorphTarget( RpGeometry& geometry ) noexcept
{
return ( _RpGeometryAddMorphTargets( geometry, 1 ) );
}
RpGeometry* RH_RWAPI::_RpGeometryAddRef( RpGeometry* geometry )
{
geometry->refCount++;
return ( geometry );
}
#pragma once
#include <RWUtils/RwAPI.h>
namespace RH_RWAPI {
constexpr RwInt32 GeometryFormatGetNumTexCoordSets( RwInt32 _fmt );
RpGeometry* _RpGeometryCreate( RwInt32 numVerts, RwInt32 numTriangles, RwUInt32 format );
static RwBool _GeometryAnnihilate( RpGeometry* geometry );
RwBool _RpGeometryDestroy( RpGeometry* geometry );
RwInt32 _RpGeometryAddMorphTargets( RpGeometry& geometry, RwInt32 mtcount ) noexcept;
RwInt32 _RpGeometryAddMorphTarget( RpGeometry& geometry ) noexcept;
RpGeometry* _RpGeometryAddRef( RpGeometry* geometry );
}
\ No newline at end of file
#include "rp_geometry_read_funcs.h"
#include "rp_geometry_funcs.h"
#include "rp_matlist_read_funcs.h"
#include "rp_geometry_binmesh_read_funcs.h"
RpGeometry* RH_RWAPI::_RpGeometryStreamRead( void* stream )
{
RpGeometry* geometry;
_rpGeometry geom;
RwUInt32 version;
struct _rpGeometry_Rw_3_0_ext
{
float ambient;
float diffuse;
float specular;
} geom_ext;
if( !RwStreamFindChunk( stream, (RwUInt32)rwID_STRUCT, (RwUInt32*)NULL, &version ) )
{
return nullptr;
}
if( RwStreamRead( stream, &geom, sizeof( geom ) ) != sizeof( geom ) )
{
return nullptr;
}
if( version <= 0x00032000 || version == 0x00033002 )
{
if( RwStreamRead( stream, &geom_ext, sizeof( geom_ext ) ) != sizeof( geom_ext ) )
{
return nullptr;
}
}
geometry = _RpGeometryCreate( geom.numVertices, geom.numTriangles, geom.format );
if( !geometry )
return nullptr;
if( geom.numMorphTargets > 1 )
{
if( _RpGeometryAddMorphTargets( *geometry, geom.numMorphTargets - 1 ) < 0 )
{
_RpGeometryDestroy( geometry );
return nullptr;
}
}
if( !( rpGEOMETRYNATIVE & geometry->flags ) )
{
if( geometry->numVertices )
{
/* Read prelighting information */
if( geom.format & rpGEOMETRYPRELIT )
{
RwUInt32 sizeLum = geometry->numVertices * sizeof( RwRGBA );
/* No conversion needed - it's made of chars */
if( RwStreamRead( stream, geometry->preLitLum, sizeLum )
!= sizeLum )
{
/* Failed, so tidy up */
_RpGeometryDestroy( geometry );
return nullptr;
}
}
/* Read texture coordinate information */
if( geometry->numTexCoordSets > 0 )
{
RwInt32 i;
const RwUInt32 sizeTC = geometry->numVertices *
sizeof( RwTexCoords );
/* Read vertex texture coordinates - reals, remember */
for( i = 0; i < geometry->numTexCoordSets; i++ )
{
if( !RwStreamRead( stream, (void*)geometry->texCoords[i], sizeTC ) )
{
/* Failed, so tidy up */
_RpGeometryDestroy( geometry );
return nullptr;
}
}
}
/* Read in the triangles */
if( geometry->numTriangles )
{
RpTriangle* destTri;
RwInt32 numTris;
RwUInt32 size;
/* Load the triangle information */
numTris = geometry->numTriangles;
destTri = geometry->triangles;
size = numTris * sizeof( _rpTriangle );
if( RwStreamRead( stream, (void*)destTri, size ) != size )
{
_RpGeometryDestroy( geometry );
return nullptr;
}
/* These are unpacked "in-place" into RwUInt16 fields */
// these guys smart tricksters tbh, why tho?
while( numTris-- )
{
RwUInt16 hi, lo;
_rpTriangle* srceTri;
srceTri = (_rpTriangle*)destTri;
hi = (RwUInt16)( srceTri->vertex01 >> 16 ) & 0xFFFF;
lo = (RwUInt16)( srceTri->vertex01 ) & 0xFFFF;
destTri->vertIndex[0] = hi;
destTri->vertIndex[1] = lo;
hi = (RwUInt16)( srceTri->vertex2Mat >> 16 ) & 0xFFFF;
lo = (RwUInt16)( srceTri->vertex2Mat ) & 0xFFFF;
destTri->vertIndex[2] = hi;
destTri->matIndex = lo;
destTri++;
}
}
}
}
RwInt32 i;
for( i = 0; i < geometry->numMorphTargets; i++ )
{
_rpMorphTarget kf;
RpMorphTarget* morphTarget = &geometry->morphTarget[i];
if( RwStreamRead( stream, &kf, sizeof( kf ) ) != sizeof( kf ) )
{
_RpGeometryDestroy( geometry );
return nullptr;
}
morphTarget->boundingSphere = kf.boundingSphere;
if( kf.pointsPresent && kf.normalsPresent )
{
if( !RwStreamRead( stream, morphTarget->verts,
sizeof( RwV3d ) * 2 * geometry->numVertices ) )
{
_RpGeometryDestroy( geometry );
return nullptr;
}
}
else {
if( kf.pointsPresent )
{
if( !RwStreamRead( stream, morphTarget->verts,
sizeof( RwV3d ) * geometry->numVertices ) )
{
_RpGeometryDestroy( geometry );
return nullptr;
}
}
if( kf.normalsPresent )
{
if( !RwStreamRead( stream, morphTarget->normals,
sizeof( RwV3d ) * geometry->numVertices ) )
{
_RpGeometryDestroy( geometry );
return nullptr;
}
}
}
}
if( !RwStreamFindChunk( stream, (RwUInt32)rwID_MATLIST,
(RwUInt32*)NULL, &version ) )
{
_RpGeometryDestroy( geometry );
return nullptr;
}
if( !_rpMaterialListStreamRead( stream, geometry->matList ) )
{
_RpGeometryDestroy( geometry );
return nullptr;
}
readGeometryMesh( stream, geometry );
return geometry;
}
\ No newline at end of file
#pragma once
#include <RWUtils/RwAPI.h>
namespace RH_RWAPI
{
RpGeometry* _RpGeometryStreamRead( void* stream );
struct _rpTriangle
{
RwUInt32 vertex01; /* V0 index in top 16 bits, V1 index in bottom 16 bits */
RwUInt32 vertex2Mat; /* V2 index in top 16 bits, Material index in bottom 16 bit */
};
struct _rpMorphTarget
{
RwSphere boundingSphere;
RwBool pointsPresent;
RwBool normalsPresent;
};
}
#include "rp_material_funcs.h"
RpMaterial* RH_RWAPI::_RpMaterialCreate( void )
{
RpMaterial* material;
RwRGBA color;
material = (RpMaterial*)malloc( sizeof( RpMaterial ) );
if( !material )
return nullptr;
material->refCount = 1;
/* White is an appropriate material color (especially for textured materials) */
color.red = 0xff;
color.green = 0xff;
color.blue = 0xff;
color.alpha = 0xff;
RpMaterialSetColor( material, &color );
material->texture = (RwTexture*)NULL; /* Non textured */
/* use the default material pipeline */
material->pipeline = (RxPipeline*)NULL;
material->surfaceProps = { (RwReal)( 1.0 ), (RwReal)( 1.0 ), (RwReal)( 1.0 ) };
//RpMaterialSetSurfaceProperties( material, &defaultSurfaceProperties );
/* Initialize memory allocated to toolkits */
//rwPluginRegistryInitObject( &materialTKList, material );
//RWASSERT( 0 < material->refCount );
return ( material );
}
RwBool RH_RWAPI::_RpMaterialDestroy( RpMaterial* material )
{
if( 1 == material->refCount )
{
/* De-initialize memory allocated to toolkits */
//rwPluginRegistryDeInitObject( &materialTKList, material );
/* Decreases the reference count on the texture too */
//RpMaterialSetTexture( material, (RwTexture *)NULL );
free( material );//RwFreeListFree( RWMATERIALGLOBAL( matFreeList ), material );
}
else
{
/* RWCRTCHECKMEMORY(); */
--material->refCount;
/* RWCRTCHECKMEMORY(); */
}
return ( TRUE );
}
#pragma once
#include <RWUtils/RwAPI.h>
namespace RH_RWAPI {
RpMaterial *_RpMaterialCreate( void );
RwBool _RpMaterialDestroy( RpMaterial *material );
} // namespace RH_RWAPI
#include "rp_material_read_funcs.h"
#include "rp_material_funcs.h"
RwTexture*
_RwTextureStreamRead( void* stream )
{
RwUInt32 size, version;
if( !RH_RWAPI::RwStreamFindChunk( stream, rwID_STRUCT, &size, &version ) )
{
return nullptr;
}
RwTexture* texture;
RwChar textureName[rwTEXTUREBASENAMELENGTH * 4];
RwChar textureMask[rwTEXTUREBASENAMELENGTH * 4];
RwTextureFilterMode filtering;
RwTextureAddressMode addressingU;
RwTextureAddressMode addressingV;
struct _rwStreamTexture
{
RwUInt32 filterAndAddress;
} texFiltAddr;
RwBool mipmapState;
RwBool autoMipmapState;
RwTextureStreamFlags flags;
/* Read the filtering mode */
memset( &texFiltAddr, 0, sizeof( texFiltAddr ) );
if( RH_RWAPI::RwStreamRead( stream, &texFiltAddr, size ) != size )
{
return nullptr;
}
/* Extract filtering */
filtering = (RwTextureFilterMode)
( texFiltAddr.filterAndAddress & rwTEXTUREFILTERMODEMASK );
/* Extract addressing */
addressingU = (RwTextureAddressMode)
( ( texFiltAddr.filterAndAddress >> 8 ) & 0x0F );
addressingV = (RwTextureAddressMode)
( ( texFiltAddr.filterAndAddress >> 12 ) & 0x0F );
/* Make sure addressingV is valid so files old than 3.04 still work */
if( addressingV == rwTEXTUREADDRESSNATEXTUREADDRESS )
{
addressingV = addressingU;
texFiltAddr.filterAndAddress |= ( ( addressingV & 0xF ) << 12 );
}
/* Extract user mipmap flags */
flags = (RwTextureStreamFlags)( ( texFiltAddr.filterAndAddress >> 16 ) & 0xFF );
//mipmapState = RwTextureGetMipmapping();
//autoMipmapState = RwTextureGetAutoMipmapping();
/* Use it */
if( ( filtering == rwFILTERMIPNEAREST ) ||
( filtering == rwFILTERMIPLINEAR ) ||
( filtering == rwFILTERLINEARMIPNEAREST ) ||
( filtering == rwFILTERLINEARMIPLINEAR ) )
{
/* Lets mip map it */
/*RwTextureSetMipmapping( TRUE );
if( flags & rwTEXTURESTREAMFLAGSUSERMIPMAPS )
{
RwTextureSetAutoMipmapping( FALSE );
}
else
{
RwTextureSetAutoMipmapping( TRUE );
}*/
}
else
{
/* Lets not */
//RwTextureSetMipmapping( FALSE );
//RwTextureSetAutoMipmapping( FALSE );
}
/* Search for a string or a unicode string */
if( !RH_RWAPI::_rwStringStreamFindAndRead( textureName, stream ) )
{
//RwTextureSetMipmapping( mipmapState );
//RwTextureSetAutoMipmapping( autoMipmapState );
return nullptr;
}
/* Search for a string or a unicode string */
if( !RH_RWAPI::_rwStringStreamFindAndRead( textureMask, stream ) )
{
//RwTextureSetMipmapping( mipmapState );
//RwTextureSetAutoMipmapping( autoMipmapState );
return nullptr;
}
/* Get the textures */
if( !( texture = _RwTextureRead( textureName, textureMask ) ) )
{
RH_RWAPI::RwStreamFindChunk( stream, rwID_EXTENSION, nullptr, nullptr );
return nullptr;
}
//{
// /* Skip any extension chunks */
// _rwPluginRegistrySkipDataChunks( &textureTKList, stream );
//
// RwTextureSetMipmapping( mipmapState );
// RwTextureSetAutoMipmapping( autoMipmapState );
//
// RWRETURN( (RwTexture*)NULL );
//}
/* clean up */
//RwTextureSetMipmapping( mipmapState );
//RwTextureSetAutoMipmapping( autoMipmapState );
//RWASSERT( 0 < texture->refCount );
if( texture->refCount == 1 )
{
/* By testing the reference count here,
* we can tell if we just loaded it!!! */
/* Set the filtering and addressing */
texture->filterAddressing = texFiltAddr.filterAndAddress &
( rwTEXTUREFILTERMODEMASK | rwTEXTUREADDRESSINGMASK );
/* Read the extension chunks */
/*if( !_rwPluginRegistryReadDataChunks( &textureTKList, stream, texture ) )
{
RWRETURN( (RwTexture*)NULL );
}*/
}
else
{
/*if( !_rwPluginRegistrySkipDataChunks( &textureTKList, stream ) )
{
//RWRETURN( (RwTexture*)NULL );
}*/
}
if( !RH_RWAPI::RwStreamFindChunk( stream, rwID_EXTENSION, nullptr, nullptr ) )
return nullptr;
return ( texture );
}
RpMaterial* RH_RWAPI::_RpMaterialStreamRead( void* stream )
{
RwUInt32 size;
RwUInt32 version;
if( !RwStreamFindChunk( stream, rwID_STRUCT, &size, &version ) )
{
return nullptr;
}
RpMaterial* material = nullptr;
_rpMaterial mat;
memset( &mat, 0, sizeof( mat ) );
if( RwStreamRead( stream, &mat, size ) != size )
{
return nullptr;
}
/* Create the material */
material = _RpMaterialCreate();
if( !material )
{
return nullptr;
}
/* We want the color */
RpMaterialSetColor( material, &mat.color );
/* set the surfaceProps */
/*material->surfaceProps = mat.surfaceProps; */
RpMaterialSetSurfaceProperties( material, &mat.surfaceProps );
/* Check if it has a texture */
material->texture = nullptr;
if( mat.textured )
{
/* Read in the texture */
if( !RwStreamFindChunk( stream, (RwUInt32)rwID_TEXTURE,
(RwUInt32 *)NULL, &version ) )
{
_RpMaterialDestroy( material );
return nullptr;
}
/* If we don't get the material, the polygons will just be the
* color of the underlying material - usually white
*/
material->texture = _RwTextureStreamRead( stream );
}
if( !RwStreamFindChunk( stream, rwID_EXTENSION, nullptr, nullptr ) )
return nullptr;
return ( material );
}
\ No newline at end of file
#pragma once
#include <RWUtils/RwAPI.h>
namespace RH_RWAPI
{
RpMaterial* _RpMaterialStreamRead( void* stream );
}
RwTexture* _RwTextureRead( const RwChar* name, const RwChar* maskName );
\ No newline at end of file
#include "rp_matlist_funcs.h"
#include "rp_material_funcs.h"
void RH_RWAPI::_rpMaterialListInitialize( RpMaterialList& matList )
{
matList.space = 0;
matList.materials = nullptr;
matList.numMaterials = 0;
}
void RH_RWAPI::_rpMaterialListDeinitialize( RpMaterialList& matList )
{
RpMaterial** materialArray;
materialArray = matList.materials;
if( materialArray )
{
RwInt32 materialCount = matList.numMaterials;
RwInt32 nI;
for( nI = 0; nI < materialCount; nI++ )
{
_RpMaterialDestroy( materialArray[nI] );
materialArray[nI] = nullptr;
}
free( materialArray );
materialArray = nullptr;
matList.materials = materialArray;
}
/* Reset the structure */
matList.numMaterials = 0;
matList.space = 0;
}
bool RH_RWAPI::_rpMaterialListSetSize( RpMaterialList& matList, RwInt32 size )
{
if( matList.space < size )
{
RpMaterial** materials;
size_t memSize = sizeof( RpMaterial* ) * size;
if( matList.materials )
{
materials = (RpMaterial * *)realloc( matList.materials, memSize );
}
else
{
materials = (RpMaterial * *)malloc( memSize );
}
if( !materials )
{
//RWERROR( ( E_RW_NOMEM, memSize ) );
return false;
}
/* Shove in the new */
matList.materials = materials;
matList.space = size;
}
return true;
}
RwInt32 RH_RWAPI::_rpMaterialListAppendMaterial( RpMaterialList& matList, RpMaterial* material )
{
RpMaterial** materials;
RwUInt32 count;
size_t memSize;
/* See if there is a blank entry we can use */
/* Add it to the list */
if( matList.space > matList.numMaterials )
{
materials = &( matList.materials )[matList.numMaterials];
( *materials ) = material;
RpMaterialAddRef( material );
matList.numMaterials++;
return ( matList.numMaterials - 1 );
}
/* Need to allocates some more space */
count = ( matList.space +
rwMATERIALLISTGRANULARITY );
memSize = sizeof( RpMaterial* ) * count;
if( matList.materials )
{
materials =
(RpMaterial * *)realloc( matList.materials, memSize );
}
else
{
materials = (RpMaterial * *)malloc( count * sizeof( RpMaterial* ) );//_rpMaterialListAlloc( count );
}
if( !materials )
{
return -1;
}
/* Shove in the new */
matList.materials = materials;
matList.space += rwMATERIALLISTGRANULARITY;
materials[matList.numMaterials] = material;
RpMaterialAddRef( material );
matList.numMaterials++;
return ( matList.numMaterials - 1 );
}
\ No newline at end of file
#pragma once
#include <RWUtils/RwAPI.h>
namespace RH_RWAPI
{
static uint32_t rwMATERIALLISTGRANULARITY = 20;
void _rpMaterialListInitialize( RpMaterialList& matList );
void _rpMaterialListDeinitialize( RpMaterialList& matList );
bool _rpMaterialListSetSize( RpMaterialList& matList, RwInt32 size );
RwInt32 _rpMaterialListAppendMaterial( RpMaterialList& matList, RpMaterial* material );
}
\ No newline at end of file
#include "rp_matlist_read_funcs.h"
#include "rp_matlist_funcs.h"
#include "rp_material_read_funcs.h"
#include "rp_material_funcs.h"
bool RH_RWAPI::_rpMaterialListStreamRead( void* stream, RpMaterialList& matList )
{
RwInt32 i, len, * matindex;
RwUInt32 size, version;
if( !RwStreamFindChunk( stream, rwID_STRUCT, &size, &version ) )
{
return false;
}
RwBool status;
status = ( NULL != RwStreamRead( stream, &len, sizeof( len ) ) );
if( !status )
return false;
matList.space = 0;
matList.materials = nullptr;
matList.numMaterials = 0;
if( len == 0 )
{
/* zero entry material list simply return the initialized
matList we've created */
return true;
}
/* make the list as large as needed */
if( !_rpMaterialListSetSize( matList, len ) )
{
_rpMaterialListDeinitialize( matList );
return false;
}
matindex = (RwInt32*)malloc( sizeof( RwInt32 ) * len );
status = ( NULL !=
RwStreamRead( stream, matindex, sizeof( RwInt32 ) * len ) );
if( !status )
{
free( matindex );
_rpMaterialListDeinitialize( matList );
return false;
}
for( i = 0; i < len; i++ )
{
RpMaterial* material;
/* new material */
if( matindex[i] < 0 )
{
if( !RwStreamFindChunk( stream, (RwUInt32)rwID_MATERIAL,
(RwUInt32*)NULL, &version ) )
{
free( matindex );
_rpMaterialListDeinitialize( matList );
return false;
}
if( !( material = _RpMaterialStreamRead( stream ) ) )
{
free( matindex );
_rpMaterialListDeinitialize( matList );
return false;
}
}
else
{
material = matList.materials[matindex[i]];
//_rpMaterialListGetMaterial( matList, matindex[i] );
RpMaterialAddRef( material );
}
/* Add the material to the end of the list - this bumps up the
* reference count
*/
_rpMaterialListAppendMaterial( matList, material );
/* We want to drop the reference count back down, so that only
* the material list owns it (so it goes away when the material
* list does.
*/
_RpMaterialDestroy( material );
}
free( matindex );
return true;
}
\ No newline at end of file
#pragma once
#include <RWUtils/RwAPI.h>
namespace RH_RWAPI
{
bool _rpMaterialListStreamRead( void* stream, RpMaterialList& matList );
}
\ No newline at end of file
#include "rw_frame_funcs.h"
#define rwMatrixSetFlags( m, flagsbit ) ( ( m )->flags = ( flagsbit ) )
#define rwMatrixGetFlags( m ) ( ( m )->flags )
#define RwMatrixSetIdentityMacro( m ) \
MACRO_START \
{ \
( m )->right.x = ( m )->up.y = ( m )->at.z = ( RwReal )( ( 1.0 ) ); \
( m )->right.y = ( m )->right.z = ( m )->up.x = ( RwReal )( ( 0.0 ) ); \
( m )->up.z = ( m )->at.x = ( m )->at.y = ( RwReal )( ( 0.0 ) ); \
( m )->pos.x = ( m )->pos.y = ( m )->pos.z = ( RwReal )( ( 0.0 ) ); \
rwMatrixSetFlags( ( m ), rwMatrixGetFlags( m ) | \
( rwMATRIXINTERNALIDENTITY | \
rwMATRIXTYPEORTHONORMAL ) ); \
} \
MACRO_STOP
#define RwMatrixSetIdentity( m ) RwMatrixSetIdentityMacro( m )
#define rwMatrixInitialize( m, t ) \
MACRO_START { rwMatrixSetFlags( ( m ), ( t ) ); } \
MACRO_STOP
#define rwMatrixInitializeIdentity( m, t ) \
MACRO_START \
{ \
rwMatrixInitialize( ( m ), ( t ) ); \
RwMatrixSetIdentity( ( m ) ); \
} \
MACRO_STOP
void RH_RWAPI::_rwFrameInternalInit( RwFrame *frame ) noexcept
{
rwObjectInitialize( frame, rwFRAME, 0 );
rwLinkListInitialize( &frame->objectList ); /* No objects attached here */
/* Set up the structure */
rwMatrixInitializeIdentity( &frame->modelling, rwMATRIXTYPEORTHONORMAL );
rwMatrixInitializeIdentity( &frame->ltm, rwMATRIXTYPEORTHONORMAL );
/* Set up the position in the hierarchy */
frame->child = nullptr;
frame->next = nullptr;
/* Point to root */
frame->root = frame;
}
RwFrame *RH_RWAPI::_RwFrameCreate( void ) noexcept
{
RwFrame *frame = (RwFrame *)malloc( sizeof( RwFrame ) );
_rwFrameInternalInit( frame );
return frame;
}
void RH_RWAPI::_rwSetHierarchyRoot( RwFrame *frame, RwFrame *root )
{
frame->root = root;
frame = frame->child;
while ( frame )
{
_rwSetHierarchyRoot( frame, root );
frame = frame->next;
}
}
void RH_RWAPI::_RwFrameUpdateObjects( RwFrame *frame ) noexcept
{
RwUInt32 oldFlags;
oldFlags = rwObjectGetPrivateFlags( frame->root );
// if( !( oldFlags & ( rwFRAMEPRIVATEHIERARCHYSYNCLTM |
// rwFRAMEPRIVATEHIERARCHYSYNCOBJ ) ) )
//{
// /* Not in the dirty list - add it */
// rwLinkListAddLLLink( &RWSRCGLOBAL( dirtyFrameList ),
// &frame->root->inDirtyListLink );
//}
/* whole hierarchy needs resync */
rwObjectSetPrivateFlags( frame->root,
oldFlags | ( rwFRAMEPRIVATEHIERARCHYSYNCLTM |
rwFRAMEPRIVATEHIERARCHYSYNCOBJ ) );
/* this frame in particular */
rwObjectSetPrivateFlags( frame, rwObjectGetPrivateFlags( frame ) |
( rwFRAMEPRIVATESUBTREESYNCLTM |
rwFRAMEPRIVATESUBTREESYNCOBJ ) );
}
void RH_RWAPI::_RwFrameRemoveChild( RwFrame *child )
{
RwFrame *curFrame = nullptr;
assert( child != nullptr );
/* Need to do something */
curFrame = ( RwFrameGetParent( child ) )->child;
assert( curFrame != nullptr );
/* Check if its the first child */
if ( curFrame == child )
{
RwFrameGetParent( child )->child = child->next;
}
else
{
while ( curFrame->next != child )
{
curFrame = curFrame->next;
}
/* Remove it from the sibling list */
curFrame->next = child->next;
}
/* Now its a root it also has no siblings */
rwObjectSetParent( child, nullptr );
child->next = nullptr;
/* Set the hierarchy root */
_rwSetHierarchyRoot( child, child );
/* Make it dirty */
_RwFrameUpdateObjects( child );
}
void RH_RWAPI::_RwFrameAddChild( RwFrame *parent, RwFrame *child )
{
if ( RwFrameGetParent( child ) )
{
_RwFrameRemoveChild( child );
}
/* add as child and re-parent */
child->next = parent->child;
parent->child = child;
rwObjectSetParent( child, parent );
_rwSetHierarchyRoot( child, parent->root );
/* Handle if its dirty */
if ( rwObjectTestPrivateFlags( child, rwFRAMEPRIVATEHIERARCHYSYNCLTM |
rwFRAMEPRIVATEHIERARCHYSYNCOBJ ) )
{
rwLinkListRemoveLLLink( &child->inDirtyListLink );
/* clear flag */
rwObjectSetPrivateFlags( child,
rwObjectGetPrivateFlags( child ) &
~( rwFRAMEPRIVATEHIERARCHYSYNCLTM |
rwFRAMEPRIVATEHIERARCHYSYNCOBJ ) );
}
/* The child's local transformation matrix is definitely dirty */
_RwFrameUpdateObjects( child );
}
RwMatrix *RH_RWAPI::_RwFrameGetLTM( RwFrame *frame )
{
/* If something has changed, sync the hierarchy */
if ( rwObjectTestPrivateFlags( frame->root,
rwFRAMEPRIVATEHIERARCHYSYNCLTM ) )
{
/* Sync the whole hierarchy */
__rwFrameSyncHierarchyLTM( frame->root );
}
return ( &frame->ltm );
}
static void FrameSyncHierarchyLTMRecurse( RwFrame *frame, RwInt32 flags )
{
/* NULL is a valid; termination condition */
while ( frame )
{
RwInt32 accumflags = flags | rwObjectGetPrivateFlags( frame );
if ( accumflags & rwFRAMEPRIVATESUBTREESYNCLTM )
{
/* Work out the new local transformation matrix */
RwMatrix *parent_ltm = &( ( RwFrameGetParent( frame ) )->ltm );
RwMatrix *local_ltm = &frame->ltm;
DirectX::XMMATRIX local = {
local_ltm->right.x, local_ltm->right.y, local_ltm->right.z, 0,
local_ltm->up.x, local_ltm->up.y, local_ltm->up.z, 0,
local_ltm->at.x, local_ltm->at.y, local_ltm->at.z, 0,
local_ltm->pos.x, local_ltm->pos.y, local_ltm->pos.z, 1 };
DirectX::XMMATRIX parent = {
parent_ltm->right.x, parent_ltm->right.y,
parent_ltm->right.z, 0,
parent_ltm->up.x, parent_ltm->up.y,
parent_ltm->up.z, 0,
parent_ltm->at.x, parent_ltm->at.y,
parent_ltm->at.z, 0,
parent_ltm->pos.x, parent_ltm->pos.y,
parent_ltm->pos.z, 1 };
DirectX::XMMATRIX res_transform = local * parent;
frame->ltm.right = { res_transform.r[0].vector4_f32[0],
res_transform.r[0].vector4_f32[1],
res_transform.r[0].vector4_f32[2] };
frame->ltm.up = { res_transform.r[1].vector4_f32[0],
res_transform.r[1].vector4_f32[1],
res_transform.r[1].vector4_f32[2] };
frame->ltm.at = { res_transform.r[2].vector4_f32[0],
res_transform.r[2].vector4_f32[1],
res_transform.r[2].vector4_f32[2] };
frame->ltm.pos = { res_transform.r[2].vector4_f32[0],
res_transform.r[2].vector4_f32[1],
res_transform.r[2].vector4_f32[2] };
/*RwMatrixMultiply( &frame->ltm,
&frame->modelling,
&( ( RwFrameGetParent( frame ) )->ltm ) );*/
/* clear flag */
rwObjectSetPrivateFlags( frame,
rwObjectGetPrivateFlags( frame ) &
~( rwFRAMEPRIVATESUBTREESYNCLTM ) );
}
/* Depth first */
/* Child has dirty status including this frame,
* sibling has dirty status of parent (parameter in)
*/
FrameSyncHierarchyLTMRecurse( frame->child, accumflags );
/* tail recursion */
frame = frame->next;
}
}
void RH_RWAPI::__rwFrameSyncHierarchyLTM( RwFrame *frame )
{
RwInt32 oldFlags;
oldFlags = rwObjectGetPrivateFlags( frame );
if ( oldFlags & rwFRAMEPRIVATESUBTREESYNCLTM )
{
/* Root of hierarchy has no parent matrix - different from rest of
* hierarchy */
// RwMatrixCopy( &frame->ltm, &frame->modelling );
frame->ltm.right = frame->modelling.right;
frame->ltm.up = frame->modelling.up;
frame->ltm.at = frame->modelling.at;
frame->ltm.pos = frame->modelling.pos;
}
/* Do the children */
FrameSyncHierarchyLTMRecurse( frame->child, oldFlags );
/* clear flag */
rwObjectSetPrivateFlags( frame,
oldFlags & ~( rwFRAMEPRIVATEHIERARCHYSYNCLTM |
rwFRAMEPRIVATESUBTREESYNCLTM ) );
}
#pragma once
#include <RWUtils/RwAPI.h>
namespace RH_RWAPI
{
static void _rwFrameInternalInit( RwFrame* frame ) noexcept;
RwFrame* _RwFrameCreate( void ) noexcept;
void _rwSetHierarchyRoot( RwFrame* frame, RwFrame* root );
void _RwFrameUpdateObjects( RwFrame* frame ) noexcept;
void _RwFrameRemoveChild( RwFrame* child );
void _RwFrameAddChild( RwFrame* parent, RwFrame* child );
RwMatrix* _RwFrameGetLTM( RwFrame* frame );
void __rwFrameSyncHierarchyLTM( RwFrame* frame );
}
\ No newline at end of file
#include "rw_framelist_read_funcs.h"
#include "rw_frame_funcs.h"
#include <DebugUtils/DebugLogger.h>
std::string RH_RWAPI::RwV3dToStr( RwV3d vec )
{
return
"x:" + std::to_string( vec.x ) + "\t"
"y:" + std::to_string( vec.y ) + "\t"
"z:" + std::to_string( vec.z );
}
rwFrameList* RH_RWAPI::_rwFrameListStreamRead( void* stream, rwFrameList* frameList )
{
using logger = RHDebug::DebugLogger;
logger::Log( "rwFrameListStreamRead start" );
struct rwStreamFrameList
{
RwInt32 numFrames;
} fl;
RwInt32 i;
RwUInt32 size;
RwUInt32 version;
if( !RwStreamFindChunk( stream, rwID_STRUCT, &size, &version ) )
return nullptr;
if( RwStreamRead( stream, &fl, sizeof( fl ) ) != sizeof( fl ) )
{
return nullptr;
}
logger::Log( "numFrames:" +
std::to_string( fl.numFrames ) );
frameList->numFrames = fl.numFrames;
frameList->frames = (RwFrame * *)malloc( sizeof( RwFrame* ) * fl.numFrames );
for( i = 0; i < fl.numFrames; i++ )
{
rwStreamFrame f;
RwFrame* frame;
RwMatrix* mat;
if( RwStreamRead( stream, &f, sizeof( f ) ) != sizeof( f ) )
{
free( frameList->frames );
return nullptr;
}
/* Create the frame */
frame = _RwFrameCreate();
if( !frame )
{
free( frameList->frames );
return nullptr;
}
logger::Log( f.to_string() );
mat = &frame->modelling;//RwFrameGetMatrix( frame );
*RwMatrixGetRight( mat ) = f.right;
*RwMatrixGetUp( mat ) = f.up;
*RwMatrixGetAt( mat ) = f.at;
*RwMatrixGetPos( mat ) = f.pos;
/*if( rwMatrixIsOrthonormalPositive( mat, _ORTHONORMAL_TOL ) )
{
rwMatrixSetFlags( mat,
rwMatrixGetFlags( mat ) &
~rwMATRIXINTERNALIDENTITY );
}
else
{
rwMatrixSetFlags( mat,
rwMatrixGetFlags( mat ) &
~( rwMATRIXINTERNALIDENTITY |
rwMATRIXTYPEORTHONORMAL ) );
}*/
frameList->frames[i] = frame;
/* Set the frame pointer */
if( f.parentIndex >= 0 )
{
_RwFrameAddChild( frameList->frames[f.parentIndex], frame );
}
}
}
#pragma once
#include <RWUtils/RwAPI.h>
namespace RH_RWAPI
{
std::string RwV3dToStr( RwV3d vec );
struct rwStreamFrame
{
RwV3d right, up, at, pos;
RwInt32 parentIndex;
RwUInt32 data;
std::string to_string() {
std::string res =
"rwStreamFrame:\n"
"at:\t" + RwV3dToStr( at ) + "\n"
"up:\t" + RwV3dToStr( up ) + "\n"
"pos:\t" + RwV3dToStr( pos ) + "\n"
"right:\t" + RwV3dToStr( right ) + "\n"
"parent:\t" + std::to_string( parentIndex ) + "\n"
"data:\t" + std::to_string( data ) + "\n";
return res;
}
};
rwFrameList* _rwFrameListStreamRead( void* stream, rwFrameList* frameList );
}
\ No newline at end of file
#include "rw_geometrylist_read_funcs.h"
#include "rp_geometry_read_funcs.h"
RH_RWAPI::rpGeometryList* RH_RWAPI::_GeometryListStreamRead( void* stream, rpGeometryList* geomList )
{
RwInt32 gl;
RwInt32 i;
RwUInt32 size;
RwUInt32 version;
if( !RwStreamFindChunk( stream, rwID_STRUCT, &size, &version ) )
{
return nullptr;
}
/* Read it */
if( RwStreamRead( stream, &gl, sizeof( gl ) ) != sizeof( gl ) )
{
return nullptr;
}
/* Set up the geometry list */
geomList->numGeoms = 0;
if( gl > 0 )
{
geomList->geometries = (RpGeometry * *)malloc( sizeof( RpGeometry* ) * gl );
if( !geomList->geometries )
{
return nullptr;
}
}
else
{
geomList->geometries = (RpGeometry * *)NULL;
}
for( i = 0; i < gl; i++ )
{
/* Read the geometry */
if( !RwStreamFindChunk( stream, rwID_GEOMETRY,
(RwUInt32*)NULL, &version ) )
{
//GeometryListDeinitialize( geomList );
return nullptr;
}
if( !( geomList->geometries[i] = _RpGeometryStreamRead( stream ) ) )
{
//GeometryListDeinitialize( geomList );
return nullptr;
}
/* Increment the number of geometries in the list */
geomList->numGeoms++;
}
return geomList;
}
\ No newline at end of file
#pragma once
#include <RWUtils/RwAPI.h>
namespace RH_RWAPI
{
struct rpGeometryList
{
RpGeometry** geometries;
RwInt32 numGeoms;
};
rpGeometryList* _GeometryListStreamRead( void* stream, rpGeometryList* geomList );
}
\ No newline at end of file
cmake_minimum_required(VERSION 3.12)
set(CMAKE_CXX_STANDARD 20)
project(DisplayModeSelectionTest)
......@@ -14,6 +13,10 @@ target_link_libraries(${PROJECT_NAME} ${DEPENDENCY_LIB_LIST} rh_engine_lib)
#set_property(TARGET ${PROJECT_NAME} PROPERTY
# MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 20
)
add_custom_command(TARGET ${PROJECT_NAME}
COMMAND ${CMAKE_COMMAND} -E copy
$ENV{VULKAN_SDK}\\Bin32\\glslangValidator.exe $<TARGET_FILE_DIR:${PROJECT_NAME}>/)
......
cmake_minimum_required(VERSION 3.12)
set(CMAKE_CXX_STANDARD 20)
include(../../rw_rh_engine_lib/install_rw_library.cmake)
project(GTAModelLoadingTest)
......@@ -14,6 +13,10 @@ include_directories(../../rw_rh_engine_lib ../../rh_engine_lib ${DEPENDENCY_INCL
add_executable(${PROJECT_NAME} WIN32 ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${DEPENDENCY_LIB_LIST} rh_engine_lib imgui::imgui)
install_rw_library()
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 20
)
#set_property(TARGET ${PROJECT_NAME} PROPERTY
# MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# Copy shaders to build destination
......
......@@ -6,7 +6,6 @@
namespace rh::engine
{
class IRenderingContext;
class D3D11ConstantBuffer;
class IPipelineLayout;
class IDescriptorSetLayout;
class IPipeline;
......
cmake_minimum_required(VERSION 3.12)
set(CMAKE_CXX_STANDARD 20)
project(InterprocessEngineTest)
......@@ -11,6 +10,10 @@ include_directories(. ../../rh_engine_lib ${DEPENDENCY_INCLUDE_LIST})
add_executable(${PROJECT_NAME} WIN32 ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${DEPENDENCY_LIB_LIST} rh_engine_lib)
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 20
)
#set_property(TARGET ${PROJECT_NAME} PROPERTY
# MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
......
cmake_minimum_required(VERSION 3.12)
set(CMAKE_CXX_STANDARD 20)
project(TextureLoadingTest)
......@@ -12,8 +11,10 @@ include_directories(../../rw_rh_engine_lib ../../rh_engine_lib ${DEPENDENCY_INCL
add_executable(TextureLoadingTest WIN32 ${SOURCES})
target_link_libraries(TextureLoadingTest ${DEPENDENCY_LIB_LIST} rh_engine_lib rw_rh_engine_lib)
#set_property(TARGET TextureLoadingTest PROPERTY
# MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 20
)
add_custom_command(TARGET ${PROJECT_NAME}
COMMAND ${CMAKE_COMMAND} -E copy
......
set(CMAKE_CXX_STANDARD 20)
project(gta_3_render_hook)
option(USE_VULKAN_API "Add RenderHook Vulkan API implementation" ON)
set(GTA_3_FOLDER CACHE PATH "GTA 3 folder")
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DLL")
include_directories(
../rh_engine_lib
../rw_rh_engine_lib
#[[
../rw_ray_tracing_lib
../rw_render_algorithms_lib]]
${DEPENDENCY_INCLUDE_LIST}
)
......@@ -35,19 +30,15 @@ set(SOURCES
config/GameRendererConfigBlock.cpp
call_redirection_util.cpp)
#set ( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON )
add_library(${PROJECT_NAME} SHARED ${SOURCES})
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fmodules-ts")
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".asi")
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 20
SUFFIX ".asi"
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${GTA_3_FOLDER}/
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${GTA_3_FOLDER}/
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${GTA_3_FOLDER}/
)
#set_target_properties(${PROJECT_NAME} PROPERTIES
# MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
add_custom_command(TARGET ${PROJECT_NAME}
COMMAND ${CMAKE_COMMAND} -E copy
......@@ -60,14 +51,12 @@ endif ()
message("ShaderPath: ${CMAKE_SOURCE_DIR}\\shaders")
message("ShaderDestPath: $<TARGET_FILE_DIR:${PROJECT_NAME}>/shaders")
# Copy shaders to build destination
add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}\\shaders ${GTA_3_FOLDER}/shaders)
#target_compile_options(${PROJECT_NAME} PRIVATE -fno-omit-frame-pointer -fsanitize=address)
#target_link_options(${PROJECT_NAME} PRIVATE -fno-omit-frame-pointer -fsanitize=address)
target_link_libraries(${PROJECT_NAME} ${DEPENDENCY_LIB_LIST}
rh_engine_lib rw_rh_engine_lib)
......
cmake_minimum_required(VERSION 3.12)
set(CMAKE_CXX_STANDARD 20)
project(gta_3_render_driver)
......@@ -18,6 +17,7 @@ add_executable(${PROJECT_NAME} WIN32 ${SOURCES})
# MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 20
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${GTA_3_FOLDER}/
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${GTA_3_FOLDER}/
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${GTA_3_FOLDER}/
......
cmake_minimum_required(VERSION 3.12)
set(CMAKE_CXX_STANDARD 20)
project(gta_sa_render_hook)
set(GTA_SA_FOLDER CACHE PATH "GTA SA folder")
......@@ -32,6 +31,7 @@ add_library(${PROJECT_NAME} SHARED ${SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".asi")
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 20
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${GTA_SA_FOLDER}/
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${GTA_SA_FOLDER}/
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${GTA_SA_FOLDER}/
......
cmake_minimum_required(VERSION 3.12)
set(CMAKE_CXX_STANDARD 20)
project(gta_sa_render_driver)
......@@ -18,6 +17,7 @@ add_executable(${PROJECT_NAME} WIN32 ${SOURCES})
# MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 20
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${GTA_SA_FOLDER}/
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${GTA_SA_FOLDER}/
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${GTA_SA_FOLDER}/
......
set(CMAKE_CXX_STANDARD 20)
project(gta_vc_render_hook)
option(USE_VULKAN_API "Add RenderHook Vulkan API implementation" ON)
set(GTA_VC_FOLDER CACHE PATH "GTA VC folder")
......@@ -18,8 +16,9 @@ set(SOURCES
#set ( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON )
add_library(${PROJECT_NAME} SHARED ${SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".asi")
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 20
SUFFIX ".asi"
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${GTA_VC_FOLDER}/
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${GTA_VC_FOLDER}/
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${GTA_VC_FOLDER}/
......
cmake_minimum_required(VERSION 3.12)
set(CMAKE_CXX_STANDARD 20)
project(gta_vc_render_driver)
......@@ -18,6 +17,7 @@ add_executable(${PROJECT_NAME} WIN32 ${SOURCES})
# MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 20
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${GTA_VC_FOLDER}/
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${GTA_VC_FOLDER}/
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${GTA_VC_FOLDER}/
......
This diff is collapsed.
......@@ -56,6 +56,21 @@ struct ImageUpdateInfo
ISampler * mSampler = nullptr;
};
/**
* Contains device limits
*/
struct DeviceLimitsInfo
{
// Alignment of an offset to buffer object
uint32_t BufferOffsetMinAlign;
uint32_t GetMinAlignedBufferEntrySize( uint32_t s ) const
{
return ( s + ( BufferOffsetMinAlign - 1 ) ) &
~( BufferOffsetMinAlign - 1 );
}
};
struct AccelStructUpdateInfo
{
void *mTLAS;
......@@ -201,6 +216,8 @@ class IDeviceState
virtual IWindow *CreateDeviceWindow( HWND window,
const OutputInfo &info ) = 0;
virtual const DeviceLimitsInfo &GetLimits() = 0;
virtual ICommandBuffer *GetMainCommandBuffer() = 0;
virtual ICommandBuffer *CreateCommandBuffer() = 0;
......
This diff is collapsed.
This diff is collapsed.
#include "D3D11ConstantBuffer.h"
#include "Engine/Common/types/constant_buffer_info.h"
#include <d3d11_3.h>
using namespace rh::engine;
D3D11ConstantBuffer::D3D11ConstantBuffer( ID3D11Device *device, const ConstantBufferInfo &info )
: D3D11BufferOld( device,
{static_cast<uint32_t>( info.size ),
D3D11_USAGE_DYNAMIC,
D3D11_BIND_CONSTANT_BUFFER,
D3D11_CPU_ACCESS_WRITE} )
{}
D3D11ConstantBuffer::~D3D11ConstantBuffer() = default;
#pragma once
#include "D3D11Buffer.h"
namespace rh::engine {
struct ConstantBufferInfo;
class D3D11ConstantBuffer : public D3D11BufferOld
{
public:
D3D11ConstantBuffer( ID3D11Device *device, const ConstantBufferInfo &info );
~D3D11ConstantBuffer() override;
};
} // namespace rh::engine
#include "D3D11DynamicIndexBuffer.h"
#include <d3d11_3.h>
using namespace rh::engine;
D3D11DynamicIndexBuffer::D3D11DynamicIndexBuffer( ID3D11Device *device, unsigned int maxIndexCount )
: D3D11BufferOld( device,
{static_cast<unsigned int>( maxIndexCount * sizeof( unsigned short ) ),
D3D11_USAGE_DYNAMIC,
D3D11_BIND_INDEX_BUFFER,
D3D11_CPU_ACCESS_WRITE} )
{}
D3D11DynamicIndexBuffer::~D3D11DynamicIndexBuffer() = default;
#pragma once
#include "D3D11Buffer.h"
namespace rh::engine {
class D3D11DynamicIndexBuffer : public D3D11BufferOld
{
public:
D3D11DynamicIndexBuffer( ID3D11Device *device, unsigned int maxIndexCount );
~D3D11DynamicIndexBuffer() override;
};
} // namespace rh::engine
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.