You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can also declare and initialize a `texture` object by using a constructor overload that takes a pointer to the source data, the size of source data in bytes, and the bits per scalar element.
122
122
123
123
```cpp
124
-
voidcreateTextureWithBPC() { *// Create the source data.
124
+
voidcreateTextureWithBPC() { // Create the source data.
125
125
float source[1024* 2];
126
126
for (int i = 0; i <1024* 2; i++) {
127
127
source[i] = (float)i;
128
128
}
129
-
*// Initialize the texture by using the size of source in bytes *// and bits per scalar element.
129
+
// Initialize the texture by using the size of source in bytes // and bits per scalar element.
parallel_for_each(tex9.extent, [=, &tex9] (index<2> idx) restrict(amp) { *// Use the subscript operator.
168
-
arr[idx].x += tex9[idx].x; *// Use the function () operator.
169
-
arr[idx].x += tex9(idx).x; *// Use the get method.
170
-
arr[idx].y += tex9.get(idx).y; *// Use the function () operator.
167
+
parallel_for_each(tex9.extent, [=, &tex9] (index<2> idx) restrict(amp) { // Use the subscript operator.
168
+
arr[idx].x += tex9[idx].x; // Use the function () operator.
169
+
arr[idx].x += tex9(idx).x; // Use the get method.
170
+
arr[idx].y += tex9.get(idx).y; // Use the function () operator.
171
171
arr[idx].y += tex9(idx[0], idx[1]).y;
172
172
});
173
173
@@ -181,21 +181,21 @@ void readTexture() {
181
181
The following code example demonstrates how to store texture channels in a short vector, and then access the individual scalar elements as properties of the short vector.
182
182
183
183
```cpp
184
-
voidUseBitsPerScalarElement() { *// Create the image data. *// Each unsigned int (32-bit) represents four 8-bit scalar elements(r,g,b,a values).
184
+
voidUseBitsPerScalarElement() { // Create the image data. // Each unsigned int (32-bit) represents four 8-bit scalar elements(r,g,b,a values).
*// Use can access the RGBA values of the source data by using swizzling expressions of the uint_4.
195
+
// Use can access the RGBA values of the source data by using swizzling expressions of the uint_4.
196
196
parallel_for_each(image_extent,
197
197
[&image_texture](index<2> idx) restrict(amp)
198
-
{ *// 4 bytes are automatically extracted when reading.
198
+
{ // 4 bytes are automatically extracted when reading.
199
199
uint_4 color = image_texture[idx];
200
200
unsigned int r = color.r;
201
201
unsigned int g = color.g;
@@ -250,7 +250,7 @@ void writeTexture() {
250
250
You can copy between texture objects by using the [copy](reference/concurrency-namespace-functions-amp.md#copy) function or the [copy_async](reference/concurrency-namespace-functions-amp.md#copy_async) function, as shown in the following code example.
251
251
252
252
```cpp
253
-
voidcopyHostArrayToTexture() { *// Copy from source array to texture object by using the copy function.
253
+
voidcopyHostArrayToTexture() { // Copy from source array to texture object by using the copy function.
254
254
float floatSource[1024* 2];
255
255
for (int i = 0; i <1024* 2; i++) {
256
256
floatSource[i] = (float)i;
@@ -259,15 +259,15 @@ void copyHostArrayToTexture() { *// Copy from source array to texture object by
0 commit comments