Skip to content

Commit 16617e0

Browse files
committed
Revert "build(deps): Adjust to OIIO changes to TextureOpt structure (#1888)"
This reverts commit d0a598d.
1 parent 56077d2 commit 16617e0

File tree

9 files changed

+50
-152
lines changed

9 files changed

+50
-152
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ ifneq (${USE_SIMD},)
152152
MY_CMAKE_FLAGS += -DUSE_SIMD:STRING="${USE_SIMD}"
153153
endif
154154

155+
ifneq (${USE_BATCHED},)
156+
MY_CMAKE_FLAGS += -DUSE_BATCHED:STRING="${USE_BATCHED}"
157+
endif
158+
155159
ifneq (${VEC_REPORT},)
156160
MY_CMAKE_FLAGS += -DVEC_REPORT:BOOL="${VEC_REPORT}"
157161
endif
@@ -398,7 +402,7 @@ help:
398402
@echo " avx, avx2, avx512f)"
399403
@echo " OSL_USE_OPTIX=1 Build the OptiX test renderer"
400404
@echo " USE_BATCHED=targets Build batched SIMD execution of shaders for (comma-separated choices:"
401-
@echo " 0, b4_SSE2, b8_AVX, b8_AVX2, b8_AVX2_noFMA,"
405+
@echo " 0, b8_AVX, b8_AVX2, b8_AVX2_noFMA,"
402406
@echo " b8_AVX512, b8_AVX512_noFMA,"
403407
@echo " b16_AVX512, b16_AVX512_noFMA)"
404408
@echo " VEC_REPORT=0 Generate compiler vectorization reports"

src/include/OSL/batched_texture.h

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,18 @@ using OIIO::Tex::Wrap;
1818

1919
struct UniformTextureOptions {
2020
// Options that must be the same for all points we're texturing at once
21-
int firstchannel = 0; ///< First channel of the lookup
22-
int subimage = 0; ///< Subimage or face ID
23-
ustring subimagename; ///< Subimage name
24-
#if defined(OIIO_TEXTUREOPTBATCH_VERSION) && OIIO_TEXTUREOPTBATCH_VERSION >= 2
25-
// Future expansion of an ideal v2 of OIIO's TextureOptBatch. But not yet.
21+
int firstchannel = 0; ///< First channel of the lookup
22+
int subimage = 0; ///< Subimage or face ID
23+
ustring subimagename; ///< Subimage name
2624
Tex::Wrap swrap = Tex::Wrap::Default; ///< Wrap mode in the s direction
2725
Tex::Wrap twrap = Tex::Wrap::Default; ///< Wrap mode in the t direction
2826
Tex::Wrap rwrap
2927
= Tex::Wrap::Default; ///< Wrap mode in the r direction (volumetric)
3028
Tex::MipMode mipmode = Tex::MipMode::Default; ///< Mip mode
3129
Tex::InterpMode interpmode
3230
= Tex::InterpMode::SmartBicubic; ///< Interpolation mode
33-
int anisotropic = 32; ///< Maximum anisotropic ratio
34-
int conservative_filter = 1; ///< True: over-blur rather than alias
35-
#else
36-
// Original (v1) sizing and layout of the TextureOptBatch struct.
37-
int swrap = int(Tex::Wrap::Default); ///< Wrap mode in the s direction
38-
int twrap = int(Tex::Wrap::Default); ///< Wrap mode in the t direction
39-
int rwrap = int(Tex::Wrap::Default); ///< Wrap mode in r (volumetric)
40-
int mipmode = int(Tex::MipMode::Default); ///< Mip mode
41-
int interpmode = int(
42-
Tex::InterpMode::SmartBicubic); ///< Interpolation mode
43-
int anisotropic = 32; ///< Maximum anisotropic ratio
44-
int conservative_filter = 1; ///< True: over-blur rather than alias
45-
#endif
31+
int anisotropic = 32; ///< Maximum anisotropic ratio
32+
int conservative_filter = 1; ///< True: over-blur rather than alias
4633
float fill = 0.0f; ///< Fill value for missing channels
4734
const float* missingcolor = nullptr; ///< Color for missing texture
4835
};

