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
22      span.virtual_style
23      {
24        font-size			 : 8pt;
25        color				 : white;
26        font-weight			: bold;
27        background			: #0a0;
28        border-left			: solid 1px #0f0;
29        border-top			: solid 1px #0f0;
30        border-right		: solid 1px #060;
31        border-bottom		: solid 1px #060;
32        padding-left		: 2px;
33        padding-right		: 2px;
34      }
35
36      span.protected_style
37      {
38        font-size			 : 8pt;
39        color				 : white;
40        font-weight			: bold;
41        background			: #444;
42        border-left			: solid 1px #ccc;
43        border-top			: solid 1px #ccc;
44        border-right		: solid 1px #222;
45        border-bottom		: solid 1px #222;
46        padding-left		: 2px;
47        padding-right		: 2px;
48      }
49        --></style>
50<title>nn::gd::CTR::Resource</title>
51  </head>
52  <body>
53<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>
54<h2>Syntax</h2>
55    <div class="section">
56      <pre class="definition">class Resource</pre>
57    </div>
58<h2>Description</h2>
59    <div class="section">
60<p>The class of resource functions.</p><p><anchor id="classnn_1_1gd_1_1_c_t_r_1_1_resource_1Resource" /></p><p>The term resource refers to two-dimensional regions like pixels (Texture2DResource), as well as regions like vertex buffers and index buffers (VertexBufferResource). 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. 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>
61    <a name="class" id="class">
62<h2>Classes</h2>
63      <div class="section">
64        <table class="members">
65          <tr>
66            <th>
67<a href="../../../../nn/gd/CTR/Resource/Helper/Overview.html">nn::gd::CTR::Resource::Helper</a>
68            </th>
69<td>Utility function for converting the format of texture resources.</td>
70          </tr> </table>
71      </div>
72    </a> <a name="enum" id="enum">
73<h2>Enumerated Types</h2>
74      <div class="section">
75        <table class="members">
76          <tr>
77            <td width="100"> </td>
78            <th>
79<a href="../../../../nn/gd/CTR/Resource/NativeFormat.html">NativeFormat</a>
80            </th>
81<td>The enum values for native format texture resources.</td>
82          </tr>
83          <tr>
84            <td width="100"> </td>
85            <th>
86<a href="../../../../nn/gd/CTR/Resource/Format.html">Format</a>
87            </th>
88<td>The enum values for texture resource formats. </td>
89          </tr>
90          <tr>
91            <td width="100"> </td>
92            <th>
93<a href="../../../../nn/gd/CTR/Resource/CompressedFormat.html">CompressedFormat</a>
94            </th>
95<td>The enum values for compressed texture resource formats.</td>
96          </tr>
97          <tr>
98            <td width="100"> </td>
99            <th>
100<a href="../../../../nn/gd/CTR/Resource/MapUsage.html">MapUsage</a>
101            </th>
102<td>The method for mapping the resource,</td>
103          </tr> </table>
104      </div>
105    </a> <a name="function" id="function">
106<h2>Member Functions</h2>
107      <div class="section">
108        <table class="members">
109          <tr>
110<th class="category" colspan="3">Texture resources:</th>
111          </tr>
112          <tr>
113            <td width="100">
114<span class="static_style" title="static">S</span> </td>
115            <th>
116<a href="../../../../nn/gd/CTR/Resource/CreateTexture2DResource.html">CreateTexture2DResource</a>
117            </th>
118<td>Creates a 2D texture resource.</td>
119          </tr>
120          <tr>
121            <td width="100">
122<span class="static_style" title="static">S</span> </td>
123            <th>
124<a href="../../../../nn/gd/CTR/Resource/CreateTexture2DResourceCastFrom.html">CreateTexture2DResourceCastFrom</a>
125            </th>
126<td>Casts an existing <CODE>Texture2DResource</CODE> resource in a different format.</td>
127          </tr>
128          <tr>
129            <td width="100">
130<span class="static_style" title="static">S</span> </td>
131            <th>
132<a href="../../../../nn/gd/CTR/Resource/GetTexture2DResourceProperties.html">GetTexture2DResourceProperties</a>
133            </th>
134<td>Gets detailed information about a 2D texture resource. </td>
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/ReleaseTexture2DResource.html">ReleaseTexture2DResource</a>
141            </th>
142<td>Releases 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/MapTexture2DResource.html">MapTexture2DResource</a>
149            </th>
150<td>Obtains a data pointer to the specified resource.</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/UnmapTexture2DResource.html">UnmapTexture2DResource</a>
157            </th>
158<td>Releases the data pointer to a resource.</td>
159          </tr>
160          <tr>
161<th class="category" colspan="3">Vertex buffer resources:</th>
162          </tr>
163          <tr>
164            <td width="100">
165<span class="static_style" title="static">S</span> </td>
166            <th>
167<a href="../../../../nn/gd/CTR/Resource/CreateVertexBufferResource.html">CreateVertexBufferResource</a>
168            </th>
169<td>Creates a vertex buffer resource. </td>
170          </tr>
171          <tr>
172            <td width="100">
173<span class="static_style" title="static">S</span> </td>
174            <th>
175<a href="../../../../nn/gd/CTR/Resource/GetVertexBufferResourceProperties.html">GetVertexBufferResourceProperties</a>
176            </th>
177<td>Gets detailed information for a vertex buffer resource.</td>
178          </tr>
179          <tr>
180            <td width="100">
181<span class="static_style" title="static">S</span> </td>
182            <th>
183<a href="../../../../nn/gd/CTR/Resource/MapVertexBufferResource.html">MapVertexBufferResource</a>
184            </th>
185<td>Obtains a data pointer to the specified resource.</td>
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/UnmapVertexBufferResource.html">UnmapVertexBufferResource</a>
192            </th>
193<td>Releases the data pointer to a 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/ReleaseVertexBufferResource.html">ReleaseVertexBufferResource</a>
200            </th>
201<td>Releases a vertex buffer resource. </td>
202          </tr> </table>
203      </div>
204    </a>
205<h2>Revision History</h2>
206    <div class="section">
207      <dl class="history">
208        <dt>2011/02/15</dt>
209<dd>Initial version.<br />
210        </dd>
211      </dl>
212    </div>
213  <hr><p>CONFIDENTIAL</p></body>
214</html>