Coverage Report

Created: 2025-10-12 07:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ogre/Components/RTShaderSystem/src/OgreShaderParameter.cpp
Line
Count
Source
1
/*
2
-----------------------------------------------------------------------------
3
This source file is part of OGRE
4
(Object-oriented Graphics Rendering Engine)
5
For the latest info, see http://www.ogre3d.org/
6
7
Copyright (c) 2000-2014 Torus Knot Software Ltd
8
Permission is hereby granted, free of charge, to any person obtaining a copy
9
of this software and associated documentation files (the "Software"), to deal
10
in the Software without restriction, including without limitation the rights
11
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
copies of the Software, and to permit persons to whom the Software is
13
furnished to do so, subject to the following conditions:
14
15
The above copyright notice and this permission notice shall be included in
16
all copies or substantial portions of the Software.
17
18
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
THE SOFTWARE.
25
-----------------------------------------------------------------------------
26
*/
27
28
#include <memory>
29
30
#include "OgreShaderPrecompiledHeaders.h"
31
32
namespace Ogre {
33
namespace RTShader {
34
35
    //-----------------------------------------------------------------------
36
    // Define some ConstParameterTypes
37
    //-----------------------------------------------------------------------
38
39
    /** ConstParameterVec2 represents a Vector2 constant.
40
    */
41
    class ConstParameterVec2 : public ConstParameter<Vector2>
42
    {
43
    public:
44
        ConstParameterVec2( Vector2 val, 
45
            GpuConstantType type, 
46
            const Semantic& semantic,  
47
            const Content& content) 
48
0
            : ConstParameter<Vector2>(val, type, semantic, content)
49
0
        {
50
0
        }
51
52
0
        ~ConstParameterVec2() {}
53
54
        /** 
55
        @see Parameter::toString.
56
        */
57
        String toString () const override
58
0
        {
59
0
            StringStream str;
60
0
            str << "vec2(" << std::showpoint << mValue.x << "," << mValue.y << ")";
61
0
            return str.str();
62
0
        }
63
    };
64
65
    /** ConstParameterVec3 represents a Vector3 constant.
66
    */
67
    class ConstParameterVec3 : public ConstParameter<Vector3>
68
    {
69
    public:
70
        ConstParameterVec3( Vector3 val, 
71
            GpuConstantType type, 
72
            const Semantic& semantic,  
73
            const Content& content) 
74
0
            : ConstParameter<Vector3>(val, type, semantic, content)
75
0
        {
76
0
        }
77
0
        ~ConstParameterVec3() {}
78
79
        /** 
80
        @see Parameter::toString.
81
        */
82
        String toString () const override
83
0
        {
84
0
            StringStream str;
85
0
            str << "vec3(" << std::showpoint << mValue.x << "," << mValue.y << "," << mValue.z << ")";
86
0
            return str.str();
87
0
        }
88
    };
89
90
    /** ConstParameterVec4 represents a Vector2 Vector4.
91
    */
92
    class ConstParameterVec4 : public ConstParameter<Vector4>
93
    {
94
    public:
95
        ConstParameterVec4( Vector4 val, 
96
            GpuConstantType type, 
97
            const Semantic& semantic,  
98
            const Content& content) 
99
0
            : ConstParameter<Vector4>(val, type, semantic, content)
100
0
        {
101
0
        }
102
0
        ~ConstParameterVec4() {}
103
104
        /** 
105
        @see Parameter::toString.
106
        */
107
        String toString () const override
108
0
        {
109
0
            StringStream str;
110
0
            str << "vec4(" << std::showpoint << mValue.x << "," << mValue.y << "," << mValue.z << "," << mValue.w << ")";
111
0
            return str.str();
112
0
        }
113
    };
114
115
    /** ConstParameterFloat represents a float constant.
116
    */
117
    class ConstParameterFloat : public ConstParameter<float>
118
    {
119
    public:
120
        ConstParameterFloat(float val, 
121
            GpuConstantType type, 
122
            const Semantic& semantic,  
123
            const Content& content) 
124
0
            : ConstParameter<float>(val, type, semantic, content)
125
0
        {
126
0
        }
127
128
0
        ~ConstParameterFloat() {}
129
130
        /** 
131
        @see Parameter::toString.
132
        */
133
        String toString () const override
134
0
        {
135
0
            return StringConverter::toString(mValue, 6, 0, ' ', std::ios::showpoint);
136
0
        }
137
    };
138
    /** ConstParameterInt represents an int constant.
139
    */
140
    class ConstParameterInt : public ConstParameter<int>
141
    {
142
    public:
143
        ConstParameterInt(int val, 
144
            GpuConstantType type, 
145
            const Semantic& semantic,  
146
            const Content& content) 
147
            : ConstParameter<int>(val, type, semantic, content)
148
0
        {
149
0
        }
150
151
0
        ~ConstParameterInt() {}
152
153
        /** 
154
        @see Parameter::toString.
155
        */
156
        String toString () const override
157
0
        {
158
0
            return Ogre::StringConverter::toString(mValue);
159
0
        }
160
    };
161
162
//-----------------------------------------------------------------------
163
0
Parameter::Parameter() : mName(""), mType(GCT_UNKNOWN), mSemantic(SPS_UNKNOWN), mIndex(0), mContent(SPC_UNKNOWN), mSize(0), mUsed(false), mIsHighP(false)
164
0
{
165
0
}
166
167
//-----------------------------------------------------------------------
168
Parameter::Parameter(GpuConstantType type, const String& name, 
169
            const Semantic& semantic, int index, 
170
            int content, size_t size) :
171
0
    mName(name), mType(type), mSemantic(semantic), mIndex(index), mContent(content), mSize(size), mUsed(false), mIsHighP(false)
172
0
{
173
0
}
174
175
//-----------------------------------------------------------------------
176
UniformParameter::UniformParameter(GpuConstantType type, const String& name, 
177
                 const Semantic& semantic, int index, 
178
                 int content,
179
0
                 uint16 variability, size_t size) : Parameter(type, name, semantic, index, content, size)
180
0
{
181
0
    mIsAutoConstantReal     = false;    
182
0
    mIsAutoConstantInt      = false;
183
0
    mIsHighP                = false;
184
0
    mAutoConstantIntData    = 0;
185
0
    mVariability            = variability;
186
0
    mParamsPtr              = NULL;
187
0
    mPhysicalIndex          = -1;
188
0
    mAutoConstantType       = GpuProgramParameters::ACT_TIME;
189
0
}
190
191
static GpuConstantType getGCType(const GpuProgramParameters::AutoConstantDefinition* def)
192
0
{
193
0
    assert(def->elementType == GpuProgramParameters::ET_REAL);
194
195
0
    switch (def->elementCount)
196
0
    {
197
0
    default:
198
0
    case 1:
199
0
        return GCT_FLOAT1;
200
0
    case 2:
201
0
        return GCT_FLOAT2;
202
0
    case 3:
203
0
        return GCT_FLOAT3;
204
0
    case 4:
205
0
        return GCT_FLOAT4;
206
0
    case 8:
207
0
        return GCT_MATRIX_2X4;
208
0
    case 9:
209
0
        return GCT_MATRIX_3X3;
210
0
    case 12:
211
0
        return GCT_MATRIX_3X4;
212
0
    case 16:
213
0
        return GCT_MATRIX_4X4;
214
0
    }
215
0
}
216
217
//-----------------------------------------------------------------------
218
UniformParameter::UniformParameter(GpuProgramParameters::AutoConstantType autoType, float fAutoConstantData, size_t size)
219
0
{
220
0
    auto parameterDef = GpuProgramParameters::getAutoConstantDefinition(autoType);
221
0
    assert(parameterDef);
222
223
0
    mName               = parameterDef->name;
224
0
    if (fAutoConstantData != 0.0)
225
0
    {
226
0
        mName += StringConverter::toString(fAutoConstantData);
227
        //replace possible illegal point character in name
228
0
        std::replace(mName.begin(), mName.end(), '.', '_'); 
229
0
    }
230
0
    mType               = getGCType(parameterDef);
231
0
    mSemantic           = SPS_UNKNOWN;
232
0
    mIndex              = -1;
233
0
    mContent            = SPC_UNKNOWN;
234
0
    mIsAutoConstantReal = true; 
235
0
    mIsAutoConstantInt  = false;
236
0
    mAutoConstantType   = autoType;
237
0
    mAutoConstantRealData = fAutoConstantData;
238
0
    mVariability        = (uint16)GPV_GLOBAL;
239
0
    mParamsPtr           = NULL;
240
0
    mPhysicalIndex       = -1;
241
0
    mSize                = size;
242
0
}
243
244
//-----------------------------------------------------------------------
245
UniformParameter::UniformParameter(GpuProgramParameters::AutoConstantType autoType, float fAutoConstantData, size_t size, GpuConstantType type)
246
0
{
247
0
    auto parameterDef = GpuProgramParameters::getAutoConstantDefinition(autoType);
248
0
    assert(parameterDef);
249
250
0
    mName               = parameterDef->name;
251
0
    if (fAutoConstantData != 0.0)
252
0
    {
253
0
        mName += StringConverter::toString(fAutoConstantData);
254
        //replace possible illegal point character in name
255
0
        std::replace(mName.begin(), mName.end(), '.', '_'); 
256
0
    }
257
0
    mType               = type;
258
0
    mSemantic           = SPS_UNKNOWN;
259
0
    mIndex              = -1;
260
0
    mContent            = SPC_UNKNOWN;
261
0
    mIsAutoConstantReal = true; 
262
0
    mIsAutoConstantInt  = false;
263
0
    mAutoConstantType   = autoType;
264
0
    mAutoConstantRealData = fAutoConstantData;
265
0
    mVariability        = (uint16)GPV_GLOBAL;
266
0
    mParamsPtr           = NULL;
267
0
    mPhysicalIndex       = -1;
268
0
    mSize                = size;
269
0
}
270
271
//-----------------------------------------------------------------------
272
UniformParameter::UniformParameter(GpuProgramParameters::AutoConstantType autoType, uint32 nAutoConstantData, size_t size)
273
0
{
274
0
    auto parameterDef = GpuProgramParameters::getAutoConstantDefinition(autoType);
275
0
    assert(parameterDef);
276
277
0
    mName               = parameterDef->name;
278
0
    if (nAutoConstantData != 0)
279
0
        mName += StringConverter::toString(nAutoConstantData);
280
0
    mType               = getGCType(parameterDef);
281
0
    mSemantic           = SPS_UNKNOWN;
282
0
    mIndex              = -1;
283
0
    mContent            = SPC_UNKNOWN;
284
0
    mIsAutoConstantReal = false;    
285
0
    mIsAutoConstantInt  = true;
286
0
    mAutoConstantType   = autoType;
287
0
    mAutoConstantIntData = nAutoConstantData;
288
0
    mVariability        = (uint16)GPV_GLOBAL;
289
0
    mParamsPtr           = NULL;
290
0
    mPhysicalIndex       = -1;
291
0
    mSize                = size;
292
0
}
293
294
//-----------------------------------------------------------------------
295
UniformParameter::UniformParameter(GpuProgramParameters::AutoConstantType autoType, uint32 nAutoConstantData, size_t size, GpuConstantType type)
296
0
{
297
0
    auto parameterDef = GpuProgramParameters::getAutoConstantDefinition(autoType);
298
0
    assert(parameterDef);
299
300
0
    mName               = parameterDef->name;
301
0
    if (nAutoConstantData != 0)
302
0
        mName += StringConverter::toString(nAutoConstantData);
303
0
    mType               = type;
304
0
    mSemantic           = SPS_UNKNOWN;
305
0
    mIndex              = -1;
306
0
    mContent            = SPC_UNKNOWN;
307
0
    mIsAutoConstantReal = false;    
308
0
    mIsAutoConstantInt  = true;
309
0
    mAutoConstantType   = autoType;
310
0
    mAutoConstantIntData = nAutoConstantData;
311
0
    mVariability        = (uint16)GPV_GLOBAL;
312
0
    mParamsPtr           = NULL;
313
0
    mPhysicalIndex       = -1;
314
0
    mSize                = size;
315
0
}
316
317
//-----------------------------------------------------------------------
318
void UniformParameter::bind(GpuProgramParametersSharedPtr paramsPtr)
319
0
{
320
    // do not throw on failure: some RS optimize unused uniforms away. Also unit tests run without any RS
321
0
    const GpuConstantDefinition* def = paramsPtr->_findNamedConstantDefinition(mBindName.empty() ? mName : mBindName, false);
322
323
0
    if (def != NULL)
324
0
    {
325
0
        mParamsPtr = paramsPtr.get();
326
0
        mPhysicalIndex = def->physicalIndex;
327
0
        mElementSize = def->elementSize;
328
0
        mVariability = def->variability;
329
0
    }
330
0
}
331
332
//-----------------------------------------------------------------------
333
ParameterPtr ParameterFactory::createInPosition(int index, int content)
334
0
{
335
0
    return std::make_shared<Parameter>(GCT_FLOAT4, "iPos_" + StringConverter::toString(index),
336
0
                                       Parameter::SPS_POSITION, index,
337
0
                                       content);
338
0
}
339
340
//-----------------------------------------------------------------------
341
ParameterPtr ParameterFactory::createOutPosition(int index)
342
0
{
343
0
    return std::make_shared<Parameter>(GCT_FLOAT4, "oPos_" + StringConverter::toString(index),
344
0
        Parameter::SPS_POSITION, index, 
345
0
        Parameter::SPC_POSITION_PROJECTIVE_SPACE);
346
0
}
347
348
//-----------------------------------------------------------------------
349
ParameterPtr ParameterFactory::createInNormal(int index)
350
0
{
351
0
    return std::make_shared<Parameter>(GCT_FLOAT3, "iNormal_" + StringConverter::toString(index),
352
0
        Parameter::SPS_NORMAL, index, 
353
0
        Parameter::SPC_NORMAL_OBJECT_SPACE);
354
0
}
355
356
357
//-----------------------------------------------------------------------
358
ParameterPtr ParameterFactory::createInWeights(int index)
359
0
{
360
0
    return std::make_shared<Parameter>(GCT_FLOAT4, "iBlendWeights_" + StringConverter::toString(index),
361
0
        Parameter::SPS_BLEND_WEIGHTS, index, 
362
0
        Parameter::SPC_BLEND_WEIGHTS);
363
0
}
364
365
366
//-----------------------------------------------------------------------
367
ParameterPtr ParameterFactory::createInIndices(int index)
368
0
{
369
0
  return std::make_shared<Parameter>(
370
0
    GCT_UINT4
371
0
  , "iBlendIndices_" + StringConverter::toString(index),
372
0
        Parameter::SPS_BLEND_INDICES, index, 
373
0
        Parameter::SPC_BLEND_INDICES);
374
0
}
375
376
//-----------------------------------------------------------------------
377
ParameterPtr ParameterFactory::createInBiNormal(int index)
378
0
{
379
0
    return std::make_shared<Parameter>(GCT_FLOAT3, "iBiNormal_" + StringConverter::toString(index),
380
0
        Parameter::SPS_BINORMAL, index, 
381
0
        Parameter::SPC_BINORMAL_OBJECT_SPACE);
382
0
}
383
384
//-----------------------------------------------------------------------
385
ParameterPtr ParameterFactory::createInTangent(int index)
386
0
{
387
0
    return std::make_shared<Parameter>(GCT_FLOAT3, "iTangent_" + StringConverter::toString(index),
388
0
        Parameter::SPS_TANGENT, index, 
389
0
        Parameter::SPC_TANGENT_OBJECT_SPACE);
390
0
}
391
392
//-----------------------------------------------------------------------
393
ParameterPtr ParameterFactory::createOutNormal(int index)
394
0
{
395
0
    return std::make_shared<Parameter>(GCT_FLOAT3, "oNormal_" + StringConverter::toString(index),
396
0
        Parameter::SPS_NORMAL, index, 
397
0
        Parameter::SPC_NORMAL_OBJECT_SPACE);
398
0
}
399
400
//-----------------------------------------------------------------------
401
ParameterPtr ParameterFactory::createOutBiNormal(int index)
402
0
{
403
0
    return std::make_shared<Parameter>(GCT_FLOAT3, "oBiNormal_" + StringConverter::toString(index),
404
0
        Parameter::SPS_BINORMAL, index, 
405
0
        Parameter::SPC_BINORMAL_OBJECT_SPACE);
406
0
}
407
408
//-----------------------------------------------------------------------
409
ParameterPtr ParameterFactory::createOutTangent(int index)
410
0
{
411
0
    return std::make_shared<Parameter>(GCT_FLOAT3, "oTangent_" + StringConverter::toString(index),
412
0
        Parameter::SPS_TANGENT, index, 
413
0
        Parameter::SPC_TANGENT_OBJECT_SPACE);
414
0
}
415
416
//-----------------------------------------------------------------------
417
ParameterPtr ParameterFactory::createInColor(int index)
418
0
{
419
0
    return std::make_shared<Parameter>(GCT_FLOAT4, "iColor_" + StringConverter::toString(index),
420
0
        Parameter::SPS_COLOR, index, 
421
0
        index == 0 ? Parameter::SPC_COLOR_DIFFUSE : Parameter::SPC_COLOR_SPECULAR);
422
0
}
423
424
//-----------------------------------------------------------------------
425
ParameterPtr ParameterFactory::createOutColor(int index)
426
0
{
427
0
    return std::make_shared<Parameter>(GCT_FLOAT4, "oColor_" + StringConverter::toString(index),
428
0
        Parameter::SPS_COLOR, index, 
429
0
        index == 0 ? Parameter::SPC_COLOR_DIFFUSE : Parameter::SPC_COLOR_SPECULAR);
430
0
}
431
432
//-----------------------------------------------------------------------
433
ParameterPtr ParameterFactory::createInTexcoord(GpuConstantType type, int index, int content)
434
0
{
435
0
    switch (type)
436
0
    {
437
0
    case GCT_FLOAT1:
438
0
    case GCT_FLOAT2:
439
0
    case GCT_FLOAT3:
440
0
    case GCT_FLOAT4:
441
0
    case GCT_MATRIX_2X2:
442
0
    case GCT_MATRIX_2X3:
443
0
    case GCT_MATRIX_2X4:
444
0
    case GCT_MATRIX_3X2:
445
0
    case GCT_MATRIX_3X3:
446
0
    case GCT_MATRIX_3X4:
447
0
    case GCT_MATRIX_4X2:
448
0
    case GCT_MATRIX_4X3:
449
0
    case GCT_MATRIX_4X4:
450
0
    case GCT_INT1:
451
0
    case GCT_INT2:
452
0
    case GCT_INT3:
453
0
    case GCT_INT4:
454
0
    case GCT_UINT1:
455
0
    case GCT_UINT2:
456
0
    case GCT_UINT3:
457
0
    case GCT_UINT4:
458
0
        return std::make_shared<Parameter>(type, StringUtil::format("iTexcoord_%d", index),
459
0
                                           Parameter::SPS_TEXTURE_COORDINATES, index, content);
460
0
    default:
461
0
    case GCT_SAMPLER1D:
462
0
    case GCT_SAMPLER2D:
463
0
    case GCT_SAMPLER2DARRAY:
464
0
    case GCT_SAMPLER3D:
465
0
    case GCT_SAMPLERCUBE:
466
0
    case GCT_SAMPLER1DSHADOW:
467
0
    case GCT_SAMPLER2DSHADOW:
468
0
    case GCT_UNKNOWN:
469
0
        break;
470
0
    }
471
472
0
    return ParameterPtr();
473
0
}
474
475
//-----------------------------------------------------------------------
476
ParameterPtr ParameterFactory::createOutTexcoord(GpuConstantType type, int index, int content)
477
0
{
478
0
    switch (type)
479
0
    {
480
0
    case GCT_FLOAT1:
481
0
    case GCT_FLOAT2:
482
0
    case GCT_FLOAT3:
483
0
    case GCT_FLOAT4:
484
0
        return std::make_shared<Parameter>(type, StringUtil::format("oTexcoord_%d", index),
485
0
                                           Parameter::SPS_TEXTURE_COORDINATES, index, content);
486
0
    default:
487
0
    case GCT_SAMPLER1D:
488
0
    case GCT_SAMPLER2D:
489
0
    case GCT_SAMPLER2DARRAY:
490
0
    case GCT_SAMPLER3D:
491
0
    case GCT_SAMPLERCUBE:
492
0
    case GCT_SAMPLER1DSHADOW:
493
0
    case GCT_SAMPLER2DSHADOW:
494
0
    case GCT_MATRIX_2X2:
495
0
    case GCT_MATRIX_2X3:
496
0
    case GCT_MATRIX_2X4:
497
0
    case GCT_MATRIX_3X2:
498
0
    case GCT_MATRIX_3X3:
499
0
    case GCT_MATRIX_3X4:
500
0
    case GCT_MATRIX_4X2:
501
0
    case GCT_MATRIX_4X3:
502
0
    case GCT_MATRIX_4X4:
503
0
    case GCT_INT1:
504
0
    case GCT_INT2:
505
0
    case GCT_INT3:
506
0
    case GCT_INT4:
507
0
    case GCT_UINT1:
508
0
    case GCT_UINT2:
509
0
    case GCT_UINT3:
510
0
    case GCT_UINT4:
511
0
    case GCT_UNKNOWN:
512
0
        break;
513
0
    }
514
515
0
    return ParameterPtr();
516
0
}
517
518
//-----------------------------------------------------------------------
519
UniformParameterPtr ParameterFactory::createSampler(GpuConstantType type, int index)
520
0
{
521
0
    switch (type)
522
0
    {
523
0
    case GCT_SAMPLER1D:
524
0
        return createSampler1D(index);
525
526
0
    case GCT_SAMPLER2D:
527
0
        return createSampler2D(index);
528
529
0
    case GCT_SAMPLER2DARRAY:
530
0
        return createSampler2DArray(index);
531
532
0
    case GCT_SAMPLER3D:
533
0
        return createSampler3D(index);
534
535
0
    case GCT_SAMPLERCUBE:
536
0
        return createSamplerCUBE(index);
537
538
0
    default:
539
0
    case GCT_SAMPLER1DSHADOW:
540
0
    case GCT_SAMPLER2DSHADOW:
541
0
    case GCT_MATRIX_2X2:
542
0
    case GCT_MATRIX_2X3:
543
0
    case GCT_MATRIX_2X4:
544
0
    case GCT_MATRIX_3X2:
545
0
    case GCT_MATRIX_3X3:
546
0
    case GCT_MATRIX_3X4:
547
0
    case GCT_MATRIX_4X2:
548
0
    case GCT_MATRIX_4X3:
549
0
    case GCT_MATRIX_4X4:
550
0
    case GCT_INT1:
551
0
    case GCT_INT2:
552
0
    case GCT_INT3:
553
0
    case GCT_INT4:
554
0
    case GCT_UINT1:
555
0
    case GCT_UINT2:
556
0
    case GCT_UINT3:
557
0
    case GCT_UINT4:
558
0
    case GCT_UNKNOWN:
559
0
        break;
560
0
    }
561
562
0
    return UniformParameterPtr();
563
    
564
0
}
565
566
//-----------------------------------------------------------------------
567
UniformParameterPtr ParameterFactory::createSampler1D(int index)
568
0
{
569
0
    return std::make_shared<UniformParameter>(GCT_SAMPLER1D, "gSampler1D_" + StringConverter::toString(index),
570
0
        Parameter::SPS_UNKNOWN, index, 
571
0
        Parameter::SPC_UNKNOWN,
572
0
        (uint16)GPV_GLOBAL, 1);
573
0
}
574
575
//-----------------------------------------------------------------------
576
UniformParameterPtr ParameterFactory::createSampler2D(int index)
577
0
{
578
0
    return std::make_shared<UniformParameter>(GCT_SAMPLER2D, "gSampler2D_" + StringConverter::toString(index),
579
0
        Parameter::SPS_UNKNOWN, index, 
580
0
        Parameter::SPC_UNKNOWN,
581
0
        (uint16)GPV_GLOBAL, 1);
582
0
}
583
584
//-----------------------------------------------------------------------
585
UniformParameterPtr ParameterFactory::createSampler2DArray(int index)
586
0
{
587
0
    return std::make_shared<UniformParameter>(GCT_SAMPLER2DARRAY, "gSampler2DArray_" + StringConverter::toString(index),
588
0
                                                         Parameter::SPS_UNKNOWN, index, 
589
0
                                                         Parameter::SPC_UNKNOWN,
590
0
                                                         (uint16)GPV_GLOBAL, 1);
591
0
}
592
593
//-----------------------------------------------------------------------
594
UniformParameterPtr ParameterFactory::createSampler3D(int index)
595
0
{
596
0
    return std::make_shared<UniformParameter>(GCT_SAMPLER3D, "gSampler3D_" + StringConverter::toString(index),
597
0
        Parameter::SPS_UNKNOWN, index, 
598
0
        Parameter::SPC_UNKNOWN,
599
0
        (uint16)GPV_GLOBAL, 1);
600
0
}
601
602
//-----------------------------------------------------------------------
603
UniformParameterPtr ParameterFactory::createSamplerCUBE(int index)
604
0
{
605
0
    return std::make_shared<UniformParameter>(GCT_SAMPLERCUBE, "gSamplerCUBE_" + StringConverter::toString(index),
606
0
        Parameter::SPS_UNKNOWN, index, 
607
0
        Parameter::SPC_UNKNOWN,
608
0
        (uint16)GPV_GLOBAL, 1);
609
0
}
610
//-----------------------------------------------------------------------
611
ParameterPtr ParameterFactory::createConstParam(const Vector2& val)
612
0
{
613
0
    return ParameterPtr(OGRE_NEW ConstParameterVec2(val, GCT_FLOAT2, Parameter::SPS_UNKNOWN,
614
0
                                                    Parameter::SPC_UNKNOWN));
615
0
}
616
617
//-----------------------------------------------------------------------
618
ParameterPtr ParameterFactory::createConstParam(const Vector3& val)
619
0
{
620
0
    return ParameterPtr(OGRE_NEW ConstParameterVec3(val, GCT_FLOAT3, Parameter::SPS_UNKNOWN,
621
0
                                                    Parameter::SPC_UNKNOWN));
622
0
}
623
624
//-----------------------------------------------------------------------
625
ParameterPtr ParameterFactory::createConstParam(const Vector4& val)
626
0
{
627
0
    return ParameterPtr(OGRE_NEW ConstParameterVec4(val, GCT_FLOAT4, Parameter::SPS_UNKNOWN,
628
0
                                                    Parameter::SPC_UNKNOWN));
629
0
}
630
631
//-----------------------------------------------------------------------
632
ParameterPtr ParameterFactory::createConstParam(float val)
633
0
{
634
0
    return ParameterPtr(OGRE_NEW ConstParameterFloat(val, GCT_FLOAT1, Parameter::SPS_UNKNOWN,
635
0
                                                     Parameter::SPC_UNKNOWN));
636
0
}
637
638
//-----------------------------------------------------------------------
639
UniformParameterPtr ParameterFactory::createUniform(GpuConstantType type, 
640
                                             int index, uint16 variability,
641
                                             const String& suggestedName,
642
                                             size_t size)
643
0
{
644
0
    UniformParameterPtr param;
645
    
646
0
    param = std::make_shared<UniformParameter>(type, suggestedName + StringConverter::toString(index),
647
0
        Parameter::SPS_UNKNOWN, index, 
648
0
        Parameter::SPC_UNKNOWN, variability, size);
649
        
650
0
    return param;
651
0
}
652
653
}
654
}