mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-06 16:57:25 +00:00
refactor: fix x64 compilation for ObjLoading
This commit is contained in:
@@ -83,7 +83,7 @@ namespace
|
||||
menu::MenuAssetZoneState& zoneState,
|
||||
MenuConversionZoneState& conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
AssetRegistration<AssetMenuList>& registration)
|
||||
AssetRegistration<AssetMenuList>& registration) const
|
||||
{
|
||||
const auto alreadyLoadedMenuFile = conversionState.m_menus_by_filename.find(menuFilePath);
|
||||
if (alreadyLoadedMenuFile != conversionState.m_menus_by_filename.end())
|
||||
@@ -125,12 +125,12 @@ namespace
|
||||
menu::MenuAssetZoneState& zoneState,
|
||||
MenuConversionZoneState& conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
AssetRegistration<AssetMenuList>& registration)
|
||||
AssetRegistration<AssetMenuList>& registration) const
|
||||
{
|
||||
const auto menuCount = parsingResult.m_menus.size();
|
||||
const auto functionCount = parsingResult.m_functions.size();
|
||||
const auto menuLoadCount = parsingResult.m_menus_to_load.size();
|
||||
auto totalItemCount = 0u;
|
||||
auto totalItemCount = 0uz;
|
||||
for (const auto& menu : parsingResult.m_menus)
|
||||
totalItemCount += menu->m_items.size();
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
void CreateMenuListAsset(MenuList& menuList, const std::vector<menuDef_t*>& menus)
|
||||
void CreateMenuListAsset(MenuList& menuList, const std::vector<menuDef_t*>& menus) const
|
||||
{
|
||||
menuList.menuCount = static_cast<int>(menus.size());
|
||||
|
||||
@@ -196,7 +196,8 @@ namespace
|
||||
menuList.menus = nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<menu::ParsingResult> ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState)
|
||||
std::unique_ptr<menu::ParsingResult>
|
||||
ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState) const
|
||||
{
|
||||
menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW4, m_search_path);
|
||||
|
||||
|
@@ -43,7 +43,7 @@ namespace
|
||||
zs.zfree = Z_NULL;
|
||||
zs.opaque = Z_NULL;
|
||||
zs.avail_in = static_cast<uInt>(file.m_length);
|
||||
zs.avail_out = compressionBufferSize;
|
||||
zs.avail_out = static_cast<unsigned>(compressionBufferSize);
|
||||
zs.next_in = reinterpret_cast<const Bytef*>(uncompressedBuffer.get());
|
||||
zs.next_out = reinterpret_cast<Bytef*>(compressedBuffer);
|
||||
|
||||
|
@@ -38,38 +38,38 @@ namespace
|
||||
}
|
||||
|
||||
private:
|
||||
StructuredDataType ConvertType(CommonStructuredDataType inputType)
|
||||
static StructuredDataType ConvertType(const CommonStructuredDataType inputType)
|
||||
{
|
||||
switch (inputType.m_category)
|
||||
{
|
||||
case CommonStructuredDataTypeCategory::INT:
|
||||
return {DATA_INT, {0}};
|
||||
return {.type = DATA_INT, .u = {}};
|
||||
case CommonStructuredDataTypeCategory::BYTE:
|
||||
return {DATA_BYTE, {0}};
|
||||
return {.type = DATA_BYTE, .u = {}};
|
||||
case CommonStructuredDataTypeCategory::BOOL:
|
||||
return {DATA_BOOL, {0}};
|
||||
return {.type = DATA_BOOL, .u = {}};
|
||||
case CommonStructuredDataTypeCategory::FLOAT:
|
||||
return {DATA_FLOAT, {0}};
|
||||
return {.type = DATA_FLOAT, .u = {}};
|
||||
case CommonStructuredDataTypeCategory::SHORT:
|
||||
return {DATA_SHORT, {0}};
|
||||
return {.type = DATA_SHORT, .u = {}};
|
||||
case CommonStructuredDataTypeCategory::STRING:
|
||||
return {DATA_STRING, {static_cast<unsigned>(inputType.m_info.string_length)}};
|
||||
return {.type = DATA_STRING, .u = {static_cast<unsigned>(inputType.m_info.string_length)}};
|
||||
case CommonStructuredDataTypeCategory::ENUM:
|
||||
return {DATA_ENUM, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
return {.type = DATA_ENUM, .u = {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
case CommonStructuredDataTypeCategory::STRUCT:
|
||||
return {DATA_STRUCT, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
return {.type = DATA_STRUCT, .u = {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
case CommonStructuredDataTypeCategory::INDEXED_ARRAY:
|
||||
return {DATA_INDEXED_ARRAY, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
return {.type = DATA_INDEXED_ARRAY, .u = {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
|
||||
return {DATA_ENUM_ARRAY, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
return {.type = DATA_ENUM_ARRAY, .u = {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
case CommonStructuredDataTypeCategory::UNKNOWN:
|
||||
default:
|
||||
assert(false);
|
||||
return {DATA_INT, {0}};
|
||||
return {.type = DATA_INT, .u = {0}};
|
||||
}
|
||||
}
|
||||
|
||||
void ConvertEnum(CommonStructuredDataEnum& inputEnum, StructuredDataEnum& outputEnum)
|
||||
void ConvertEnum(CommonStructuredDataEnum& inputEnum, StructuredDataEnum& outputEnum) const
|
||||
{
|
||||
outputEnum.entryCount = static_cast<int>(inputEnum.m_entries.size());
|
||||
if (inputEnum.m_reserved_entry_count <= 0)
|
||||
@@ -94,10 +94,10 @@ namespace
|
||||
outputEnum.entries = nullptr;
|
||||
}
|
||||
|
||||
void ConvertStruct(CommonStructuredDataStruct& inputStruct, StructuredDataStruct& outputStruct)
|
||||
void ConvertStruct(CommonStructuredDataStruct& inputStruct, StructuredDataStruct& outputStruct) const
|
||||
{
|
||||
outputStruct.size = static_cast<int>(inputStruct.m_size_in_byte);
|
||||
outputStruct.bitOffset = inputStruct.m_bit_offset;
|
||||
outputStruct.bitOffset = static_cast<unsigned>(inputStruct.m_bit_offset);
|
||||
|
||||
outputStruct.propertyCount = static_cast<int>(inputStruct.m_properties.size());
|
||||
inputStruct.SortPropertiesByName();
|
||||
@@ -115,34 +115,34 @@ namespace
|
||||
if (outputProperty.type.type != DATA_BOOL)
|
||||
{
|
||||
assert(inputProperty.m_offset_in_bits % 8 == 0);
|
||||
outputProperty.offset = inputProperty.m_offset_in_bits / 8;
|
||||
outputProperty.offset = static_cast<unsigned>(inputProperty.m_offset_in_bits / 8uz);
|
||||
}
|
||||
else
|
||||
outputProperty.offset = inputProperty.m_offset_in_bits;
|
||||
outputProperty.offset = static_cast<unsigned>(inputProperty.m_offset_in_bits);
|
||||
}
|
||||
}
|
||||
else
|
||||
outputStruct.properties = nullptr;
|
||||
}
|
||||
|
||||
void ConvertIndexedArray(const CommonStructuredDataIndexedArray& inputIndexedArray, StructuredDataIndexedArray& outputIndexedArray)
|
||||
static void ConvertIndexedArray(const CommonStructuredDataIndexedArray& inputIndexedArray, StructuredDataIndexedArray& outputIndexedArray)
|
||||
{
|
||||
outputIndexedArray.arraySize = static_cast<int>(inputIndexedArray.m_element_count);
|
||||
outputIndexedArray.elementType = ConvertType(inputIndexedArray.m_array_type);
|
||||
outputIndexedArray.elementSize = utils::Align(inputIndexedArray.m_element_size_in_bits, 8uz) / 8uz;
|
||||
outputIndexedArray.elementSize = static_cast<unsigned>(utils::Align(inputIndexedArray.m_element_size_in_bits, 8uz) / 8uz);
|
||||
}
|
||||
|
||||
void ConvertEnumedArray(const CommonStructuredDataEnumedArray& inputEnumedArray, StructuredDataEnumedArray& outputEnumedArray)
|
||||
{
|
||||
outputEnumedArray.enumIndex = static_cast<int>(inputEnumedArray.m_enum_index);
|
||||
outputEnumedArray.elementType = ConvertType(inputEnumedArray.m_array_type);
|
||||
outputEnumedArray.elementSize = utils::Align(inputEnumedArray.m_element_size_in_bits, 8uz) / 8uz;
|
||||
outputEnumedArray.elementSize = static_cast<unsigned>(utils::Align(inputEnumedArray.m_element_size_in_bits, 8uz) / 8uz);
|
||||
}
|
||||
|
||||
void ConvertDef(const CommonStructuredDataDef& inputDef, StructuredDataDef& outputDef)
|
||||
{
|
||||
outputDef.version = inputDef.m_version;
|
||||
outputDef.formatChecksum = inputDef.m_checksum;
|
||||
outputDef.formatChecksum = static_cast<unsigned>(inputDef.m_checksum);
|
||||
|
||||
outputDef.enumCount = static_cast<int>(inputDef.m_enums.size());
|
||||
if (!inputDef.m_enums.empty())
|
||||
@@ -185,7 +185,7 @@ namespace
|
||||
outputDef.enumedArrays = nullptr;
|
||||
|
||||
outputDef.rootType = ConvertType(inputDef.m_root_type);
|
||||
outputDef.size = inputDef.m_size_in_byte;
|
||||
outputDef.size = static_cast<unsigned>(inputDef.m_size_in_byte);
|
||||
}
|
||||
|
||||
StructuredDataDefSet* ConvertSet(const std::string& assetName, const std::vector<std::unique_ptr<CommonStructuredDataDef>>& commonDefs)
|
||||
@@ -193,7 +193,7 @@ namespace
|
||||
auto* set = m_memory.Alloc<StructuredDataDefSet>();
|
||||
set->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
set->defCount = commonDefs.size();
|
||||
set->defCount = static_cast<unsigned>(commonDefs.size());
|
||||
set->defs = m_memory.Alloc<StructuredDataDef>(commonDefs.size());
|
||||
|
||||
for (auto defIndex = 0u; defIndex < commonDefs.size(); defIndex++)
|
||||
|
@@ -31,14 +31,14 @@ namespace
|
||||
class LoadedTechnique
|
||||
{
|
||||
public:
|
||||
MaterialTechnique* m_technique;
|
||||
std::vector<XAssetInfoGeneric*> m_dependencies;
|
||||
|
||||
LoadedTechnique(MaterialTechnique* technique, std::vector<XAssetInfoGeneric*> dependencies)
|
||||
: m_technique(technique),
|
||||
m_dependencies(std::move(dependencies))
|
||||
{
|
||||
}
|
||||
|
||||
MaterialTechnique* m_technique;
|
||||
std::vector<XAssetInfoGeneric*> m_dependencies;
|
||||
};
|
||||
|
||||
class TechniqueZoneLoadingState final : public IZoneAssetCreationState
|
||||
@@ -46,8 +46,7 @@ namespace
|
||||
public:
|
||||
typedef const float (*literal_t)[4];
|
||||
|
||||
public:
|
||||
_NODISCARD const LoadedTechnique* FindLoadedTechnique(const std::string& techniqueName) const
|
||||
[[nodiscard]] const LoadedTechnique* FindLoadedTechnique(const std::string& techniqueName) const
|
||||
{
|
||||
const auto loadedTechnique = m_loaded_techniques.find(techniqueName);
|
||||
if (loadedTechnique != m_loaded_techniques.end())
|
||||
@@ -86,8 +85,6 @@ namespace
|
||||
|
||||
class ShaderInfoFromFileSystemCacheState final : public IZoneAssetCreationState
|
||||
{
|
||||
std::unordered_map<std::string, std::unique_ptr<d3d9::ShaderInfo>> m_cached_shader_info;
|
||||
|
||||
public:
|
||||
[[nodiscard]] const d3d9::ShaderInfo* LoadShaderInfoFromDisk(ISearchPath& searchPath, const std::string& fileName)
|
||||
{
|
||||
@@ -108,9 +105,9 @@ namespace
|
||||
}
|
||||
|
||||
const auto shaderData = std::make_unique<char[]>(shaderSize);
|
||||
file.m_stream->read(shaderData.get(), shaderSize);
|
||||
file.m_stream->read(shaderData.get(), static_cast<std::streamsize>(shaderSize));
|
||||
|
||||
auto shaderInfo = d3d9::ShaderAnalyser::GetShaderInfo(reinterpret_cast<const uint32_t*>(shaderData.get()), shaderSize);
|
||||
auto shaderInfo = d3d9::ShaderAnalyser::GetShaderInfo(shaderData.get(), shaderSize);
|
||||
if (!shaderInfo)
|
||||
return nullptr;
|
||||
|
||||
@@ -118,6 +115,9 @@ namespace
|
||||
m_cached_shader_info.emplace(std::make_pair(fileName, std::move(shaderInfo)));
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::unique_ptr<d3d9::ShaderInfo>> m_cached_shader_info;
|
||||
};
|
||||
|
||||
class TechniqueCreator final : public techset::ITechniqueDefinitionAcceptor
|
||||
@@ -126,10 +126,13 @@ namespace
|
||||
class PassShaderArgument
|
||||
{
|
||||
public:
|
||||
MaterialShaderArgument m_arg;
|
||||
MaterialUpdateFrequency m_update_frequency;
|
||||
explicit PassShaderArgument(const MaterialShaderArgument arg)
|
||||
: m_arg(arg),
|
||||
m_update_frequency(GetUpdateFrequencyForArg(arg))
|
||||
{
|
||||
}
|
||||
|
||||
static MaterialUpdateFrequency GetUpdateFrequencyForArg(MaterialShaderArgument arg)
|
||||
static MaterialUpdateFrequency GetUpdateFrequencyForArg(const MaterialShaderArgument arg)
|
||||
{
|
||||
switch (arg.type)
|
||||
{
|
||||
@@ -160,15 +163,22 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
explicit PassShaderArgument(const MaterialShaderArgument arg)
|
||||
: m_arg(arg),
|
||||
m_update_frequency(GetUpdateFrequencyForArg(arg))
|
||||
{
|
||||
}
|
||||
MaterialShaderArgument m_arg;
|
||||
MaterialUpdateFrequency m_update_frequency;
|
||||
};
|
||||
|
||||
struct Pass
|
||||
{
|
||||
Pass()
|
||||
: m_vertex_shader(nullptr),
|
||||
m_vertex_shader_info(nullptr),
|
||||
m_pixel_shader(nullptr),
|
||||
m_pixel_shader_info(nullptr),
|
||||
m_vertex_decl{},
|
||||
m_vertex_decl_asset(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
XAssetInfo<MaterialVertexShader>* m_vertex_shader;
|
||||
const d3d9::ShaderInfo* m_vertex_shader_info;
|
||||
std::unique_ptr<d3d9::ShaderInfo> m_vertex_shader_info_unq;
|
||||
@@ -184,21 +194,8 @@ namespace
|
||||
MaterialVertexDeclaration m_vertex_decl;
|
||||
XAssetInfo<MaterialVertexDeclaration>* m_vertex_decl_asset;
|
||||
std::vector<PassShaderArgument> m_arguments;
|
||||
|
||||
Pass()
|
||||
: m_vertex_shader(nullptr),
|
||||
m_vertex_shader_info(nullptr),
|
||||
m_pixel_shader(nullptr),
|
||||
m_pixel_shader_info(nullptr),
|
||||
m_vertex_decl{},
|
||||
m_vertex_decl_asset(nullptr)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<Pass> m_passes;
|
||||
std::vector<XAssetInfoGeneric*> m_dependencies;
|
||||
|
||||
TechniqueCreator(
|
||||
const std::string& techniqueName, ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context, ITechsetCreator* techsetCreator)
|
||||
: m_technique_name(techniqueName),
|
||||
@@ -217,10 +214,11 @@ namespace
|
||||
m_passes.emplace_back();
|
||||
}
|
||||
|
||||
static size_t RegisterCountPerElement(const d3d9::ShaderConstant& constant)
|
||||
static unsigned RegisterCountPerElement(const d3d9::ShaderConstant& constant)
|
||||
{
|
||||
const auto valuesPerRegister =
|
||||
constant.m_register_set == d3d9::RegisterSet::BOOL || constant.m_register_set == d3d9::RegisterSet::SAMPLER ? 1u : 4u;
|
||||
|
||||
return utils::Align(constant.m_type_columns * constant.m_type_rows, valuesPerRegister) / valuesPerRegister;
|
||||
}
|
||||
|
||||
@@ -243,7 +241,7 @@ namespace
|
||||
if (shaderType == techset::ShaderSelector::VERTEX_SHADER && isSamplerArgument)
|
||||
return false;
|
||||
|
||||
MaterialShaderArgument argument{};
|
||||
MaterialShaderArgument argument;
|
||||
argument.dest = static_cast<uint16_t>(shaderArgument.m_register_index + registerOffset);
|
||||
|
||||
unsigned arrayCount;
|
||||
@@ -258,7 +256,7 @@ namespace
|
||||
return false;
|
||||
|
||||
argument.type = MTL_ARG_CODE_PIXEL_SAMPLER;
|
||||
argument.u.codeSampler = samplerSource->source + elementOffset;
|
||||
argument.u.codeSampler = samplerSource->source + static_cast<unsigned>(elementOffset);
|
||||
|
||||
arrayCount = static_cast<unsigned>(samplerSource->arrayCount);
|
||||
}
|
||||
@@ -304,13 +302,12 @@ namespace
|
||||
{
|
||||
if (!AutoCreateShaderArgument(techset::ShaderSelector::VERTEX_SHADER, argument, elementIndex, registerIndex))
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "Unassigned vertex shader \"" << pass.m_vertex_shader->m_name << "\" arg: " << argument.m_name;
|
||||
|
||||
std::string elementIndexStr;
|
||||
if (argument.m_type_elements > 1)
|
||||
ss << '[' << elementIndex << ']';
|
||||
elementIndexStr = std::format("[{}]", elementIndex);
|
||||
|
||||
errorMessage = ss.str();
|
||||
errorMessage =
|
||||
std::format("Unassigned vertex shader \"{}\" arg: {}{}", pass.m_vertex_shader->m_name, argument.m_name, elementIndexStr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -572,11 +569,11 @@ namespace
|
||||
return foundSource;
|
||||
}
|
||||
|
||||
bool FindShaderArgument(const d3d9::ShaderInfo& shaderInfo,
|
||||
const techset::ShaderArgument& argument,
|
||||
size_t& constantIndex,
|
||||
size_t& registerOffset,
|
||||
std::string& errorMessage) const
|
||||
static bool FindShaderArgument(const d3d9::ShaderInfo& shaderInfo,
|
||||
const techset::ShaderArgument& argument,
|
||||
size_t& constantIndex,
|
||||
size_t& registerOffset,
|
||||
std::string& errorMessage)
|
||||
{
|
||||
const auto matchingShaderConstant = std::ranges::find_if(shaderInfo.m_constants,
|
||||
[argument](const d3d9::ShaderConstant& constant)
|
||||
@@ -854,14 +851,14 @@ namespace
|
||||
}
|
||||
|
||||
bool AcceptShaderLiteralArgument(const techset::ShaderSelector shader,
|
||||
techset::ShaderArgument shaderArgument,
|
||||
techset::ShaderArgumentLiteralSource source,
|
||||
const techset::ShaderArgument shaderArgument,
|
||||
const techset::ShaderArgumentLiteralSource source,
|
||||
std::string& errorMessage) override
|
||||
{
|
||||
assert(!m_passes.empty());
|
||||
auto& pass = m_passes.at(m_passes.size() - 1);
|
||||
|
||||
MaterialShaderArgument argument{};
|
||||
MaterialShaderArgument argument;
|
||||
const d3d9::ShaderInfo* shaderInfo;
|
||||
|
||||
if (shader == techset::ShaderSelector::VERTEX_SHADER)
|
||||
@@ -913,14 +910,14 @@ namespace
|
||||
}
|
||||
|
||||
bool AcceptShaderMaterialArgument(const techset::ShaderSelector shader,
|
||||
techset::ShaderArgument shaderArgument,
|
||||
const techset::ShaderArgument shaderArgument,
|
||||
const techset::ShaderArgumentMaterialSource source,
|
||||
std::string& errorMessage) override
|
||||
{
|
||||
assert(!m_passes.empty());
|
||||
auto& pass = m_passes.at(m_passes.size() - 1);
|
||||
|
||||
MaterialShaderArgument argument{};
|
||||
MaterialShaderArgument argument;
|
||||
const d3d9::ShaderInfo* shaderInfo;
|
||||
|
||||
if (shader == techset::ShaderSelector::VERTEX_SHADER)
|
||||
@@ -1016,6 +1013,8 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<Pass> m_passes;
|
||||
|
||||
private:
|
||||
const std::string& m_technique_name;
|
||||
ISearchPath& m_search_path;
|
||||
|
Reference in New Issue
Block a user