Skip to content

Commit 0c1e045

Browse files
move UV transform to front of SParameterSet, keep variable length stuff last
1 parent 6a4e8df commit 0c1e045

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

include/nbl/asset/material_compiler3/CFrontendIR.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class CFrontendIR final : public CNodePool
131131
float scale = std::numeric_limits<float>::infinity();
132132
// rest are ignored if the view is null
133133
uint8_t viewChannel : 2 = 0;
134-
uint8_t padding[3] = {0,0,0};
134+
uint8_t padding[3] = {0,0,0}; // TODO: padding stores metadata, shall we exclude from assignment and copy operators?
135135
core::smart_refctd_ptr<const ICPUImageView> view = {};
136136
// shadow comparison functions are ignored
137137
// NOTE: could take only things that matter from the sampler and pack the viewChannel and reduce padding
@@ -189,13 +189,13 @@ class CFrontendIR final : public CNodePool
189189
printDot<StringConstIterator>(Count,sstr,selfID,std::forward<StringConstIterator>(paramNameBegin),uvRequired);
190190
}
191191

192-
SParameter params[Count] = {};
193192
// identity transform by default, ignored if no UVs
194193
// NOTE: a transform could be applied per-param, whats important that the UV slot remains the smae across all of them.
195194
hlsl::float32_t2x3 uvTransform = hlsl::float32_t2x3(
196195
1,0,0,
197196
0,1,0
198197
);
198+
SParameter params[Count] = {};
199199

200200
// to make sure there will be no padding inbetween
201201
static_assert(alignof(SParameter)>=alignof(hlsl::float32_t2x3));

src/nbl/ext/MitsubaLoader/CMitsubaLoader.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ SAssetBundle CMitsubaLoader::loadAsset(system::IFile* _file, const IAssetLoader:
337337
}
338338

339339
ctx.transferMetadata();
340-
return asset::SAssetBundle(std::move(result.metadata),{std::move(ctx.scene)});
340+
return SAssetBundle(std::move(result.metadata),{std::move(ctx.scene)});
341341
}
342342
}
343343

@@ -503,8 +503,10 @@ hlsl::float32_t2x3 SContext::getParameters(const std::span<parameter_t,3> out, c
503503
const auto param = getTexture(src.texture,&retval);
504504
for (auto c=0; c<out.size(); c++)
505505
{
506-
out[c] = param;
506+
out[c].scale = param.scale;
507507
out[c].viewChannel = param.viewChannel+c;
508+
out[c].view = param.view;
509+
out[c].sampler = param.sampler;
508510
}
509511
}
510512
else
@@ -528,7 +530,16 @@ hlsl::float32_t2x3 SContext::getParameters(const std::span<parameter_t> out, con
528530
{
529531
auto retval = hlsl::math::linalg::diagonal<hlsl::float32_t2x3>(0.f);
530532
if (src.texture)
531-
std::fill(out.begin(),out.end(),getTexture(src.texture,&retval));
533+
{
534+
const auto param = getTexture(src.texture,&retval);
535+
for (auto c=0; c<out.size(); c++)
536+
{
537+
out[c].scale = param.scale;
538+
out[c].viewChannel = param.viewChannel+c;
539+
out[c].view = param.view;
540+
out[c].sampler = param.sampler;
541+
}
542+
}
532543
else
533544
MitsubaLoader::getParameters(out,src.value);
534545
return retval;

0 commit comments

Comments
 (0)