mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-12-27 12:31:50 +00:00
feat: dump t6 shader args
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,60 @@
|
||||
#include "CommonTechnique.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
CommonCodeSourceInfos::CommonCodeSourceInfos(const CommonCodeConstSourceInfo* codeConstSourceInfos,
|
||||
const size_t codeConstCount,
|
||||
const CommonCodeSamplerSourceInfo* codeSamplerSourceInfos,
|
||||
const size_t codeSamplerCount)
|
||||
: m_code_const_source_infos(codeConstCount),
|
||||
m_code_sampler_source_infos(codeSamplerCount)
|
||||
{
|
||||
std::copy(codeConstSourceInfos, &codeConstSourceInfos[codeConstCount], m_code_const_source_infos.data());
|
||||
std::ranges::sort(m_code_const_source_infos,
|
||||
[](const CommonCodeConstSourceInfo& a, const CommonCodeConstSourceInfo& b) -> bool
|
||||
{
|
||||
return a.value < b.value;
|
||||
});
|
||||
|
||||
std::copy(codeSamplerSourceInfos, &codeSamplerSourceInfos[codeSamplerCount], m_code_sampler_source_infos.data());
|
||||
std::ranges::sort(m_code_sampler_source_infos,
|
||||
[](const CommonCodeSamplerSourceInfo& a, const CommonCodeSamplerSourceInfo& b) -> bool
|
||||
{
|
||||
return a.value < b.value;
|
||||
});
|
||||
}
|
||||
|
||||
std::optional<CommonCodeConstSourceInfo> CommonCodeSourceInfos::GetInfoForCodeConstSource(const CommonCodeConstSource codeConstSource) const
|
||||
{
|
||||
for (const auto& codeConstSourceInfo : m_code_const_source_infos)
|
||||
{
|
||||
const auto codeConstSourceInfoEnd = static_cast<unsigned>(codeConstSourceInfo.value) + codeConstSourceInfo.arrayCount;
|
||||
if (codeConstSourceInfo.value <= codeConstSource && codeConstSourceInfoEnd >= codeConstSource)
|
||||
return codeConstSourceInfo;
|
||||
|
||||
if (codeConstSourceInfoEnd > codeConstSource)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<CommonCodeSamplerSourceInfo> CommonCodeSourceInfos::GetInfoForCodeSamplerSource(const CommonCodeSamplerSource codeSamplerSource) const
|
||||
{
|
||||
for (const auto& codeSamplerSourceInfo : m_code_sampler_source_infos)
|
||||
{
|
||||
if (codeSamplerSourceInfo.value == codeSamplerSource)
|
||||
return codeSamplerSourceInfo;
|
||||
|
||||
if (codeSamplerSourceInfo.value > codeSamplerSource)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
CommonStreamRoutingInfos::CommonStreamRoutingInfos(const CommonStreamRoutingSourceInfo* sourceInfos,
|
||||
const size_t sourceCount,
|
||||
const CommonStreamRoutingDestinationInfo* destinationNames,
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
typedef std::uint8_t CommonStreamSource;
|
||||
typedef std::uint8_t CommonStreamDestination;
|
||||
|
||||
typedef std::uint8_t CommonCodeConstSource;
|
||||
typedef std::uint8_t CommonCodeSamplerSource;
|
||||
|
||||
struct CommonStreamRoutingSourceInfo
|
||||
{
|
||||
const char* name;
|
||||
@@ -19,8 +27,44 @@ namespace techset
|
||||
const char* abbreviation;
|
||||
};
|
||||
|
||||
typedef std::uint8_t CommonStreamSource;
|
||||
typedef std::uint8_t CommonStreamDestination;
|
||||
enum class CommonCodeSourceUpdateFrequency : std::uint8_t
|
||||
{
|
||||
PER_PRIM,
|
||||
PER_OBJECT,
|
||||
RARELY,
|
||||
CUSTOM,
|
||||
};
|
||||
|
||||
struct CommonCodeConstSourceInfo
|
||||
{
|
||||
CommonCodeConstSource value;
|
||||
const char* accessor;
|
||||
std::uint8_t arrayCount;
|
||||
CommonCodeSourceUpdateFrequency updateFrequency;
|
||||
};
|
||||
|
||||
struct CommonCodeSamplerSourceInfo
|
||||
{
|
||||
CommonCodeSamplerSource value;
|
||||
const char* accessor;
|
||||
CommonCodeSourceUpdateFrequency updateFrequency;
|
||||
};
|
||||
|
||||
class CommonCodeSourceInfos
|
||||
{
|
||||
public:
|
||||
CommonCodeSourceInfos(const CommonCodeConstSourceInfo* codeConstSourceInfos,
|
||||
size_t codeConstCount,
|
||||
const CommonCodeSamplerSourceInfo* codeSamplerSourceInfos,
|
||||
size_t codeSamplerCount);
|
||||
|
||||
[[nodiscard]] std::optional<CommonCodeConstSourceInfo> GetInfoForCodeConstSource(CommonCodeConstSource codeConstSource) const;
|
||||
[[nodiscard]] std::optional<CommonCodeSamplerSourceInfo> GetInfoForCodeSamplerSource(CommonCodeSamplerSource codeSamplerSource) const;
|
||||
|
||||
private:
|
||||
std::vector<CommonCodeConstSourceInfo> m_code_const_source_infos;
|
||||
std::vector<CommonCodeSamplerSourceInfo> m_code_sampler_source_infos;
|
||||
};
|
||||
|
||||
class CommonStreamRoutingInfos
|
||||
{
|
||||
@@ -41,6 +85,58 @@ namespace techset
|
||||
std::vector<CommonStreamRoutingDestinationInfo> m_destinations;
|
||||
};
|
||||
|
||||
union CommonShaderArgValue
|
||||
{
|
||||
std::array<float, 4> literal_value;
|
||||
CommonCodeConstSource code_const_source;
|
||||
CommonCodeSamplerSource code_sampler_source;
|
||||
unsigned name_hash;
|
||||
};
|
||||
|
||||
class CommonShaderArgDestinationDx9
|
||||
{
|
||||
public:
|
||||
unsigned m_destination_register;
|
||||
};
|
||||
|
||||
class CommonShaderArgDestinationDx11
|
||||
{
|
||||
public:
|
||||
// In case of a constant: Offset in constant buffer
|
||||
// In case of a sampler: Index of sampler
|
||||
unsigned m_location;
|
||||
unsigned m_size;
|
||||
unsigned m_buffer;
|
||||
};
|
||||
|
||||
union CommonShaderArgDestination
|
||||
{
|
||||
CommonShaderArgDestinationDx9 dx9;
|
||||
CommonShaderArgDestinationDx11 dx11;
|
||||
};
|
||||
|
||||
enum class CommonShaderArgType : std::uint8_t
|
||||
{
|
||||
// Value is set to a float4 value in the pass
|
||||
LITERAL_CONST,
|
||||
// Value is set to a float4 value in the material
|
||||
MATERIAL_CONST,
|
||||
// Value is set to a float4 value calculated in code
|
||||
CODE_CONST,
|
||||
// Value is set to a sampler from the material
|
||||
MATERIAL_SAMPLER,
|
||||
// Value is set to a sampler generated in code
|
||||
CODE_SAMPLER
|
||||
};
|
||||
|
||||
class CommonShaderArg
|
||||
{
|
||||
public:
|
||||
CommonShaderArgType m_type;
|
||||
CommonShaderArgDestination m_destination;
|
||||
CommonShaderArgValue m_value;
|
||||
};
|
||||
|
||||
class CommonStreamRouting
|
||||
{
|
||||
public:
|
||||
@@ -60,6 +156,7 @@ namespace techset
|
||||
std::string m_name;
|
||||
const void* m_shader_bin;
|
||||
size_t m_shader_bin_size;
|
||||
std::vector<CommonShaderArg> m_args;
|
||||
};
|
||||
|
||||
enum class DxVersion : std::uint8_t
|
||||
|
||||
Reference in New Issue
Block a user