Skip to content

Commit b855e1c

Browse files
committed
NBL_HLSL_DEFINE_STRUCT for IESTextureInfo, update ies/profile.hlsl casts & use NBL_CONST_MEMBER_FUNC, update examples_tests submodule
1 parent 83a83a4 commit b855e1c

File tree

3 files changed

+31
-24
lines changed

3 files changed

+31
-24
lines changed

include/nbl/builtin/hlsl/ies/profile.hlsl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,48 +61,48 @@ struct ProfileProperties
6161
NO_LATERAL_SYMMET //! The luminaire is assumed to exhibit no lateral symmet
6262
};
6363

64-
Version getVersion() const
64+
Version getVersion() NBL_CONST_MEMBER_FUNC
6565
{
66-
return static_cast<Version>( packed & VERSION_MASK );
66+
return (Version)( packed & VERSION_MASK );
6767
}
6868

69-
PhotometricType getType() const
69+
PhotometricType getType() NBL_CONST_MEMBER_FUNC
7070
{
7171
const packed_flags_t shift = VERSION_BITS;
72-
return static_cast<PhotometricType>( (packed >> shift) & TYPE_MASK );
72+
return (PhotometricType)((packed >> shift) & TYPE_MASK);
7373
}
7474

75-
LuminairePlanesSymmetry getSymmetry() const
75+
LuminairePlanesSymmetry getSymmetry() NBL_CONST_MEMBER_FUNC
7676
{
7777
const packed_flags_t shift = VERSION_BITS + TYPE_BITS;
78-
return static_cast<LuminairePlanesSymmetry>( (packed >> shift) & SYMM_MASK );
78+
return (LuminairePlanesSymmetry)((packed >> shift) & SYMM_MASK);
7979
}
8080

8181
void setVersion(Version v)
8282
{
83-
packed_flags_t vBits = static_cast<packed_flags_t>(v) & VERSION_MASK;
83+
packed_flags_t vBits = (packed_flags_t)(v) & VERSION_MASK;
8484
packed = (packed & ~VERSION_MASK) | vBits;
8585
}
8686

8787
void setType(PhotometricType t)
8888
{
8989
const packed_flags_t shift = VERSION_BITS;
90-
packed_flags_t tBits = (static_cast<packed_flags_t>(t) & TYPE_MASK) << shift;
90+
packed_flags_t tBits = ((packed_flags_t)(t) & TYPE_MASK) << shift;
9191
packed = (packed & ~(TYPE_MASK << shift)) | tBits;
9292
}
9393

9494
void setSymmetry(LuminairePlanesSymmetry s)
9595
{
9696
const packed_flags_t shift = VERSION_BITS + TYPE_BITS;
97-
packed_flags_t sBits = (static_cast<packed_flags_t>(s) & SYMM_MASK) << shift;
97+
packed_flags_t sBits = ((packed_flags_t)(s) & SYMM_MASK) << shift;
9898
packed = (packed & ~(SYMM_MASK << shift)) | sBits;
9999
}
100100

101101
float32_t maxCandelaValue; //! Max candela sample value
102102
float32_t totalEmissionIntegral; //! Total emitted intensity (integral over full angular domain)
103103
float32_t fullDomainAvgEmission; //! Mean intensity over full angular domain (including I == 0)
104104
float32_t avgEmmision; //! Mean intensity over emitting solid angle (I > 0)
105-
packed_flags_t packed = 0u; //! Packed version, type and symmetry flags
105+
packed_flags_t packed; //! Packed version, type and symmetry flags
106106
};
107107

108108
}

include/nbl/builtin/hlsl/ies/texture.hlsl

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,28 @@
66
#define _NBL_BUILTIN_HLSL_IES_TEXTURE_INCLUDED_
77

88
#include "nbl/builtin/hlsl/ies/sampler.hlsl"
9+
#include "nbl/builtin/hlsl/bda/struct_declare.hlsl"
910

1011
namespace nbl
1112
{
1213
namespace hlsl
1314
{
15+
16+
// TODO(?): should be in nbl::hlsl::ies (or in the Texutre struct) but I get
17+
// error GA3909C62: class template specialization of 'member_count' not in a namespace enclosing 'bda'
18+
// which I don't want to deal with rn to not (eventually) break stuff
19+
20+
struct IESTextureInfo;
21+
NBL_HLSL_DEFINE_STRUCT((IESTextureInfo),
22+
((inv, float32_t2))
23+
((flatten, float32_t))
24+
((maxValueRecip, float32_t))
25+
((flattenTarget, float32_t))
26+
((domainLo, float32_t))
27+
((domainHi, float32_t))
28+
((fullDomainFlatten, uint16_t)) // bool
29+
);
30+
1431
namespace ies
1532
{
1633

@@ -22,19 +39,9 @@ struct Texture
2239
using sampler_t = CandelaSampler<accessor_t>;
2340
using polar_t = math::Polar<float32_t>;
2441
using octahedral_t = math::OctahedralTransform<float32_t>;
42+
using SInfo = nbl::hlsl::IESTextureInfo;
2543

26-
struct SInfo
27-
{
28-
float32_t2 inv;
29-
float32_t flatten;
30-
float32_t maxValueRecip;
31-
float32_t flattenTarget;
32-
float32_t domainLo;
33-
float32_t domainHi;
34-
bool fullDomainFlatten;
35-
};
36-
37-
static SInfo createInfo(NBL_CONST_REF_ARG(accessor_t) accessor, NBL_CONST_REF_ARG(uint32_t2) size, float32_t flatten, bool fullDomainFlatten)
44+
static inline SInfo createInfo(NBL_CONST_REF_ARG(accessor_t) accessor, NBL_CONST_REF_ARG(uint32_t2) size, float32_t flatten, bool fullDomainFlatten)
3845
{
3946
SInfo retval;
4047
const ProfileProperties props = accessor.getProperties();
@@ -57,7 +64,7 @@ struct Texture
5764
return retval;
5865
}
5966

60-
static float32_t eval(NBL_CONST_REF_ARG(accessor_t) accessor, NBL_CONST_REF_ARG(SInfo) info, NBL_CONST_REF_ARG(uint32_t2) position)
67+
static inline float32_t eval(NBL_CONST_REF_ARG(accessor_t) accessor, NBL_CONST_REF_ARG(SInfo) info, NBL_CONST_REF_ARG(uint32_t2) position)
6168
{
6269
// We don't currently support generating IES images that exploit symmetries or reduced domains, all are full octahederal mappings of a sphere.
6370
// If we did, we'd rely on MIRROR and CLAMP samplers to do some of the work for us while handling the discontinuity due to corner sampling.

0 commit comments

Comments
 (0)