1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_ResTextureMapper.h
4 
5   Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Revision: 18106 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NW_GFX_RESTEXTUREMAPPER_H_
17 #define NW_GFX_RESTEXTUREMAPPER_H_
18 
19 #include <nw/types.h>
20 #include <nw/gfx/res/gfx_ResTexture.h>
21 #include <nw/gfx/gfx_CommandUtil.h>
22 
23 namespace nw {
24 namespace gfx {
25 namespace res {
26 
27 class ResGraphicsFile;
28 
29 //! @details :private
30 struct ResTextureSamplerData
31 {
32     nw::ut::ResTypeInfo typeInfo;
33     nw::ut::Offset toOwner;
34     nw::ut::ResS32 m_MinFilter;
35 };
36 
37 //! @details :private
38 struct ResStandardTextureSamplerData : public ResTextureSamplerData
39 {
40     nw::ut::ResFloatColor m_BorderColor;
41     nw::ut::ResF32 m_LodBias;
42 };
43 
44 //! @details :private
45 struct ResShadowTextureSamplerData : public ResTextureSamplerData
46 {
47 };
48 
49 //! @details :private
50 struct ResTextureMapperData
51 {
52     nw::ut::ResTypeInfo typeInfo;
53     nw::os::IAllocator* m_DynamicAllocator;
54     nw::ut::Offset toTexture;
55 };
56 
57 //! @details :private
58 struct ResPixelBasedTextureMapperData : public ResTextureMapperData
59 {
60     nw::ut::Offset toSampler;
61 
62     enum { ADDRESS_INDEX = 7 };
63 
64     nw::ut::ResU32 m_CommandCache[14];
65     nw::ut::ResU32 m_CommandSizeToSend;
66 };
67 
68 //! @details :private
69 struct ResProceduralTextureMapperData : public ResTextureMapperData
70 {
71 };
72 
73 //--------------------------------------------------------------------------
74 //! @brief  テクスチャサンプラの設定を管理するためのバイナリリソースクラスです。
75 //---------------------------------------------------------------------------
76 class ResTextureSampler : public nw::ut::ResCommon< ResTextureSamplerData >
77 {
78 public:
79     enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResTextureSampler) };
80     enum { SIGNATURE = NW_RES_SIGNATURE32('BSTS') };
81 
82     //! @brief 縮小時の補間処理です。
83     enum MinFilter
84     {
85         MINFILTER_NEAREST,                //!< ニアレスト(補間なし)で、ミップマップは使用しません。
86         MINFILTER_LINEAR,                 //!< リニア(補間あり)で、ミップマップは使用しません。
87         MINFILTER_NEAREST_MIPMAP_NEAREST, //!< ニアレスト(補間なし)で、ミップマップもニアレスト(補間なし)です。
88         MINFILTER_NEAREST_MIPMAP_LINEAR,  //!< ニアレスト(補間なし)で、ミップマップはリニア(補間あり)です。
89         MINFILTER_LINEAR_MIPMAP_NEAREST,  //!< リニア(補間あり)で、ミップマップはニアレスト(補間なし)です。
90         MINFILTER_LINEAR_MIPMAP_LINEAR    //!< リニア(補間あり)で、ミップマップもリニア(補間あり)です。
91     };
92 
93     //! @brief 拡大時の補間処理です。
94     enum MagFilter
95     {
96         MAGFILTER_NEAREST, //!< ニアレスト(補間なし)です。
97         MAGFILTER_LINEAR   //!< リニア(補間あり)です。
98     };
99 
NW_RES_CTOR(ResTextureSampler)100     NW_RES_CTOR( ResTextureSampler )
101 
102     //---------------------------------------------------------------------------
103     //! @fn           MinFilter GetMinFilter() const
104     //! @brief        縮小フィルタを取得します。
105     //---------------------------------------------------------------------------
106     MinFilter GetMinFilter() const
107     {
108         return static_cast<MinFilter>(this->ref().m_MinFilter);
109     }
110 
111     //---------------------------------------------------------------------------
112     //! @fn           void SetMinFilter(MinFilter value)
113     //! @brief        縮小フィルタを設定します。
114     //---------------------------------------------------------------------------
SetMinFilter(MinFilter value)115     void SetMinFilter(MinFilter value)
116     {
117         this->ref().m_MinFilter = static_cast<MinFilter>(value);
118 
119         ::std::pair<u32, u32*> command = GetOwnerCommand();
120 
121         enum {
122             CMD_SHIFT2 = 2,
123             CMD_MASK2 = 0x1,
124             CMD_NEAR = 0,
125             CMD_LINEAR = 1,
126             CMD_SHIFT24 = 24,
127             CMD_MASK24 = 0x1,
128             CMD_OTHER = 0,
129             CMD_MIPMAP_LINER = 1,
130             CMD_INDEX = 5
131         };
132 
133         NW_MIN_ASSERT(command.first, (CMD_INDEX + 1) * sizeof(u32));
134         NW_NULL_ASSERT(command.second);
135 
136         const u32 table2[] =
137         {
138             CMD_NEAR,
139             CMD_LINEAR,
140             CMD_NEAR,
141             CMD_NEAR,
142             CMD_LINEAR,
143             CMD_LINEAR
144         };
145         u32 value2 = table2[value];
146         internal::SetCmdValue( &command.second[CMD_INDEX], value2, CMD_MASK2, CMD_SHIFT2 );
147 
148         const u32 table24[] =
149         {
150             CMD_OTHER,
151             CMD_OTHER,
152             CMD_OTHER,
153             CMD_MIPMAP_LINER,
154             CMD_OTHER,
155             CMD_MIPMAP_LINER
156         };
157         u32 value24 = table24[value];
158 
159         internal::SetCmdValue( &command.second[CMD_INDEX], value24, CMD_MASK24, CMD_SHIFT24 );
160     }
161 
162     //---------------------------------------------------------------------------
163     //! @fn           MagFilter GetMagFilter() const
164     //! @brief        拡大フィルタを取得します。
165     //---------------------------------------------------------------------------
GetMagFilter()166     MagFilter GetMagFilter() const
167     {
168         ::std::pair<u32, u32*> command = GetOwnerCommand();
169 
170         enum { CMD_SHIFT = 1, CMD_MASK = 0x1, CMD_INDEX = 5 };
171 
172         NW_MIN_ASSERT(command.first, (CMD_INDEX + 1) * sizeof(u32));
173         NW_NULL_ASSERT(command.second);
174 
175         return static_cast<MagFilter>(internal::GetCmdValue( command.second[CMD_INDEX], CMD_MASK, CMD_SHIFT ));
176     }
177 
178     //---------------------------------------------------------------------------
179     //! @fn           void SetMagFilter(MagFilter value)
180     //! @brief        拡大フィルタを設定します。
181     //---------------------------------------------------------------------------
SetMagFilter(MagFilter value)182     void SetMagFilter(MagFilter value)
183     {
184         ::std::pair<u32, u32*> command = GetOwnerCommand();
185 
186         enum { CMD_SHIFT = 1, CMD_MASK = 0x1, CMD_INDEX = 5 };
187 
188         NW_MIN_ASSERT(command.first, (CMD_INDEX + 1) * sizeof(u32));
189         NW_NULL_ASSERT(command.second);
190 
191         internal::SetCmdValue( &command.second[CMD_INDEX], value, CMD_MASK, CMD_SHIFT );
192     }
193 
194     //---------------------------------------------------------------------------
195     //! @brief        このテクスチャサンプラーを所有するテクスチャマッパーを取得します。
196     //!
197     //! @return       テクスチャマッパーへのポインタです。
198     //---------------------------------------------------------------------------
GetOwnerData()199     ResTextureMapperData* GetOwnerData()
200     {
201         return static_cast<ResTextureMapperData*>( ref().toOwner.to_ptr() );
202     }
203 
204     //---------------------------------------------------------------------------
205     //! @brief        このテクスチャサンプラーを所有するテクスチャマッパーを取得します。
206     //!
207     //! @return       テクスチャマッパーへのポインタです。
208     //---------------------------------------------------------------------------
GetOwnerData()209     const ResTextureMapperData* GetOwnerData() const
210     {
211         return static_cast<const ResTextureMapperData*>( ref().toOwner.to_ptr() );
212     }
213 
214     //---------------------------------------------------------------------------
215     //! @brief        インスタンスの型情報を取得します。
216     //!
217     //! @return       型情報です。
218     //---------------------------------------------------------------------------
GetTypeInfo()219     nw::ut::ResTypeInfo GetTypeInfo() const { return ref().typeInfo; }
220 
221 protected:
222     //! @brief このテクスチャサンプラーを所有するテクスチャマッパーのコマンドを取得します。
223     ::std::pair<u32, u32*> GetOwnerCommand() const;
224 };
225 
226 //--------------------------------------------------------------------------
227 //! @brief 標準のテクスチャサンプラの設定を表すバイナリリソースクラスです。
228 //---------------------------------------------------------------------------
229 class ResStandardTextureSampler : public ResTextureSampler
230 {
231 public:
232     enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResStandardTextureSampler) };
233     enum { SIGNATURE = NW_RES_SIGNATURE32('STTS') };
234 
NW_RES_CTOR_INHERIT(ResStandardTextureSampler,ResTextureSampler)235     NW_RES_CTOR_INHERIT( ResStandardTextureSampler, ResTextureSampler )
236 
237     //---------------------------------------------------------------------------
238     //! @fn           const nw::ut::FloatColor & GetBorderColor() const
239     //! @brief        縁の色を取得します。
240     //---------------------------------------------------------------------------
241     const ut::FloatColor& GetBorderColor() const { return ref().m_BorderColor; }
242 
243     //---------------------------------------------------------------------------
244     //! @fn           void SetBorderColor(const ut::FloatColor& value)
245     //! @brief        縁の色を設定します。
246     //---------------------------------------------------------------------------
SetBorderColor(const ut::FloatColor & value)247     void SetBorderColor(const ut::FloatColor& value) {
248         ref().m_BorderColor = value;
249         u32 borderColorU32 = ref().m_BorderColor.ToPicaU32();
250 
251         enum { CMD_INDEX = 2 };
252         ::std::pair<u32, u32*> command = GetOwnerCommand();
253 
254         NW_MIN_ASSERT(command.first, (CMD_INDEX + 1) * sizeof(u32));
255         NW_NULL_ASSERT(command.second);
256 
257         command.second[CMD_INDEX] = borderColorU32;
258     }
259 
260     //---------------------------------------------------------------------------
261     //! @fn           void SetBorderColor(f32 r, f32 g, f32 b)
262     //! @brief        縁の色を設定します。
263     //---------------------------------------------------------------------------
SetBorderColor(f32 r,f32 g,f32 b)264     void SetBorderColor( f32 r, f32 g, f32 b )
265     {
266         ref().m_BorderColor.Set(r, g, b);
267         u32 borderColorU32 = ref().m_BorderColor.ToPicaU32();
268 
269         enum { CMD_INDEX = 2 };
270         ::std::pair<u32, u32*> command = GetOwnerCommand();
271 
272         NW_MIN_ASSERT(command.first, (CMD_INDEX + 1) * sizeof(u32));
273         NW_NULL_ASSERT(command.second);
274 
275         command.second[CMD_INDEX] = borderColorU32;
276     }
277 
278 
279         //---------------------------------------------------------------------------
280         //! @fn           void SetBorderColor(f32 r, f32 g, f32 b, f32 a)
281         //! @brief        縁の色を設定します。
282         //---------------------------------------------------------------------------
SetBorderColor(f32 r,f32 g,f32 b,f32 a)283     void SetBorderColor( f32 r, f32 g, f32 b, f32 a )
284     {
285             ref().m_BorderColor.Set(r, g, b, a);
286             u32 borderColorU32 = ref().m_BorderColor.ToPicaU32();
287 
288             enum { CMD_INDEX = 2 };
289             ::std::pair<u32, u32*> command = GetOwnerCommand();
290 
291             NW_MIN_ASSERT(command.first, (CMD_INDEX + 1) * sizeof(u32));
292             NW_NULL_ASSERT(command.second);
293 
294             command.second[CMD_INDEX] = borderColorU32;
295     }
296 
297     enum Wrap
298     {
299         WRAP_CLAMP_TO_EDGE   = 0,     //!< テクスチャの端のピクセルを引き伸ばします。
300         WRAP_CLAMP_TO_BORDER = 1,     //!< テクスチャの端でボーダーカラーを引き伸ばします。
301         WRAP_REPEAT          = 2,     //!< テクスチャの端で繰り返します。
302         WRAP_MIRRORED_REPEAT = 3      //!< テクスチャの端で反転しながら繰り返します。
303     };
304 
305     //---------------------------------------------------------------------------
306     //! @fn           Wrap GetWrapS() const
307     //! @brief        S方向の繰り返し方法を取得します。
308     //---------------------------------------------------------------------------
GetWrapS()309     Wrap GetWrapS() const
310     {
311         ::std::pair<u32, u32*> command = GetOwnerCommand();
312 
313         enum { CMD_SHIFT = 12, CMD_MASK = 0x7, CMD_INDEX = 5 };
314 
315         NW_MIN_ASSERT(command.first, (CMD_INDEX + 1) * sizeof(u32));
316         NW_NULL_ASSERT(command.second);
317 
318         return static_cast<Wrap>(internal::GetCmdValue( command.second[CMD_INDEX], CMD_MASK, CMD_SHIFT ));
319     }
320 
321     //---------------------------------------------------------------------------
322     //! @fn           void SetWrapS(Wrap value)
323     //! @brief        S方向の繰り返し方法を設定します。
324     //---------------------------------------------------------------------------
SetWrapS(Wrap value)325     void SetWrapS(Wrap value)
326     {
327         ::std::pair<u32, u32*> command = GetOwnerCommand();
328 
329         enum { CMD_SHIFT = 12, CMD_MASK = 0x7, CMD_INDEX = 5 };
330 
331         NW_MIN_ASSERT(command.first, (CMD_INDEX + 1) * sizeof(u32));
332         NW_NULL_ASSERT(command.second);
333 
334         internal::SetCmdValue( &command.second[CMD_INDEX], value, CMD_MASK, CMD_SHIFT );
335     }
336 
337     //---------------------------------------------------------------------------
338     //! @fn           Wrap GetWrapT() const
339     //! @brief        T方向の繰り返し方法を取得します。
340     //---------------------------------------------------------------------------
GetWrapT()341     Wrap GetWrapT() const
342     {
343         ::std::pair<u32, u32*> command = GetOwnerCommand();
344 
345         enum { CMD_SHIFT = 8, CMD_MASK = 0x7, CMD_INDEX = 5 };
346 
347         NW_MIN_ASSERT(command.first, (CMD_INDEX + 1) * sizeof(u32));
348         NW_NULL_ASSERT(command.second);
349 
350         return static_cast<Wrap>(internal::GetCmdValue( command.second[CMD_INDEX], CMD_MASK, CMD_SHIFT ));
351     }
352 
353     //---------------------------------------------------------------------------
354     //! @fn           void SetWrapT(Wrap value)
355     //! @brief        T方向の繰り返し方法を設定します。
356     //---------------------------------------------------------------------------
SetWrapT(Wrap value)357     void SetWrapT(Wrap value)
358     {
359         ::std::pair<u32, u32*> command = GetOwnerCommand();
360 
361         enum { CMD_SHIFT = 8, CMD_MASK = 0x7, CMD_INDEX = 5 };
362 
363         NW_MIN_ASSERT(command.first, (CMD_INDEX + 1) * sizeof(u32));
364         NW_NULL_ASSERT(command.second);
365 
366         internal::SetCmdValue( &command.second[CMD_INDEX], value, CMD_MASK, CMD_SHIFT );
367     }
368 
369     //---------------------------------------------------------------------------
370     //! @fn           u32 GetMinLod() const
371     //! @brief        最小のLevel Of Detailsを取得します。
372     //---------------------------------------------------------------------------
GetMinLod()373     u32 GetMinLod() const
374     {
375         ::std::pair<u32, u32*> command = GetOwnerCommand();
376 
377         enum { CMD_SHIFT = 24, CMD_MASK = 0xf, CMD_INDEX = 6 };
378 
379         NW_MIN_ASSERT(command.first, (CMD_INDEX + 1) * sizeof(u32));
380         NW_NULL_ASSERT(command.second);
381 
382         return static_cast<Wrap>(internal::GetCmdValue( command.second[CMD_INDEX], CMD_MASK, CMD_SHIFT ));
383     }
384 
385     //---------------------------------------------------------------------------
386     //! @fn           void SetMinLod(u32 value)
387     //! @brief        最小のLevel Of Detailsを設定します。
388     //---------------------------------------------------------------------------
SetMinLod(u32 value)389     void SetMinLod(u32 value)
390     {
391         ::std::pair<u32, u32*> command = GetOwnerCommand();
392 
393         enum { CMD_SHIFT = 24, CMD_MASK = 0xf, CMD_INDEX = 6 };
394 
395         NW_MIN_ASSERT(command.first, (CMD_INDEX + 1) * sizeof(u32));
396         NW_NULL_ASSERT(command.second);
397         NW_MINMAX_ASSERT(value, 0, 15);
398 
399         u32 minLod = value;
400         if (this->ref().m_MinFilter == ResTextureSampler::MINFILTER_NEAREST ||
401             this->ref().m_MinFilter == ResTextureSampler::MINFILTER_LINEAR)
402         {
403             minLod = 0;
404         }
405 
406         internal::SetCmdValue( &command.second[CMD_INDEX], minLod, CMD_MASK, CMD_SHIFT );
407     }
408 
409     //---------------------------------------------------------------------------
410     //! @fn           f32 GetLodBias() const
411     //! @brief        Level Of Details のバイアスを取得します。
412     //---------------------------------------------------------------------------
GetLodBias()413     f32 GetLodBias() const { return this->ref().m_LodBias; }
414 
415     //---------------------------------------------------------------------------
416     //! @fn           void SetLodBias(f32 value)
417     //! @brief        Level Of Details のバイアスを設定します。
418     //---------------------------------------------------------------------------
SetLodBias(f32 value)419     void SetLodBias(f32 value)
420     {
421         this->ref().m_LodBias = value;
422         ::std::pair<u32, u32*> command = GetOwnerCommand();
423         enum { CMD_SHIFT = 0, CMD_MASK = 0x1fff, CMD_INDEX = 6 };
424 
425         NW_MIN_ASSERT(command.first, (CMD_INDEX + 1) * sizeof(u32));
426         NW_NULL_ASSERT(command.second);
427 
428         u32 lodBias = ut::FixedS13Fraction8::Float32ToFixed13(value);
429         internal::SetCmdValue( &command.second[CMD_INDEX], lodBias, CMD_MASK, CMD_SHIFT );
430     }
431 };
432 
433 //--------------------------------------------------------------------------
434 //! @brief 影用テクスチャサンプラの設定を表すバイナリリソースクラスです。
435 //---------------------------------------------------------------------------
436 class ResShadowTextureSampler : public ResTextureSampler
437 {
438 public:
439     enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResShadowTextureSampler) };
440     enum { SIGNATURE = NW_RES_SIGNATURE32('SHTS') };
441 
442     NW_RES_CTOR_INHERIT( ResShadowTextureSampler, ResTextureSampler )
443 };
444 
445 //--------------------------------------------------------------------------
446 //! @brief テクスチャとサンプラの設定を管理し、メッシュへのテクスチャ貼り付けを表すバイナリリソースクラスです。
447 //---------------------------------------------------------------------------
448 class ResTextureMapper : public nw::ut::ResCommon< ResTextureMapperData >
449 {
450 public:
451     enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResTextureMapper) };
452     enum { SIGNATURE = NW_RES_SIGNATURE32('TMAP') };
453 
454     NW_RES_CTOR( ResTextureMapper )
455 
456     //---------------------------------------------------------------------------
457     //! @brief        テクスチャマッパーにテクスチャを設定します。
458     //!               テクスチャを設定した後にコマンドの生成を行います。
459     //!
460     //! @param[in]    resTexture テクスチャです。
461     //---------------------------------------------------------------------------
462     void SetTexture(ResTexture resTexture);
463 
464     //---------------------------------------------------------------------------
465     //! @brief        テクスチャマッパーからテクスチャを取得します。
466     //!
467     //! @return       テクスチャです。
468     //---------------------------------------------------------------------------
GetTexture()469     const ResTexture GetTexture() const { return ResTexture( ref().toTexture.to_ptr() ); }
470 
471     //---------------------------------------------------------------------------
472     //! @brief        リソースの初期化処理をおこないます。
473     //!
474     //! @param[in]    allocator アロケータです。
475     //! @param[in]    graphicsFile グラフィックスリソースです。
476     //---------------------------------------------------------------------------
477     Result Setup(os::IAllocator* allocator, ResGraphicsFile graphicsFile);
478 
479     //---------------------------------------------------------------------------
480     //! @brief        リソースの後始末をおこないます。
481     //---------------------------------------------------------------------------
482     void Cleanup();
483 
484     //---------------------------------------------------------------------------
485     //! @brief        リソースからテクスチャマッパーをクローンします。
486     //!
487     //! @param[in]    allocator アロケータです。
488     //---------------------------------------------------------------------------
489     ResTextureMapper CloneDynamic(os::IAllocator* allocator);
490 
491     //---------------------------------------------------------------------------
492     //! @brief        クローン時に必要なメモリサイズを取得します。
493     //---------------------------------------------------------------------------
494     size_t GetMemorySizeForClone(size_t alignment = os::IAllocator::DEFAULT_ALIGNMENT) const
495     {
496         os::MemorySizeCalculator size(alignment);
497 
498         GetMemorySizeForCloneInternal(&size);
499 
500         return size.GetSizeWithPadding(alignment);
501     }
502 
503     //! @details :private
504     void GetMemorySizeForCloneInternal(os::MemorySizeCalculator* pSize) const;
505 
506     //---------------------------------------------------------------------------
507     //! @brief        ResTextureMapper のリソースを破棄します。
508     //---------------------------------------------------------------------------
509     void DestroyDynamic();
510 
511     //---------------------------------------------------------------------------
512     //! @brief        リソースの型情報を取得します。
513     //!
514     //! @return       型情報です。
515     //---------------------------------------------------------------------------
GetTypeInfo()516     nw::ut::ResTypeInfo     GetTypeInfo() const { return ref().typeInfo; }
517 };
518 
519 typedef nw::ut::ResArrayClass<ResTextureMapper>::type  ResTextureMapperArray;
520 
521 //--------------------------------------------------------------------------
522 //! @brief  画像データによるテクスチャをメッシュに貼り付けるためのバイナリリソースクラスです。
523 //---------------------------------------------------------------------------
524 class ResPixelBasedTextureMapper : public ResTextureMapper
525 {
526 public:
527     enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResPixelBasedTextureMapper) };
528     enum { SIGNATURE = NW_RES_SIGNATURE32('PMAP') };
529 
530     NW_RES_CTOR_INHERIT( ResPixelBasedTextureMapper, ResTextureMapper )
531 
532     //---------------------------------------------------------------------------
533     //! @brief        テクスチャマッパーにテクスチャサンプラーを設定します。
534     //!               テクスチャサンプラーを設定した後にコマンドの生成を行います。
535     //!
536     //! @param[in]    resTextureSampler テクスチャサンプラーです。
537     //---------------------------------------------------------------------------
538     NW_DEPRECATED_FUNCTION(void SetSampler(ResTextureSampler resTextureSampler));
539 
540     //---------------------------------------------------------------------------
541     //! @brief        テクスチャマッパーからテクスチャサンプラーを取得します。
542     //!
543     //! @return       テクスチャサンプラーです。
544     //---------------------------------------------------------------------------
GetSampler()545     const ResTextureSampler  GetSampler() const { return ResTextureSampler( ref().toSampler.to_ptr() ); }
546 
547     //---------------------------------------------------------------------------
548     //! @brief        コマンドキャッシュを取得します。
549     //!
550     //! @return       コマンドキャッシュへのポインタです。
551     //---------------------------------------------------------------------------
GetCommandCache()552     u32* GetCommandCache() { return &ref().m_CommandCache[0]; }
GetCommandCache()553     const u32* GetCommandCache() const { return &ref().m_CommandCache[0]; }
554 
555     //---------------------------------------------------------------------------
556     //! @fn           void SetCommandSizeToSend(u32 value)
557     //! @brief        送信するコマンドサイズを設定します。
558     //---------------------------------------------------------------------------
559     //---------------------------------------------------------------------------
560     //! @fn           u32 GetCommandSizeToSend() const
561     //! @brief        送信するコマンドサイズを取得します。
562     //---------------------------------------------------------------------------
NW_RES_FIELD_PRIMITIVE_DECL(u32,CommandSizeToSend)563     NW_RES_FIELD_PRIMITIVE_DECL( u32, CommandSizeToSend )       // GetCommandSizeToSend(), SetCommandSizeToSend()
564 
565     //---------------------------------------------------------------------------
566     //! @brief    テクスチャ設定用のコマンドが設定されているかどうかを確認します。
567     //!
568     //! @return   すでに設定済みであれば true、設定されていなければ false を返します。
569     //---------------------------------------------------------------------------
570     bool IsCommandReady() const
571     {
572         return ref().m_CommandCache[ResPixelBasedTextureMapperData::ADDRESS_INDEX] != 0;
573     }
574 
575     //---------------------------------------------------------------------------
576     //! @brief    テクスチャ設定用のコマンドとテクスチャのバインドをリセットします。
577     //---------------------------------------------------------------------------
ResetCommand()578     void ResetCommand()
579     {
580         ref().m_CommandCache[ResPixelBasedTextureMapperData::ADDRESS_INDEX] = 0;
581     }
582 };
583 
584 typedef nw::ut::ResArrayClass<ResPixelBasedTextureMapper>::type        ResPixelBasedTextureMapperArray;
585 typedef nw::ut::ResArrayClass<const ResPixelBasedTextureMapper>::type  ResPixelBasedTextureMapperArrayConst;
586 
587 
588 //--------------------------------------------------------------------------
589 //! @brief  プロシージャルテクスチャのメッシュへの貼り付けを表すバイナリリソースクラスです。
590 //! @details :private
591 //---------------------------------------------------------------------------
592 class ResProceduralTextureMapper : public ResTextureMapper
593 {
594 public:
595     enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResProceduralTextureMapper) };
596     enum { SIGNATURE = NW_RES_SIGNATURE32('PRCM') };
597 
598     NW_RES_CTOR_INHERIT( ResProceduralTextureMapper, ResTextureMapper )
599 };
600 
601 } // namespace res
602 } // namespace gfx
603 } // namespace nw
604 
605 #endif // NW_GFX_RESTEXTUREMAPPER_H_
606