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>nn::gd::CTR::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>Regarding the 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 <B>initialData</B> 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><CODE>DepthStencilTarget</CODE> is created 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">TextureStage::SetTexture(TextureUnitId, Texture2D &texture2D)</a><br /></para></listitem><listitem><para><a href="../../../../nn/gd/CTR/TextureStage/SetTextureUnit0.html">TextureStage::SetTextureUnit0(TextureCube &textureCube)</a><br /></para></listitem><listitem><para><a href="../../../../nn/gd/CTR/OutputStage/SetRenderTarget.html">OutputStage::SetRenderTarget(const RenderTarget *renderTarget)</a><br /></para></listitem><listitem><para><a href="../../../../nn/gd/CTR/OutputStage/SetDepthStencilTarget.html">OutputStage::SetDepthStencilTarget(const DepthStencilTarget *depthStencil)</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">VertexInputStage::SetIndexBuffer(VertexBufferResource *indexBuffer, IndexFormat format, u32 offset)</a><br /></para></listitem><listitem><para><a href="../../../../nn/gd/CTR/VertexInputStage/SetVertexBuffers.html">VertexInputStage::SetVertexBuffers(u32 startSlot, u32 numBuffers, VertexBufferResource **vertexBuffers, u32 *offsets)</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/NativeResourceFormat.html">NativeResourceFormat</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/ResourceFormat.html">ResourceFormat</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/CompressedResourceFormat.html">CompressedResourceFormat</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="function" id="function">
104<h2>Member Functions</h2>
105      <div class="section">
106        <table class="members">
107          <tr>
108<th class="category" colspan="3">Texture resources:</th>
109          </tr>
110          <tr>
111            <td width="100">
112<span class="static_style" title="static">S</span> </td>
113            <th>
114<a href="../../../../nn/gd/CTR/Resource/CreateTexture2DResource.html">CreateTexture2DResource</a>
115            </th>
116<td>Creates a 2D texture resource.</td>
117          </tr>
118          <tr>
119            <td width="100">
120<span class="static_style" title="static">S</span> </td>
121            <th>
122<a href="../../../../nn/gd/CTR/Resource/CreateTexture2DResourceCastFrom.html">CreateTexture2DResourceCastFrom</a>
123            </th>
124<td>Casts an existing <CODE>Texture2DResource</CODE> resource in a different format.</td>
125          </tr>
126          <tr>
127            <td width="100">
128<span class="static_style" title="static">S</span> </td>
129            <th>
130<a href="../../../../nn/gd/CTR/Resource/GetTexture2DResourceProperties.html">GetTexture2DResourceProperties</a>
131            </th>
132<td>Gets detailed information about a 2D texture resource. </td>
133          </tr>
134          <tr>
135            <td width="100">
136<span class="static_style" title="static">S</span> </td>
137            <th>
138<a href="../../../../nn/gd/CTR/Resource/ReleaseTexture2DResource.html">ReleaseTexture2DResource</a>
139            </th>
140<td>Releases a 2D texture resource.</td>
141          </tr>
142          <tr>
143            <td width="100">
144<span class="static_style" title="static">S</span> </td>
145            <th>
146<a href="../../../../nn/gd/CTR/Resource/MapTexture2DResource.html">MapTexture2DResource</a>
147            </th>
148<td>Obtains a data pointer to the specified resource.</td>
149          </tr>
150          <tr>
151            <td width="100">
152<span class="static_style" title="static">S</span> </td>
153            <th>
154<a href="../../../../nn/gd/CTR/Resource/UnmapTexture2DResource.html">UnmapTexture2DResource</a>
155            </th>
156<td>Releases the data pointer to a resource.</td>
157          </tr>
158          <tr>
159<th class="category" colspan="3">Vertex buffer resources:</th>
160          </tr>
161          <tr>
162            <td width="100">
163<span class="static_style" title="static">S</span> </td>
164            <th>
165<a href="../../../../nn/gd/CTR/Resource/CreateVertexBufferResource.html">CreateVertexBufferResource</a>
166            </th>
167<td>Creates a vertex buffer resource. </td>
168          </tr>
169          <tr>
170            <td width="100">
171<span class="static_style" title="static">S</span> </td>
172            <th>
173<a href="../../../../nn/gd/CTR/Resource/GetVertexBufferResourceProperties.html">GetVertexBufferResourceProperties</a>
174            </th>
175<td>Gets detailed information for a vertex buffer resource.</td>
176          </tr>
177          <tr>
178            <td width="100">
179<span class="static_style" title="static">S</span> </td>
180            <th>
181<a href="../../../../nn/gd/CTR/Resource/MapVertexBufferResource.html">MapVertexBufferResource</a>
182            </th>
183<td>Obtains a data pointer to the specified resource.</td>
184          </tr>
185          <tr>
186            <td width="100">
187<span class="static_style" title="static">S</span> </td>
188            <th>
189<a href="../../../../nn/gd/CTR/Resource/UnmapVertexBufferResource.html">UnmapVertexBufferResource</a>
190            </th>
191<td>Releases the data pointer to a resource.</td>
192          </tr>
193          <tr>
194            <td width="100">
195<span class="static_style" title="static">S</span> </td>
196            <th>
197<a href="../../../../nn/gd/CTR/Resource/ReleaseVertexBufferResource.html">ReleaseVertexBufferResource</a>
198            </th>
199<td>Releases a vertex buffer resource. </td>
200          </tr> </table>
201      </div>
202    </a>
203<h2>Revision History</h2>
204    <div class="section">
205      <dl class="history">
206        <dt>2011/02/15</dt>
207<dd>Initial version.<br />
208        </dd>
209      </dl>
210    </div>
211  <hr><p>CONFIDENTIAL</p></body>
212</html>
213