1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
3  <head>
4    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5    <meta http-equiv="Content-Style-Type" content="text/css" />
6    <link rel="stylesheet" href="../../../../css/manpage.css" type="text/css" />
7    <style type="text/css"><!--
8      span.static_style
9      {
10        font-size			: 8pt;
11        color				: white;
12        font-weight			: bold;
13        background			: #44f;
14        border-left			: solid 1px #aaf;
15        border-top			: solid 1px #aaf;
16        border-right		: solid 1px #00c;
17        border-bottom		: solid 1px #00c;
18        padding-left		: 2px;
19        padding-right		: 2px;
20      }
21      span.virtual_style
22      {
23        font-size			 : 8pt;
24        color				 : white;
25        font-weight			: bold;
26        background			: #0a0;
27        border-left			: solid 1px #0f0;
28        border-top			: solid 1px #0f0;
29        border-right		: solid 1px #060;
30        border-bottom		: solid 1px #060;
31        padding-left		: 2px;
32        padding-right		: 2px;
33      }
34      span.protected_style
35      {
36        font-size			 : 8pt;
37        color				 : white;
38        font-weight			: bold;
39        background			: #444;
40        border-left			: solid 1px #ccc;
41        border-top			: solid 1px #ccc;
42        border-right		: solid 1px #222;
43        border-bottom		: solid 1px #222;
44        padding-left		: 2px;
45        padding-right		: 2px;
46      }
47        --></style>
48<title>nn::gd::CTR::Resource</title>
49  </head>
50  <body>
51<h1><CODE><a href="../../../../nn/Overview.html">nn</a>::<a href="../../../../nn/gd/Overview.html">gd</a>::<a href="../../../../nn/gd/CTR/Overview.html">CTR</a>::Resource</CODE> Class</h1>
52<h2>Syntax</h2>
53    <div class="section">
54<pre class="definition">class Resource</pre>
55    </div>
56<h2>Description</h2>
57    <div class="section">
58<p>The class of resource functions.</p><p><anchor id="classnn_1_1gd_1_1_c_t_r_1_1_resource_1Resource" />The term <I>resource </I> refers to two-dimensional regions like pixels (<CODE>Texture2DResource</CODE>), as well as regions like vertex buffers and index buffers (<CODE>VertexBufferResource)</CODE>. When a resource is created, memory is allocated to the resource. Resources are created using the <CODE>ResourceCreateTexture2DResource</CODE> function or the <CODE>ResourceCreateVertexBufferResource</CODE> function. When a resource is released, the allocated memory is also released. <br /><br /><br /><B>Note: </B><B>Relation between resources and the NNGX command request queue</B><br /><br /> You need to be careful when releasing <SPAN class="argument">initialData</SPAN> passed to the <CODE><a href="../../../../nn/gd/CTR/Resource/CreateTexture2DResource.html">Resource::CreateTexture2DResource</a></CODE> function or the <CODE>ResourceCreateVertexBufferResource</CODE> function. If <CODE><a href="../../../../nn/gd/CTR/Texture2DResourceDescription/Overview.html">Texture2DResourceDescription.m_MemLocation</a></CODE> has been set to <CODE>MemoryVRAMA</CODE> or <CODE>MemoryVRAMB</CODE>, problems can occur if <CODE>initialData</CODE> is released immediately after the resource has been created. If <CODE>Texture2DResourceDescription.m_MemLocation</CODE> is set to a VRAM  location, then DMA transfer requests for the <CODE>initialData</CODE> data will accumulate in the command buffer. It is a copy of the actual data that is used when commands execute. For this reason, the user application must retain <SPAN class="argument">initialData</SPAN> until the commands have finished executing. <br /> Remark: If <SPAN class="argument">initialData</SPAN> is created in FCRAM, then the data are transferred using the <CODE>memcpy</CODE> function, so it is all right to release <SPAN class="argument">initialData</SPAN> immediately after creating the resource. <br /><br /><br /><B>For Texture2DResource resources</B><br /><br /> <CODE>Texture2DResource</CODE> resources cannot be bound directly to pipeline stages, so they must be created using <CODE>Texture2DResource</CODE> from inside the following objects:</p><p><itemizedlist><listitem><para><CODE>Texture2</CODE> is created using the <CODE>TextureStageCreateTexture2D</CODE> function.<br /></para></listitem><listitem><para><CODE>TextureCube</CODE> is created using the <CODE>TextureStageCreateTextureCube</CODE> function.<br /></para></listitem><listitem><para><CODE>RenderTarget</CODE> is created using the <CODE>OutputStageCreateRenderTarget</CODE> function. <br /></para></listitem><listitem><para>Create <CODE>DepthStencilTarget</CODE> using the <CODE>OutputStageCreateDepthStencilTarget</CODE> function. <br /></para></listitem></itemizedlist><br /> This mechanism allows you to use a single resource in a number of different ways in the user application. For example, after you have bound some <CODE>Texture2DResource</CODE> resource to a <CODE>RenderTarget</CODE> and completed the render task, you could use the result as a 2D texture. <br />Below is a list of functions that can be bound to pipeline stages and utilize <CODE>Texture2DResource</CODE> resources:</p><p><itemizedlist><listitem><para><a href="../../../../nn/gd/CTR/TextureStage/SetTexture.html"><CODE>TextureStage::SetTexture(TextureUnitId, Texture2D &texture2D)</CODE></a><br /></para></listitem><listitem><para><a href="../../../../nn/gd/CTR/TextureStage/SetTextureUnit0.html"><CODE>TextureStage::SetTextureUnit0(TextureCube &textureCube)</CODE></a><br /></para></listitem><listitem><para><a href="../../../../nn/gd/CTR/OutputStage/SetRenderTarget.html"><CODE>OutputStage::SetRenderTarget(const RenderTarget *renderTarget)</CODE></a><br /></para></listitem><listitem><para><a href="../../../../nn/gd/CTR/OutputStage/SetDepthStencilTarget.html"><CODE>OutputStage::SetDepthStencilTarget(const DepthStencilTarget *depthStencil)</CODE></a><br /></para></listitem></itemizedlist><br /><br /><B>For vertex resources</B><br /><br /> Since there is only one way to use each buffer, you can directly bind vertex resources to <CODE>VertexInputStage</CODE>. <br />Below is a list of functions that can be bound to pipeline stages and utilize vertex resources:</p><p><itemizedlist><listitem><para><a href="../../../../nn/gd/CTR/VertexInputStage/SetIndexBuffer.html"><CODE>VertexInputStage::SetIndexBuffer(VertexBufferResource *indexBuffer, IndexFormat format, u32 offset)</CODE></a><br /></para></listitem><listitem><para><a href="../../../../nn/gd/CTR/VertexInputStage/SetVertexBuffers.html"><CODE>VertexInputStage::SetVertexBuffers(u32 startSlot, u32 numBuffers, VertexBufferResource **vertexBuffers, u32 *offsets)</CODE></a></para></listitem></itemizedlist></p><!-- write here --></div>
59    <a name="class" id="class">
60<h2>Classes</h2>
61      <div class="section">
62        <table class="members">
63          <tr>
64            <th>
65<a href="../../../../nn/gd/CTR/Resource/Helper/Overview.html">nn::gd::CTR::Resource::Helper</a>
66            </th>
67<td>Utility function for converting the format of texture resources.</td>
68          </tr> </table>
69      </div>
70    </a> <a name="enum" id="enum">
71<h2>Enumerated Types</h2>
72      <div class="section">
73        <table class="members">
74          <tr>
75            <td width="100"> </td>
76            <th>
77<a href="../../../../nn/gd/CTR/Resource/NativeFormat.html">NativeFormat</a>
78            </th>
79<td>The enum values for native format texture resources.</td>
80          </tr>
81          <tr>
82            <td width="100"> </td>
83            <th>
84<a href="../../../../nn/gd/CTR/Resource/Format.html">Format</a>
85            </th>
86<td>The enum values for texture resource formats. </td>
87          </tr>
88          <tr>
89            <td width="100"> </td>
90            <th>
91<a href="../../../../nn/gd/CTR/Resource/CompressedFormat.html">CompressedFormat</a>
92            </th>
93<td>The enum values for compressed texture resource formats.</td>
94          </tr>
95          <tr>
96            <td width="100"> </td>
97            <th>
98<a href="../../../../nn/gd/CTR/Resource/MapUsage.html">MapUsage</a>
99            </th>
100<td>The method for mapping the resource,</td>
101          </tr> </table>
102      </div>
103    </a> <a name="typedef" id="typedef">
104<h2><CODE>typedef</CODE> Definitions</h2>
105      <div class="section">
106        <table class="members">
107          <tr>
108            <td width="100" />
109            <th>
110<a href="../../../../nn/gd/CTR/Resource/NativeResourceFormat.html">NativeResourceFormat</a>
111            </th>
112<td>Do not use this. It may be removed in a future release. Use NativeFormat.</td>
113          </tr>
114          <tr>
115            <td width="100" />
116            <th>
117<a href="../../../../nn/gd/CTR/Resource/ResourceFormat.html">ResourceFormat</a>
118            </th>
119<td>Do not use this. It may be removed in a future release. Use Format.</td>
120          </tr>
121          <tr>
122            <td width="100" />
123            <th>
124<a href="../../../../nn/gd/CTR/Resource/CompressedResourceFormat.html">CompressedResourceFormat</a>
125            </th>
126<td>Do not use this. It may be removed in a future release. Use CompressedFormat.</td>
127          </tr> </table>
128      </div>
129    </a> <a name="function" id="function">
130<h2>Member Functions</h2>
131      <div class="section">
132        <table class="members">
133          <tr>
134<th class="category" colspan="3">Texture resources:</th>
135          </tr>
136          <tr>
137            <td width="100">
138<span class="static_style" title="static">S</span> </td>
139            <th>
140<a href="../../../../nn/gd/CTR/Resource/CreateTexture2DResource.html">CreateTexture2DResource</a>
141            </th>
142<td>Creates a 2D texture resource.</td>
143          </tr>
144          <tr>
145            <td width="100">
146<span class="static_style" title="static">S</span> </td>
147            <th>
148<a href="../../../../nn/gd/CTR/Resource/CreateTexture2DResourceCastFrom.html">CreateTexture2DResourceCastFrom</a>
149            </th>
150<td>Casts an existing <CODE>Texture2DResource</CODE> resource in a different format.</td>
151          </tr>
152          <tr>
153            <td width="100">
154<span class="static_style" title="static">S</span> </td>
155            <th>
156<a href="../../../../nn/gd/CTR/Resource/GetTexture2DResourceProperties.html">GetTexture2DResourceProperties</a>
157            </th>
158<td>Gets detailed information about a 2D texture resource. </td>
159          </tr>
160          <tr>
161            <td width="100">
162<span class="static_style" title="static">S</span> </td>
163            <th>
164<a href="../../../../nn/gd/CTR/Resource/ReleaseTexture2DResource.html">ReleaseTexture2DResource</a>
165            </th>
166<td>Releases a 2D texture resource.</td>
167          </tr>
168          <tr>
169            <td width="100">
170<span class="static_style" title="static">S</span> </td>
171            <th>
172<a href="../../../../nn/gd/CTR/Resource/MapTexture2DResource.html">MapTexture2DResource</a>
173            </th>
174<td>Obtains a data pointer to the specified resource.</td>
175          </tr>
176          <tr>
177            <td width="100">
178<span class="static_style" title="static">S</span> </td>
179            <th>
180<a href="../../../../nn/gd/CTR/Resource/UnmapTexture2DResource.html">UnmapTexture2DResource</a>
181            </th>
182<td>Releases the data pointer to a resource. Flushes the memory cache based on the memory type and usage method.</td>
183          </tr>
184          <tr>
185<th class="category" colspan="3">Vertex buffer resources:</th>
186          </tr>
187          <tr>
188            <td width="100">
189<span class="static_style" title="static">S</span> </td>
190            <th>
191<a href="../../../../nn/gd/CTR/Resource/CreateVertexBufferResource.html">CreateVertexBufferResource</a>
192            </th>
193<td>Creates a vertex buffer resource. </td>
194          </tr>
195          <tr>
196            <td width="100">
197<span class="static_style" title="static">S</span> </td>
198            <th>
199<a href="../../../../nn/gd/CTR/Resource/GetVertexBufferResourceProperties.html">GetVertexBufferResourceProperties</a>
200            </th>
201<td>Gets detailed information for a vertex buffer resource.</td>
202          </tr>
203          <tr>
204            <td width="100">
205<span class="static_style" title="static">S</span> </td>
206            <th>
207<a href="../../../../nn/gd/CTR/Resource/MapVertexBufferResource.html">MapVertexBufferResource</a>
208            </th>
209<td>Obtains a data pointer to the specified resource.</td>
210          </tr>
211          <tr>
212            <td width="100">
213<span class="static_style" title="static">S</span> </td>
214            <th>
215<a href="../../../../nn/gd/CTR/Resource/UnmapVertexBufferResource.html">UnmapVertexBufferResource</a>
216            </th>
217<td>Releases the data pointer to a resource. Flushes the memory cache based on the memory type and usage method.</td>
218          </tr>
219          <tr>
220            <td width="100">
221<span class="static_style" title="static">S</span> </td>
222            <th>
223<a href="../../../../nn/gd/CTR/Resource/ReleaseVertexBufferResource.html">ReleaseVertexBufferResource</a>
224            </th>
225<td>Releases a vertex buffer resource. </td>
226          </tr> </table>
227      </div>
228    </a>
229<h2>Revision History</h2>
230    <div class="section">
231      <dl class="history">
232        <dt>2011/02/15</dt>
233<dd>Initial version.<br />
234        </dd>
235      </dl>
236    </div>
237  <hr><p>CONFIDENTIAL</p></body>
238</html>
239