mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Merge pull request #12562 from iwubcode/mesh_asset
VideoCommon: add functionality to prepare for a custom mesh asset to be used by graphics mods
This commit is contained in:
@@ -75,3 +75,6 @@
|
||||
[submodule "hidapi-src"]
|
||||
path = Externals/hidapi/hidapi-src
|
||||
url = https://github.com/libusb/hidapi
|
||||
[submodule "Externals/tinygltf/tinygltf"]
|
||||
path = Externals/tinygltf/tinygltf
|
||||
url = https://github.com/syoyo/tinygltf.git
|
||||
|
||||
@@ -638,6 +638,7 @@ add_subdirectory(Externals/glslang)
|
||||
if(WIN32 OR APPLE)
|
||||
add_subdirectory(Externals/spirv_cross)
|
||||
endif()
|
||||
add_subdirectory(Externals/tinygltf)
|
||||
|
||||
if(ENABLE_VULKAN)
|
||||
add_definitions(-DHAS_VULKAN)
|
||||
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
add_library(tinygltf STATIC)
|
||||
target_compile_definitions(tinygltf PUBLIC TINYGLTF_NOEXCEPTION)
|
||||
target_compile_definitions(tinygltf PUBLIC TINYGLTF_NO_EXTERNAL_IMAGE)
|
||||
target_compile_definitions(tinygltf PUBLIC TINYGLTF_USE_CPP14)
|
||||
if (NOT MSVC)
|
||||
target_compile_features(tinygltf PRIVATE cxx_std_20)
|
||||
endif()
|
||||
target_sources(tinygltf PRIVATE
|
||||
tinygltf/tiny_gltf.cc)
|
||||
target_include_directories(tinygltf INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
dolphin_disable_warnings_msvc(tinygltf)
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ExternalsDir)tinygltf;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>TINYGLTF_NOEXCEPTION;TINYGLTF_NO_EXTERNAL_IMAGE;TINYGLTF_USE_CPP14;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(ExternalsDir)tinygltf\tinygltf.vcxproj">
|
||||
<Project>{8bda3693-4999-4d11-9e52-8d08c30b643a}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+1
Submodule Externals/tinygltf/tinygltf added at c5641f2c22
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<Import Project="..\..\Source\VSProps\Base.Macros.props" />
|
||||
<Import Project="$(VSPropsDir)Base.Targets.props" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{8bda3693-4999-4d11-9e52-8d08c30b643a}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(VSPropsDir)Configuration.StaticLibrary.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings" />
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VSPropsDir)Base.props" />
|
||||
<Import Project="$(VSPropsDir)ClDisableAllWarnings.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>tinygltf;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="tinygltf/tiny_gltf.cc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="tinygltf/json.hpp" />
|
||||
<ClInclude Include="tinygltf/stb_image.h" />
|
||||
<ClInclude Include="tinygltf/stb_image_write.h" />
|
||||
<ClInclude Include="tinygltf/tiny_gltf.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -656,6 +656,7 @@
|
||||
<ClInclude Include="VideoCommon\Assets\CustomTextureData.h" />
|
||||
<ClInclude Include="VideoCommon\Assets\DirectFilesystemAssetLibrary.h" />
|
||||
<ClInclude Include="VideoCommon\Assets\MaterialAsset.h" />
|
||||
<ClInclude Include="VideoCommon\Assets\MeshAsset.h" />
|
||||
<ClInclude Include="VideoCommon\Assets\ShaderAsset.h" />
|
||||
<ClInclude Include="VideoCommon\Assets\TextureAsset.h" />
|
||||
<ClInclude Include="VideoCommon\AsyncRequests.h" />
|
||||
@@ -1293,6 +1294,7 @@
|
||||
<ClCompile Include="VideoCommon\Assets\CustomTextureData.cpp" />
|
||||
<ClCompile Include="VideoCommon\Assets\DirectFilesystemAssetLibrary.cpp" />
|
||||
<ClCompile Include="VideoCommon\Assets\MaterialAsset.cpp" />
|
||||
<ClCompile Include="VideoCommon\Assets\MeshAsset.cpp" />
|
||||
<ClCompile Include="VideoCommon\Assets\ShaderAsset.cpp" />
|
||||
<ClCompile Include="VideoCommon\Assets\TextureAsset.cpp" />
|
||||
<ClCompile Include="VideoCommon\AsyncRequests.cpp" />
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
<Import Project="$(ExternalsDir)SFML\exports.props" />
|
||||
<Import Project="$(ExternalsDir)soundtouch\exports.props" />
|
||||
<Import Project="$(ExternalsDir)spirv_cross\exports.props" />
|
||||
<Import Project="$(ExternalsDir)tinygltf\exports.props" />
|
||||
<Import Project="$(ExternalsDir)xxhash\exports.props" />
|
||||
<Import Project="$(ExternalsDir)zlib-ng\exports.props" />
|
||||
<Import Project="$(ExternalsDir)zstd\exports.props" />
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,60 @@
|
||||
// Copyright 2023 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <picojson.h>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Matrix.h"
|
||||
|
||||
#include "VideoCommon/Assets/CustomAsset.h"
|
||||
#include "VideoCommon/NativeVertexFormat.h"
|
||||
#include "VideoCommon/RenderState.h"
|
||||
|
||||
namespace File
|
||||
{
|
||||
class IOFile;
|
||||
}
|
||||
|
||||
namespace VideoCommon
|
||||
{
|
||||
struct MeshDataChunk
|
||||
{
|
||||
std::unique_ptr<u8[]> vertex_data;
|
||||
u32 vertex_stride;
|
||||
u32 num_vertices;
|
||||
std::unique_ptr<u16[]> indices;
|
||||
u32 num_indices;
|
||||
PortableVertexDeclaration vertex_declaration;
|
||||
PrimitiveType primitive_type;
|
||||
u32 components_available;
|
||||
Common::Vec3 minimum_position;
|
||||
Common::Vec3 maximum_position;
|
||||
Common::Matrix44 transform;
|
||||
std::string material_name;
|
||||
};
|
||||
|
||||
struct MeshData
|
||||
{
|
||||
static bool FromJson(const CustomAssetLibrary::AssetID& asset_id, const picojson::object& json,
|
||||
MeshData* data);
|
||||
static void ToJson(picojson::object& obj, const MeshData& data);
|
||||
|
||||
static bool FromDolphinMesh(std::span<const u8> raw_data, MeshData* data);
|
||||
|
||||
static bool ToDolphinMesh(File::IOFile* file_data, const MeshData& data);
|
||||
|
||||
static bool FromGLTF(std::string_view gltf_file, MeshData* data);
|
||||
|
||||
std::vector<MeshDataChunk> m_mesh_chunks;
|
||||
std::map<std::string, CustomAssetLibrary::AssetID, std::less<>>
|
||||
m_mesh_material_to_material_asset_id;
|
||||
};
|
||||
} // namespace VideoCommon
|
||||
@@ -20,6 +20,8 @@ add_library(videocommon
|
||||
Assets/DirectFilesystemAssetLibrary.h
|
||||
Assets/MaterialAsset.cpp
|
||||
Assets/MaterialAsset.h
|
||||
Assets/MeshAsset.cpp
|
||||
Assets/MeshAsset.h
|
||||
Assets/ShaderAsset.cpp
|
||||
Assets/ShaderAsset.h
|
||||
Assets/TextureAsset.cpp
|
||||
@@ -216,6 +218,7 @@ PRIVATE
|
||||
imgui
|
||||
implot
|
||||
glslang
|
||||
tinygltf
|
||||
)
|
||||
|
||||
if(_M_X86_64)
|
||||
|
||||
@@ -91,6 +91,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spng", "..\Externals\libspn
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rcheevos", "..\Externals\rcheevos\rcheevos.vcxproj", "{CC99A910-3752-4465-95AA-7DC240D92A99}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinygltf", "..\Externals\tinygltf\tinygltf.vcxproj", "{8BDA3693-4999-4D11-9E52-8D08C30B643A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM64 = Debug|ARM64
|
||||
@@ -439,6 +441,14 @@ Global
|
||||
{CC99A910-3752-4465-95AA-7DC240D92A99}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{CC99A910-3752-4465-95AA-7DC240D92A99}.Release|x64.ActiveCfg = Release|x64
|
||||
{CC99A910-3752-4465-95AA-7DC240D92A99}.Release|x64.Build.0 = Release|x64
|
||||
{8BDA3693-4999-4D11-9E52-8D08C30B643A}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{8BDA3693-4999-4D11-9E52-8D08C30B643A}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{8BDA3693-4999-4D11-9E52-8D08C30B643A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{8BDA3693-4999-4D11-9E52-8D08C30B643A}.Debug|x64.Build.0 = Debug|x64
|
||||
{8BDA3693-4999-4D11-9E52-8D08C30B643A}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{8BDA3693-4999-4D11-9E52-8D08C30B643A}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{8BDA3693-4999-4D11-9E52-8D08C30B643A}.Release|x64.ActiveCfg = Release|x64
|
||||
{8BDA3693-4999-4D11-9E52-8D08C30B643A}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -477,6 +487,7 @@ Global
|
||||
{3F17D282-A77D-4931-B844-903AD0809A5E} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
|
||||
{447B7B1E-1D74-4AEF-B2B9-6EB41C5D5313} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
|
||||
{CC99A910-3752-4465-95AA-7DC240D92A99} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
|
||||
{8BDA3693-4999-4D11-9E52-8D08C30B643A} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {64B0A343-3B94-4522-9C24-6937FE5EFB22}
|
||||
|
||||
Reference in New Issue
Block a user