mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-09-24 06:47:07 +00:00
fix: make sure matrix shader args with less than 4 rows are properly dumped and loaded
This commit is contained in:
@@ -202,7 +202,7 @@ namespace
|
||||
codeDestAccessor = targetShaderArg->m_name;
|
||||
|
||||
const auto isTransposed = targetShaderArg->m_class == d3d9::ParameterClass::MATRIX_COLUMNS;
|
||||
DumpShaderArg(technique, arg, codeDestAccessor, isTransposed);
|
||||
DumpShaderArg(technique, arg, codeDestAccessor, isTransposed, targetShaderArg->m_register_count);
|
||||
}
|
||||
|
||||
void DumpShaderArgDx11(const CommonTechnique& technique, const CommonShaderArg& arg, const d3d11::ShaderInfo& shaderInfo) const
|
||||
@@ -284,7 +284,8 @@ namespace
|
||||
}
|
||||
|
||||
const auto isTransposed = variable->m_variable_class == d3d11::VariableClass::MATRIX_COLUMNS;
|
||||
DumpShaderArg(technique, arg, codeDestAccessor, isTransposed);
|
||||
|
||||
DumpShaderArg(technique, arg, codeDestAccessor, isTransposed, variable->m_row_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -315,11 +316,15 @@ namespace
|
||||
static_cast<unsigned>(arg.m_type.m_value_type));
|
||||
return;
|
||||
}
|
||||
DumpShaderArg(technique, arg, boundTextureResource->m_name, false);
|
||||
DumpShaderArg(technique, arg, boundTextureResource->m_name, false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void DumpShaderArg(const CommonTechnique& technique, const CommonShaderArg& arg, std::string codeDestAccessor, const bool isTransposed) const
|
||||
void DumpShaderArg(const CommonTechnique& technique,
|
||||
const CommonShaderArg& arg,
|
||||
std::string codeDestAccessor,
|
||||
const bool isTransposed,
|
||||
const size_t shaderRowCount) const
|
||||
{
|
||||
if (arg.m_type.m_value_type == CommonShaderValueType::CODE_CONST)
|
||||
{
|
||||
@@ -341,9 +346,10 @@ namespace
|
||||
else
|
||||
codeAccessor = std::format("{}[{}]", constSourceInfo->accessor, arg.m_value.code_const_source.m_index - constSourceInfo->value);
|
||||
|
||||
// Assert that the value uses 4 rows when matrix and 1 otherwise.
|
||||
// If this is untrue, there must be more code handling the selected rows
|
||||
assert((isMatrix && arg.m_value.code_const_source.m_row_count == 4) || arg.m_value.code_const_source.m_row_count == 1);
|
||||
// Assert that when a code const is not a matrix, the game uses one row of it per arg
|
||||
// If it is a matrix, the game uses as many rows as can be seen in the shader
|
||||
assert(isMatrix || arg.m_value.code_const_source.m_row_count == 1);
|
||||
assert(!isMatrix || arg.m_value.code_const_source.m_row_count == shaderRowCount);
|
||||
|
||||
if (codeDestAccessor != codeAccessor)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user