Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/amd/vulkan/radv_meta_copy.c
7233 views
1
/*
2
* Copyright © 2016 Intel Corporation
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
13
* Software.
14
*
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
* IN THE SOFTWARE.
22
*/
23
24
#include "radv_meta.h"
25
#include "vk_format.h"
26
27
static VkExtent3D
28
meta_image_block_size(const struct radv_image *image)
29
{
30
const struct util_format_description *desc = vk_format_description(image->vk_format);
31
return (VkExtent3D){desc->block.width, desc->block.height, 1};
32
}
33
34
/* Returns the user-provided VkBufferImageCopy::imageExtent in units of
35
* elements rather than texels. One element equals one texel or one block
36
* if Image is uncompressed or compressed, respectively.
37
*/
38
static struct VkExtent3D
39
meta_region_extent_el(const struct radv_image *image, const VkImageType imageType,
40
const struct VkExtent3D *extent)
41
{
42
const VkExtent3D block = meta_image_block_size(image);
43
return radv_sanitize_image_extent(imageType,
44
(VkExtent3D){
45
.width = DIV_ROUND_UP(extent->width, block.width),
46
.height = DIV_ROUND_UP(extent->height, block.height),
47
.depth = DIV_ROUND_UP(extent->depth, block.depth),
48
});
49
}
50
51
/* Returns the user-provided VkBufferImageCopy::imageOffset in units of
52
* elements rather than texels. One element equals one texel or one block
53
* if Image is uncompressed or compressed, respectively.
54
*/
55
static struct VkOffset3D
56
meta_region_offset_el(const struct radv_image *image, const struct VkOffset3D *offset)
57
{
58
const VkExtent3D block = meta_image_block_size(image);
59
return radv_sanitize_image_offset(image->type, (VkOffset3D){
60
.x = offset->x / block.width,
61
.y = offset->y / block.height,
62
.z = offset->z / block.depth,
63
});
64
}
65
66
static VkFormat
67
vk_format_for_size(int bs)
68
{
69
switch (bs) {
70
case 1:
71
return VK_FORMAT_R8_UINT;
72
case 2:
73
return VK_FORMAT_R8G8_UINT;
74
case 4:
75
return VK_FORMAT_R8G8B8A8_UINT;
76
case 8:
77
return VK_FORMAT_R16G16B16A16_UINT;
78
case 12:
79
return VK_FORMAT_R32G32B32_UINT;
80
case 16:
81
return VK_FORMAT_R32G32B32A32_UINT;
82
default:
83
unreachable("Invalid format block size");
84
}
85
}
86
87
static struct radv_meta_blit2d_surf
88
blit_surf_for_image_level_layer(struct radv_image *image, VkImageLayout layout,
89
const VkImageSubresourceLayers *subres,
90
VkImageAspectFlags aspect_mask)
91
{
92
VkFormat format = radv_get_aspect_format(image, aspect_mask);
93
94
if (!radv_dcc_enabled(image, subres->mipLevel) && !(radv_image_is_tc_compat_htile(image)))
95
format = vk_format_for_size(vk_format_get_blocksize(format));
96
97
format = vk_format_no_srgb(format);
98
99
return (struct radv_meta_blit2d_surf){
100
.format = format,
101
.bs = vk_format_get_blocksize(format),
102
.level = subres->mipLevel,
103
.layer = subres->baseArrayLayer,
104
.image = image,
105
.aspect_mask = aspect_mask,
106
.current_layout = layout,
107
};
108
}
109
110
bool
111
radv_image_is_renderable(struct radv_device *device, struct radv_image *image)
112
{
113
if (image->vk_format == VK_FORMAT_R32G32B32_UINT ||
114
image->vk_format == VK_FORMAT_R32G32B32_SINT ||
115
image->vk_format == VK_FORMAT_R32G32B32_SFLOAT)
116
return false;
117
118
if (device->physical_device->rad_info.chip_class >= GFX9 && image->type == VK_IMAGE_TYPE_3D &&
119
vk_format_get_blocksizebits(image->vk_format) == 128 &&
120
vk_format_is_compressed(image->vk_format))
121
return false;
122
return true;
123
}
124
125
static void
126
copy_buffer_to_image(struct radv_cmd_buffer *cmd_buffer, struct radv_buffer *buffer,
127
struct radv_image *image, VkImageLayout layout,
128
const VkBufferImageCopy2KHR *region)
129
{
130
struct radv_meta_saved_state saved_state;
131
bool old_predicating;
132
bool cs;
133
134
/* The Vulkan 1.0 spec says "dstImage must have a sample count equal to
135
* VK_SAMPLE_COUNT_1_BIT."
136
*/
137
assert(image->info.samples == 1);
138
139
cs = cmd_buffer->queue_family_index == RADV_QUEUE_COMPUTE ||
140
!radv_image_is_renderable(cmd_buffer->device, image);
141
142
radv_meta_save(&saved_state, cmd_buffer,
143
(cs ? RADV_META_SAVE_COMPUTE_PIPELINE : RADV_META_SAVE_GRAPHICS_PIPELINE) |
144
RADV_META_SAVE_CONSTANTS | RADV_META_SAVE_DESCRIPTORS);
145
146
/* VK_EXT_conditional_rendering says that copy commands should not be
147
* affected by conditional rendering.
148
*/
149
old_predicating = cmd_buffer->state.predicating;
150
cmd_buffer->state.predicating = false;
151
152
/**
153
* From the Vulkan 1.0.6 spec: 18.3 Copying Data Between Images
154
* extent is the size in texels of the source image to copy in width,
155
* height and depth. 1D images use only x and width. 2D images use x, y,
156
* width and height. 3D images use x, y, z, width, height and depth.
157
*
158
*
159
* Also, convert the offsets and extent from units of texels to units of
160
* blocks - which is the highest resolution accessible in this command.
161
*/
162
const VkOffset3D img_offset_el = meta_region_offset_el(image, &region->imageOffset);
163
const VkExtent3D bufferExtent = {
164
.width = region->bufferRowLength ? region->bufferRowLength : region->imageExtent.width,
165
.height = region->bufferImageHeight ? region->bufferImageHeight : region->imageExtent.height,
166
};
167
const VkExtent3D buf_extent_el = meta_region_extent_el(image, image->type, &bufferExtent);
168
169
/* Start creating blit rect */
170
const VkExtent3D img_extent_el = meta_region_extent_el(image, image->type, &region->imageExtent);
171
struct radv_meta_blit2d_rect rect = {
172
.width = img_extent_el.width,
173
.height = img_extent_el.height,
174
};
175
176
/* Create blit surfaces */
177
struct radv_meta_blit2d_surf img_bsurf = blit_surf_for_image_level_layer(
178
image, layout, &region->imageSubresource, region->imageSubresource.aspectMask);
179
180
if (!radv_is_buffer_format_supported(img_bsurf.format, NULL)) {
181
uint32_t queue_mask = radv_image_queue_family_mask(image, cmd_buffer->queue_family_index,
182
cmd_buffer->queue_family_index);
183
bool compressed =
184
radv_layout_dcc_compressed(cmd_buffer->device, image, region->imageSubresource.mipLevel,
185
layout, false, queue_mask);
186
if (compressed) {
187
radv_decompress_dcc(cmd_buffer, image,
188
&(VkImageSubresourceRange){
189
.aspectMask = region->imageSubresource.aspectMask,
190
.baseMipLevel = region->imageSubresource.mipLevel,
191
.levelCount = 1,
192
.baseArrayLayer = region->imageSubresource.baseArrayLayer,
193
.layerCount = region->imageSubresource.layerCount,
194
});
195
img_bsurf.disable_compression = true;
196
}
197
img_bsurf.format = vk_format_for_size(vk_format_get_blocksize(img_bsurf.format));
198
}
199
200
struct radv_meta_blit2d_buffer buf_bsurf = {
201
.bs = img_bsurf.bs,
202
.format = img_bsurf.format,
203
.buffer = buffer,
204
.offset = region->bufferOffset,
205
.pitch = buf_extent_el.width,
206
};
207
208
if (image->type == VK_IMAGE_TYPE_3D)
209
img_bsurf.layer = img_offset_el.z;
210
/* Loop through each 3D or array slice */
211
unsigned num_slices_3d = img_extent_el.depth;
212
unsigned num_slices_array = region->imageSubresource.layerCount;
213
unsigned slice_3d = 0;
214
unsigned slice_array = 0;
215
while (slice_3d < num_slices_3d && slice_array < num_slices_array) {
216
217
rect.dst_x = img_offset_el.x;
218
rect.dst_y = img_offset_el.y;
219
220
/* Perform Blit */
221
if (cs) {
222
radv_meta_buffer_to_image_cs(cmd_buffer, &buf_bsurf, &img_bsurf, 1, &rect);
223
} else {
224
radv_meta_blit2d(cmd_buffer, NULL, &buf_bsurf, &img_bsurf, 1, &rect);
225
}
226
227
/* Once we've done the blit, all of the actual information about
228
* the image is embedded in the command buffer so we can just
229
* increment the offset directly in the image effectively
230
* re-binding it to different backing memory.
231
*/
232
buf_bsurf.offset += buf_extent_el.width * buf_extent_el.height * buf_bsurf.bs;
233
img_bsurf.layer++;
234
if (image->type == VK_IMAGE_TYPE_3D)
235
slice_3d++;
236
else
237
slice_array++;
238
}
239
240
/* Restore conditional rendering. */
241
cmd_buffer->state.predicating = old_predicating;
242
243
radv_meta_restore(&saved_state, cmd_buffer);
244
}
245
246
void
247
radv_CmdCopyBufferToImage2KHR(VkCommandBuffer commandBuffer,
248
const VkCopyBufferToImageInfo2KHR *pCopyBufferToImageInfo)
249
{
250
RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
251
RADV_FROM_HANDLE(radv_buffer, src_buffer, pCopyBufferToImageInfo->srcBuffer);
252
RADV_FROM_HANDLE(radv_image, dst_image, pCopyBufferToImageInfo->dstImage);
253
254
for (unsigned r = 0; r < pCopyBufferToImageInfo->regionCount; r++) {
255
copy_buffer_to_image(cmd_buffer, src_buffer, dst_image,
256
pCopyBufferToImageInfo->dstImageLayout,
257
&pCopyBufferToImageInfo->pRegions[r]);
258
}
259
}
260
261
static void
262
copy_image_to_buffer(struct radv_cmd_buffer *cmd_buffer, struct radv_buffer *buffer,
263
struct radv_image *image, VkImageLayout layout,
264
const VkBufferImageCopy2KHR *region)
265
{
266
struct radv_meta_saved_state saved_state;
267
bool old_predicating;
268
269
radv_meta_save(
270
&saved_state, cmd_buffer,
271
RADV_META_SAVE_COMPUTE_PIPELINE | RADV_META_SAVE_CONSTANTS | RADV_META_SAVE_DESCRIPTORS);
272
273
/* VK_EXT_conditional_rendering says that copy commands should not be
274
* affected by conditional rendering.
275
*/
276
old_predicating = cmd_buffer->state.predicating;
277
cmd_buffer->state.predicating = false;
278
279
/**
280
* From the Vulkan 1.0.6 spec: 18.3 Copying Data Between Images
281
* extent is the size in texels of the source image to copy in width,
282
* height and depth. 1D images use only x and width. 2D images use x, y,
283
* width and height. 3D images use x, y, z, width, height and depth.
284
*
285
*
286
* Also, convert the offsets and extent from units of texels to units of
287
* blocks - which is the highest resolution accessible in this command.
288
*/
289
const VkOffset3D img_offset_el = meta_region_offset_el(image, &region->imageOffset);
290
const VkExtent3D bufferExtent = {
291
.width = region->bufferRowLength ? region->bufferRowLength : region->imageExtent.width,
292
.height = region->bufferImageHeight ? region->bufferImageHeight : region->imageExtent.height,
293
};
294
const VkExtent3D buf_extent_el = meta_region_extent_el(image, image->type, &bufferExtent);
295
296
/* Start creating blit rect */
297
const VkExtent3D img_extent_el = meta_region_extent_el(image, image->type, &region->imageExtent);
298
struct radv_meta_blit2d_rect rect = {
299
.width = img_extent_el.width,
300
.height = img_extent_el.height,
301
};
302
303
/* Create blit surfaces */
304
struct radv_meta_blit2d_surf img_info = blit_surf_for_image_level_layer(
305
image, layout, &region->imageSubresource, region->imageSubresource.aspectMask);
306
307
if (!radv_is_buffer_format_supported(img_info.format, NULL)) {
308
uint32_t queue_mask = radv_image_queue_family_mask(image, cmd_buffer->queue_family_index,
309
cmd_buffer->queue_family_index);
310
bool compressed =
311
radv_layout_dcc_compressed(cmd_buffer->device, image, region->imageSubresource.mipLevel,
312
layout, false, queue_mask);
313
if (compressed) {
314
radv_decompress_dcc(cmd_buffer, image,
315
&(VkImageSubresourceRange){
316
.aspectMask = region->imageSubresource.aspectMask,
317
.baseMipLevel = region->imageSubresource.mipLevel,
318
.levelCount = 1,
319
.baseArrayLayer = region->imageSubresource.baseArrayLayer,
320
.layerCount = region->imageSubresource.layerCount,
321
});
322
img_info.disable_compression = true;
323
}
324
img_info.format = vk_format_for_size(vk_format_get_blocksize(img_info.format));
325
}
326
327
struct radv_meta_blit2d_buffer buf_info = {
328
.bs = img_info.bs,
329
.format = img_info.format,
330
.buffer = buffer,
331
.offset = region->bufferOffset,
332
.pitch = buf_extent_el.width,
333
};
334
335
if (image->type == VK_IMAGE_TYPE_3D)
336
img_info.layer = img_offset_el.z;
337
/* Loop through each 3D or array slice */
338
unsigned num_slices_3d = img_extent_el.depth;
339
unsigned num_slices_array = region->imageSubresource.layerCount;
340
unsigned slice_3d = 0;
341
unsigned slice_array = 0;
342
while (slice_3d < num_slices_3d && slice_array < num_slices_array) {
343
344
rect.src_x = img_offset_el.x;
345
rect.src_y = img_offset_el.y;
346
347
/* Perform Blit */
348
radv_meta_image_to_buffer(cmd_buffer, &img_info, &buf_info, 1, &rect);
349
350
buf_info.offset += buf_extent_el.width * buf_extent_el.height * buf_info.bs;
351
img_info.layer++;
352
if (image->type == VK_IMAGE_TYPE_3D)
353
slice_3d++;
354
else
355
slice_array++;
356
}
357
358
/* Restore conditional rendering. */
359
cmd_buffer->state.predicating = old_predicating;
360
361
radv_meta_restore(&saved_state, cmd_buffer);
362
}
363
364
void
365
radv_CmdCopyImageToBuffer2KHR(VkCommandBuffer commandBuffer,
366
const VkCopyImageToBufferInfo2KHR *pCopyImageToBufferInfo)
367
{
368
RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
369
RADV_FROM_HANDLE(radv_image, src_image, pCopyImageToBufferInfo->srcImage);
370
RADV_FROM_HANDLE(radv_buffer, dst_buffer, pCopyImageToBufferInfo->dstBuffer);
371
372
for (unsigned r = 0; r < pCopyImageToBufferInfo->regionCount; r++) {
373
copy_image_to_buffer(cmd_buffer, dst_buffer, src_image,
374
pCopyImageToBufferInfo->srcImageLayout,
375
&pCopyImageToBufferInfo->pRegions[r]);
376
}
377
}
378
379
static void
380
copy_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
381
VkImageLayout src_image_layout, struct radv_image *dst_image,
382
VkImageLayout dst_image_layout, const VkImageCopy2KHR *region)
383
{
384
struct radv_meta_saved_state saved_state;
385
bool old_predicating;
386
bool cs;
387
388
/* From the Vulkan 1.0 spec:
389
*
390
* vkCmdCopyImage can be used to copy image data between multisample
391
* images, but both images must have the same number of samples.
392
*/
393
assert(src_image->info.samples == dst_image->info.samples);
394
395
cs = cmd_buffer->queue_family_index == RADV_QUEUE_COMPUTE ||
396
!radv_image_is_renderable(cmd_buffer->device, dst_image);
397
398
radv_meta_save(&saved_state, cmd_buffer,
399
(cs ? RADV_META_SAVE_COMPUTE_PIPELINE : RADV_META_SAVE_GRAPHICS_PIPELINE) |
400
RADV_META_SAVE_CONSTANTS | RADV_META_SAVE_DESCRIPTORS);
401
402
/* VK_EXT_conditional_rendering says that copy commands should not be
403
* affected by conditional rendering.
404
*/
405
old_predicating = cmd_buffer->state.predicating;
406
cmd_buffer->state.predicating = false;
407
408
VkImageAspectFlags src_aspects[3] = {VK_IMAGE_ASPECT_PLANE_0_BIT, VK_IMAGE_ASPECT_PLANE_1_BIT,
409
VK_IMAGE_ASPECT_PLANE_2_BIT};
410
VkImageAspectFlags dst_aspects[3] = {VK_IMAGE_ASPECT_PLANE_0_BIT, VK_IMAGE_ASPECT_PLANE_1_BIT,
411
VK_IMAGE_ASPECT_PLANE_2_BIT};
412
unsigned aspect_count =
413
region->srcSubresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT ? src_image->plane_count : 1;
414
if (region->srcSubresource.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT)
415
src_aspects[0] = region->srcSubresource.aspectMask;
416
if (region->dstSubresource.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT)
417
dst_aspects[0] = region->dstSubresource.aspectMask;
418
419
for (unsigned a = 0; a < aspect_count; ++a) {
420
/* Create blit surfaces */
421
struct radv_meta_blit2d_surf b_src = blit_surf_for_image_level_layer(
422
src_image, src_image_layout, &region->srcSubresource, src_aspects[a]);
423
424
struct radv_meta_blit2d_surf b_dst = blit_surf_for_image_level_layer(
425
dst_image, dst_image_layout, &region->dstSubresource, dst_aspects[a]);
426
427
uint32_t dst_queue_mask = radv_image_queue_family_mask(
428
dst_image, cmd_buffer->queue_family_index, cmd_buffer->queue_family_index);
429
bool dst_compressed = radv_layout_dcc_compressed(cmd_buffer->device, dst_image,
430
region->dstSubresource.mipLevel,
431
dst_image_layout, false, dst_queue_mask);
432
uint32_t src_queue_mask = radv_image_queue_family_mask(
433
src_image, cmd_buffer->queue_family_index, cmd_buffer->queue_family_index);
434
bool src_compressed = radv_layout_dcc_compressed(cmd_buffer->device, src_image,
435
region->srcSubresource.mipLevel,
436
src_image_layout, false, src_queue_mask);
437
438
if (!src_compressed || radv_dcc_formats_compatible(b_src.format, b_dst.format)) {
439
b_src.format = b_dst.format;
440
} else if (!dst_compressed) {
441
b_dst.format = b_src.format;
442
} else {
443
radv_decompress_dcc(cmd_buffer, dst_image,
444
&(VkImageSubresourceRange){
445
.aspectMask = dst_aspects[a],
446
.baseMipLevel = region->dstSubresource.mipLevel,
447
.levelCount = 1,
448
.baseArrayLayer = region->dstSubresource.baseArrayLayer,
449
.layerCount = region->dstSubresource.layerCount,
450
});
451
b_dst.format = b_src.format;
452
b_dst.disable_compression = true;
453
}
454
455
/**
456
* From the Vulkan 1.0.6 spec: 18.4 Copying Data Between Buffers and Images
457
* imageExtent is the size in texels of the image to copy in width, height
458
* and depth. 1D images use only x and width. 2D images use x, y, width
459
* and height. 3D images use x, y, z, width, height and depth.
460
*
461
* Also, convert the offsets and extent from units of texels to units of
462
* blocks - which is the highest resolution accessible in this command.
463
*/
464
const VkOffset3D dst_offset_el = meta_region_offset_el(dst_image, &region->dstOffset);
465
const VkOffset3D src_offset_el = meta_region_offset_el(src_image, &region->srcOffset);
466
467
/*
468
* From Vulkan 1.0.68, "Copying Data Between Images":
469
* "When copying between compressed and uncompressed formats
470
* the extent members represent the texel dimensions of the
471
* source image and not the destination."
472
* However, we must use the destination image type to avoid
473
* clamping depth when copying multiple layers of a 2D image to
474
* a 3D image.
475
*/
476
const VkExtent3D img_extent_el =
477
meta_region_extent_el(src_image, dst_image->type, &region->extent);
478
479
/* Start creating blit rect */
480
struct radv_meta_blit2d_rect rect = {
481
.width = img_extent_el.width,
482
.height = img_extent_el.height,
483
};
484
485
if (src_image->type == VK_IMAGE_TYPE_3D)
486
b_src.layer = src_offset_el.z;
487
488
if (dst_image->type == VK_IMAGE_TYPE_3D)
489
b_dst.layer = dst_offset_el.z;
490
491
/* Loop through each 3D or array slice */
492
unsigned num_slices_3d = img_extent_el.depth;
493
unsigned num_slices_array = region->dstSubresource.layerCount;
494
unsigned slice_3d = 0;
495
unsigned slice_array = 0;
496
while (slice_3d < num_slices_3d && slice_array < num_slices_array) {
497
498
/* Finish creating blit rect */
499
rect.dst_x = dst_offset_el.x;
500
rect.dst_y = dst_offset_el.y;
501
rect.src_x = src_offset_el.x;
502
rect.src_y = src_offset_el.y;
503
504
/* Perform Blit */
505
if (cs) {
506
radv_meta_image_to_image_cs(cmd_buffer, &b_src, &b_dst, 1, &rect);
507
} else {
508
radv_meta_blit2d(cmd_buffer, &b_src, NULL, &b_dst, 1, &rect);
509
}
510
511
b_src.layer++;
512
b_dst.layer++;
513
if (dst_image->type == VK_IMAGE_TYPE_3D)
514
slice_3d++;
515
else
516
slice_array++;
517
}
518
}
519
520
/* Restore conditional rendering. */
521
cmd_buffer->state.predicating = old_predicating;
522
523
radv_meta_restore(&saved_state, cmd_buffer);
524
}
525
526
void
527
radv_CmdCopyImage2KHR(VkCommandBuffer commandBuffer, const VkCopyImageInfo2KHR *pCopyImageInfo)
528
{
529
RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
530
RADV_FROM_HANDLE(radv_image, src_image, pCopyImageInfo->srcImage);
531
RADV_FROM_HANDLE(radv_image, dst_image, pCopyImageInfo->dstImage);
532
533
for (unsigned r = 0; r < pCopyImageInfo->regionCount; r++) {
534
copy_image(cmd_buffer, src_image, pCopyImageInfo->srcImageLayout, dst_image,
535
pCopyImageInfo->dstImageLayout, &pCopyImageInfo->pRegions[r]);
536
}
537
}
538
539