src/liboslexec/batched_llvm_gen.cpp

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4263,15 +4263,8 @@ llvm_batched_texture_options(BatchedBackendLLVM& rop, int opnum,
42634263
llvm::Value* wide_const_fzero_value = rop.ll.wide_constant(0.0f);
42644264
llvm::Value* wide_const_fone_value = rop.ll.wide_constant(1.0f);
42654265
llvm::Value* const_zero_value = rop.ll.constant(0);
4266-
#if defined(OIIO_TEXTUREOPTBATCH_VERSION) && OIIO_TEXTUREOPTBATCH_VERSION >= 2
4267-
// Possible future TextureOptBatch v2 -- not active yet
4268-
llvm::Value* wrap_default_value = rop.ll.constant8(
4269-
static_cast<uint8_t>(Tex::Wrap::Default));
4270-
#else
4271-
// OIIO <= 3.0
4272-
llvm::Value* wrap_default_value = rop.ll.constant(
4266+
llvm::Value* wrap_default_value = rop.ll.constant(
42734267
static_cast<int>(Tex::Wrap::Default));
4274-
#endif
42754268

42764269
llvm::Value* sblur = wide_const_fzero_value;
42774270
llvm::Value* tblur = wide_const_fzero_value;
@@ -4289,19 +4282,10 @@ llvm_batched_texture_options(BatchedBackendLLVM& rop, int opnum,
42894282
llvm::Value* swrap = wrap_default_value;
42904283
llvm::Value* twrap = wrap_default_value;
42914284
llvm::Value* rwrap = wrap_default_value;
4292-
#if defined(OIIO_TEXTUREOPTBATCH_VERSION) && OIIO_TEXTUREOPTBATCH_VERSION >= 2
4293-
// Possible future TextureOptBatch v2 -- not active yet
4294-
llvm::Value* mipmode = rop.ll.constant8(
4295-
static_cast<uint8_t>(Tex::MipMode::Default));
4296-
llvm::Value* interpmode = rop.ll.constant8(
4297-
static_cast<uint8_t>(Tex::InterpMode::SmartBicubic));
4298-
#else
4299-
// OIIO <= 3.0
4300-
llvm::Value* mipmode = rop.ll.constant(
4285+
llvm::Value* mipmode = rop.ll.constant(
43014286
static_cast<int>(Tex::MipMode::Default));
43024287
llvm::Value* interpmode = rop.ll.constant(
43034288
static_cast<int>(Tex::InterpMode::SmartBicubic));
4304-
#endif
43054289
llvm::Value* anisotropic = rop.ll.constant(32);
43064290
llvm::Value* conservative_filter = rop.ll.constant(1);
43074291
llvm::Value* fill = rop.ll.constant(0.0f);
@@ -4458,7 +4442,7 @@ llvm_batched_texture_options(BatchedBackendLLVM& rop, int opnum,
44584442
}
44594443
llvm::Value* val = nullptr;
44604444
if (Val.is_constant()) {
4461-
int mode = int(TextureOpt::decode_wrapmode(Val.get_string()));
4445+
int mode = TextureOpt::decode_wrapmode(Val.get_string());
44624446
val = rop.ll.constant(mode);
44634447
} else {
44644448
val = rop.llvm_load_value(Val);
@@ -4471,33 +4455,14 @@ llvm_batched_texture_options(BatchedBackendLLVM& rop, int opnum,
44714455
}
44724456
continue;
44734457
}
4474-
#if defined(OIIO_TEXTUREOPTBATCH_VERSION) && OIIO_TEXTUREOPTBATCH_VERSION >= 2
4475-
// Possible future TextureOptBatch v2 -- not active yet
4476-
PARAM_UNIFORM_STRING_UINT8_CODE(swrap, OIIO::Tex::decode_wrapmode,
4477-
osl_texture_decode_wrapmode, swrap)
4478-
PARAM_UNIFORM_STRING_UINT8_CODE(twrap, OIIO::Tex::decode_wrapmode,
4479-
osl_texture_decode_wrapmode, twrap)
4480-
if (tex3d) {
4481-
PARAM_UNIFORM_STRING_UINT8_CODE(rwrap, OIIO::Tex::decode_wrapmode,
4482-
osl_texture_decode_wrapmode, rwrap)
4483-
}
4484-
PARAM_UNIFORM_STRING_UINT8_CODE(interp, tex_interp_to_code,
4485-
osl_texture_decode_interpmode,
4486-
interpmode)
4487-
#else
4488-
// OIIO <= 3.0
4489-
PARAM_UNIFORM_STRING_INT_CODE(swrap, OIIO::TextureOpt::decode_wrapmode,
4490-
osl_texture_decode_wrapmode, swrap)
4491-
PARAM_UNIFORM_STRING_INT_CODE(twrap, OIIO::TextureOpt::decode_wrapmode,
4492-
osl_texture_decode_wrapmode, twrap)
4458+
PARAM_UNIFORM_STRING_CODE(swrap, OIIO::TextureOpt::decode_wrapmode,
4459+
osl_texture_decode_wrapmode, swrap)
4460+
PARAM_UNIFORM_STRING_CODE(twrap, OIIO::TextureOpt::decode_wrapmode,
4461+
osl_texture_decode_wrapmode, twrap)
44934462
if (tex3d) {
4494-
PARAM_UNIFORM_STRING_INT_CODE(rwrap,
4495-
OIIO::TextureOpt::decode_wrapmode,
4496-
osl_texture_decode_wrapmode, rwrap)
4463+
PARAM_UNIFORM_STRING_CODE(rwrap, OIIO::TextureOpt::decode_wrapmode,
4464+
osl_texture_decode_wrapmode, rwrap)
44974465
}
4498-
PARAM_UNIFORM_STRING_INT_CODE(interp, tex_interp_to_code,
4499-
osl_texture_decode_interpmode, interpmode)
4500-
#endif
45014466

45024467
PARAM_UNIFORM_FLOAT(fill)
45034468
PARAM_UNIFORM_INT(firstchannel)
@@ -4519,6 +4484,10 @@ llvm_batched_texture_options(BatchedBackendLLVM& rop, int opnum,
45194484
continue;
45204485
}
45214486

4487+
PARAM_UNIFORM_STRING_CODE(interp, tex_interp_to_code,
4488+
osl_texture_decode_interpmode, interpmode)
4489+
4490+
45224491
if (name == Strings::alpha && valtype == TypeDesc::FLOAT) {
45234492
OSL_ASSERT(
45244493
valIsVarying
@@ -4605,7 +4574,7 @@ llvm_batched_texture_options(BatchedBackendLLVM& rop, int opnum,
46054574
#undef PARAM_WIDE_FLOAT_S_T_R
46064575
#undef PARAM_UNIFORM_FLOAT
46074576
#undef PARAM_UNIFORM_INT
4608-
#undef PARAM_UNIFORM_STRING_INT_CODE
4577+
#undef PARAM_UNIFORM_STRING_CODE
46094578
}
46104579

46114580
// The LLVMMemberIndex will be the same for any width of BatchedTextureOptions,

src/liboslexec/batched_llvm_instance.cpp

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -717,24 +717,14 @@ BatchedBackendLLVM::llvm_type_batched_texture_options()
717717
sg_types.push_back(ll.type_wide_float()); // rnd
718718

719719
// Uniform values of the batch
720-
sg_types.push_back(ll.type_int()); // firstchannel
721-
sg_types.push_back(ll.type_int()); // subimage
722-
sg_types.push_back(vp); // subimagename
723-
#if defined(OIIO_TEXTUREOPTBATCH_VERSION) && OIIO_TEXTUREOPTBATCH_VERSION >= 2
724-
// Possible future TextureOptBatch v2 -- not active yet
725-
sg_types.push_back(ll.type_int8()); // swrap
726-
sg_types.push_back(ll.type_int8()); // twrap
727-
sg_types.push_back(ll.type_int8()); // rwrap
728-
sg_types.push_back(ll.type_int8()); // mipmode
729-
sg_types.push_back(ll.type_int8()); // interpmode
730-
#else
731-
// OIIO <= 3.0
732-
sg_types.push_back(ll.type_int()); // swrap
733-
sg_types.push_back(ll.type_int()); // twrap
734-
sg_types.push_back(ll.type_int()); // rwrap
735-
sg_types.push_back(ll.type_int()); // mipmode
736-
sg_types.push_back(ll.type_int()); // interpmode
737-
#endif
720+
sg_types.push_back(ll.type_int()); // firstchannel
721+
sg_types.push_back(ll.type_int()); // subimage
722+
sg_types.push_back(vp); // subimagename
723+
sg_types.push_back(ll.type_int()); // swrap
724+
sg_types.push_back(ll.type_int()); // twrap
725+
sg_types.push_back(ll.type_int()); // rwrap
726+
sg_types.push_back(ll.type_int()); // mipmode
727+
sg_types.push_back(ll.type_int()); // interpmode
738728
sg_types.push_back(ll.type_int()); // anisotropic
739729
sg_types.push_back(ll.type_int()); // conservative_filter
740730
sg_types.push_back(ll.type_float()); // fill

src/liboslexec/constfold.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,10 +2494,10 @@ DECLFOLDER(constfold_texture)
24942494
// Keep from repeating the same tedious code for {s,t,r, }{width,blur,wrap}
24952495
#define CHECK(field, ctype, osltype) \
24962496
if (name == Strings::field && !field##_set) { \
2497-
if (valuetype == osltype && *(ctype*)value == (ctype)opt.field) \
2497+
if (valuetype == osltype && *(ctype*)value == opt.field) \
24982498
elide = true; \
24992499
else if (osltype == TypeDesc::FLOAT && valuetype == TypeDesc::INT \
2500-
&& *(int*)value == (int)opt.field) \
2500+
&& *(int*)value == opt.field) \
25012501
elide = true; \
25022502
else \
25032503
field##_set = true; \
@@ -2513,8 +2513,8 @@ DECLFOLDER(constfold_texture)
25132513
{ \
25142514
if (valuetype == osltype) { \
25152515
ctype* v = (ctype*)value; \
2516-
if (*v == (ctype)opt.s##field && *v == (ctype)opt.t##field \
2517-
&& *v == (ctype)opt.r##field) \
2516+
if (*v == opt.s##field && *v == opt.t##field \
2517+
&& *v == opt.r##field) \
25182518
elide = true; \
25192519
else { \
25202520
s##field##_set = true; \
@@ -2523,8 +2523,8 @@ DECLFOLDER(constfold_texture)
25232523
} \
25242524
} else if (osltype == TypeDesc::FLOAT && valuetype == TypeDesc::INT) { \
25252525
int* v = (int*)value; \
2526-
if (*v == (ctype)opt.s##field && *v == (ctype)opt.t##field \
2527-
&& *v == (ctype)opt.r##field) \
2526+
if (*v == opt.s##field && *v == opt.t##field \
2527+
&& *v == opt.r##field) \
25282528
elide = true; \
25292529
else { \
25302530
s##field##_set = true; \
@@ -2566,8 +2566,7 @@ DECLFOLDER(constfold_texture)
25662566
else if (name == Strings::interp && !interp_set)
25672567
{
25682568
if (value && valuetype == TypeDesc::STRING
2569-
&& tex_interp_to_code(*(ustring*)value)
2570-
== (int)opt.interpmode)
2569+
&& tex_interp_to_code(*(ustring*)value) == opt.interpmode)
25712570
elide = true;
25722571
else
25732572
interp_set = true;

src/liboslexec/llvm_gen.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2568,8 +2568,7 @@ llvm_gen_texture_options(BackendLLVM& rop, int opnum, int first_optional_arg,
25682568
bool sblur_set = false, tblur_set = false, rblur_set = false;
25692569
bool swrap_set = false, twrap_set = false, rwrap_set = false;
25702570
bool firstchannel_set = false, fill_set = false, interp_set = false;
2571-
// bool time_set = false;
2572-
bool subimage_set = false;
2571+
bool time_set = false, subimage_set = false;
25732572

25742573
Opcode& op(rop.inst()->ops()[opnum]);
25752574
for (int a = first_optional_arg; a < op.nargs(); ++a) {
@@ -2640,8 +2639,8 @@ llvm_gen_texture_options(BackendLLVM& rop, int opnum, int first_optional_arg,
26402639
#define PARAM_STRING_CODE(paramname, decoder, fieldname) \
26412640
if (name == Strings::paramname && valtype == TypeDesc::STRING) { \
26422641
if (Val.is_constant()) { \
2643-
int code = (int)decoder(Val.get_string()); \
2644-
if (!paramname##_set && code == (int)optdefaults.fieldname) \
2642+
int code = decoder(Val.get_string()); \
2643+
if (!paramname##_set && code == optdefaults.fieldname) \
26452644
continue; \
26462645
if (code >= 0) { \
26472646
llvm::Value* val = rop.ll.constant(code); \
@@ -2667,7 +2666,7 @@ llvm_gen_texture_options(BackendLLVM& rop, int opnum, int first_optional_arg,
26672666

26682667
if (name == Strings::wrap && valtype == TypeDesc::STRING) {
26692668
if (Val.is_constant()) {
2670-
int mode = (int)TextureOpt::decode_wrapmode(Val.get_string());
2669+
int mode = TextureOpt::decode_wrapmode(Val.get_string());
26712670
llvm::Value* val = rop.ll.constant(mode);
26722671
rop.ll.call_function("osl_texture_set_stwrap_code", opt, val);
26732672
if (tex3d)
@@ -2687,6 +2686,7 @@ llvm_gen_texture_options(BackendLLVM& rop, int opnum, int first_optional_arg,
26872686
PARAM_STRING_CODE(rwrap, TextureOpt::decode_wrapmode, rwrap)
26882687

26892688
PARAM_FLOAT(fill)
2689+
PARAM_FLOAT(time)
26902690
PARAM_INT(firstchannel)
26912691
PARAM_INT(subimage)
26922692

@@ -2745,16 +2745,6 @@ llvm_gen_texture_options(BackendLLVM& rop, int opnum, int first_optional_arg,
27452745
rop.ll.constant(nchans), val);
27462746
continue;
27472747
}
2748-
2749-
// PARAM_FLOAT(time)
2750-
if (name == Strings::time
2751-
&& (valtype == TypeDesc::FLOAT || valtype == TypeDesc::INT)) {
2752-
// NOTE: currently no supported 3d texture format makes use of
2753-
// time. So there is no time in the TextureOpt struct, but will
2754-
// silently accept and ignore the time option.
2755-
continue;
2756-
}
2757-
27582748
rop.shadingcontext()->errorfmt(
27592749
"Unknown texture{} optional argument: \"{}\", <{}> ({}:{})",
27602750
tex3d ? "3d" : "", name, valtype, op.sourcefile(), op.sourceline());

src/liboslexec/optexture.cpp

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,41 +32,6 @@ osl_get_texture_options(void* sg_)
3232
ShaderGlobals* sg = (ShaderGlobals*)sg_;
3333
TextureOpt* opt = sg->context->texture_options_ptr();
3434
new (opt) TextureOpt;
35-
#if defined(OIIO_TEXTUREOPT_VERSION) && OIIO_TEXTUREOPT_VERSION >= 2
36-
new (opt) TextureOpt;
37-
#else
38-
// TODO: Simplify when TextureOpt() has __device__ marker.
39-
TextureOpt* o = reinterpret_cast<TextureOpt*>(opt);
40-
o->firstchannel = 0;
41-
o->subimage = 0;
42-
o->subimagename = ustring();
43-
o->swrap = TextureOpt::WrapDefault;
44-
o->twrap = TextureOpt::WrapDefault;
45-
o->mipmode = TextureOpt::MipModeDefault;
46-
o->interpmode = TextureOpt::InterpSmartBicubic;
47-
o->anisotropic = 32;
48-
o->conservative_filter = true;
49-
o->sblur = 0.0f;
50-
o->tblur = 0.0f;
51-
o->swidth = 1.0f;
52-
o->twidth = 1.0f;
53-
o->fill = 0.0f;
54-
o->missingcolor = nullptr;
55-
o->time = 0.0f; // Deprecated
56-
o->rnd = -1.0f;
57-
o->samples = 1; // Deprecated
58-
o->rwrap = TextureOpt::WrapDefault;
59-
o->rblur = 0.0f;
60-
o->rwidth = 1.0f;
61-
# ifdef OIIO_TEXTURESYSTEM_SUPPORTS_COLORSPACE
62-
o->colortransformid = 0;
63-
int* envlayout = (int*)&o->colortransformid + 1;
64-
# else
65-
int* envlayout = (int*)&o->rwidth + 1;
66-
# endif
67-
// envlayout is private so we access it from the last public member for now.
68-
*envlayout = 0;
69-
#endif
7035
return opt;
7136
}
7237

@@ -80,7 +45,7 @@ osl_texture_set_firstchannel(void* opt, int x)
8045
OSL_SHADEOP int
8146
osl_texture_decode_wrapmode(ustring_pod name)
8247
{
83-
return int(OIIO::TextureOpt::decode_wrapmode(ustring_from(USTR(name))));
48+
return OIIO::TextureOpt::decode_wrapmode(ustring_from(USTR(name)));
8449
}
8550

8651
OSL_SHADEOP void
@@ -193,8 +158,7 @@ osl_texture_set_fill(void* opt, float x)
193158
OSL_SHADEOP void
194159
osl_texture_set_time(void* opt, float x)
195160
{
196-
// Not used by the texture system
197-
// ((TextureOpt*)opt)->time = x;
161+
((TextureOpt*)opt)->time = x;
198162
}
199163

200164
OSL_SHADEOP int

src/liboslexec/oslexec_pvt.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@
2525
# include "string_hash.h"
2626
#endif
2727

28-
#include <OpenImageIO/Imath.h>
29-
3028
#include <OpenImageIO/color.h>
3129
#include <OpenImageIO/paramlist.h>
3230
#include <OpenImageIO/refcnt.h>
33-
#include <OpenImageIO/texture.h>
3431
#include <OpenImageIO/thread.h>
3532
#include <OpenImageIO/ustring.h>
3633

@@ -2515,13 +2512,13 @@ tex_interp_to_code(StringParam modename)
25152512
{
25162513
int mode = -1;
25172514
if (modename == STRING_PARAMS(smartcubic))
2518-
mode = (int)TextureOpt::InterpSmartBicubic;
2515+
mode = TextureOpt::InterpSmartBicubic;
25192516
else if (modename == STRING_PARAMS(linear))
2520-
mode = (int)TextureOpt::InterpBilinear;
2517+
mode = TextureOpt::InterpBilinear;
25212518
else if (modename == STRING_PARAMS(cubic))
2522-
mode = (int)TextureOpt::InterpBicubic;
2519+
mode = TextureOpt::InterpBicubic;
25232520
else if (modename == STRING_PARAMS(closest))
2524-
mode = (int)TextureOpt::InterpClosest;
2521+
mode = TextureOpt::InterpClosest;
25252522
return mode;
25262523
}
25272524

src/testshade/rs_simplerend.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
# error OSL_HOST_RS_BITCODE must be defined by your build system.
77
#endif
88

9-
#include <OpenImageIO/fmath.h>
10-
119
#include <OSL/fmt_util.h>
1210
#include <OSL/journal.h>
1311
#include <OSL/rendererservices.h>

0 commit comments

Comments
 (0)