|
287 | 287 |
|
288 | 288 | #define PL__ALIGN_UP(num, align) (((num) + ((align)-1)) & ~((align)-1)) |
289 | 289 |
|
290 | | -static inline void |
291 | | -pl__metal_barrier_in_encoder(id<MTL4CommandEncoder> encoder) |
292 | | -{ |
293 | | - [encoder barrierAfterEncoderStages:MTLStageDispatch | MTLStageBlit |
294 | | - beforeEncoderStages:MTLStageDispatch | MTLStageBlit |
295 | | - visibilityOptions:MTL4VisibilityOptionDevice]; |
296 | | -} |
297 | | - |
298 | 290 | //----------------------------------------------------------------------------- |
299 | 291 | // [SECTION] public api implementation |
300 | 292 | //----------------------------------------------------------------------------- |
|
581 | 573 | destinationLevel:ptRegion->uMipLevel |
582 | 574 | destinationOrigin:tOrigin]; |
583 | 575 | } |
584 | | - |
585 | | - pl__metal_barrier_in_encoder(ptDevice->tComputeEncoder); |
586 | 576 | } |
587 | 577 | } |
588 | 578 |
|
|
626 | 616 | destinationSlice:ptRegions[i].uDestinationBaseArrayLayer |
627 | 617 | destinationLevel:ptRegions[i].uDestinationMipLevel |
628 | 618 | destinationOrigin:tDestOrigin]; |
629 | | - |
630 | | - pl__metal_barrier_in_encoder(ptDevice->tComputeEncoder); |
631 | 619 | } |
632 | 620 | } |
633 | 621 |
|
|
690 | 678 | destinationBytesPerRow:uBytesPerRow |
691 | 679 | destinationBytesPerImage:uBytesPerImage]; |
692 | 680 | } |
693 | | - |
694 | | - pl__metal_barrier_in_encoder(ptDevice->tComputeEncoder); |
695 | 681 | } |
696 | 682 | } |
697 | 683 |
|
|
706 | 692 |
|
707 | 693 | plDevice* ptDevice = ptCmdBuffer->ptDevice; |
708 | 694 | [ptDevice->tComputeEncoder copyFromBuffer:ptDevice->sbtBuffersHot[tSource.uIndex].tBuffer sourceOffset:uSourceOffset toBuffer:ptDevice->sbtBuffersHot[tDestination.uIndex].tBuffer destinationOffset:uDestinationOffset size:szSize]; |
709 | | - pl__metal_barrier_in_encoder(ptDevice->tComputeEncoder); |
710 | 695 | } |
711 | 696 |
|
712 | 697 | plTimelineSemaphore* |
|
840 | 825 | return; |
841 | 826 |
|
842 | 827 | [ptDevice->tComputeEncoder generateMipmapsForTexture:ptDevice->sbtTexturesHot[tTexture.uIndex].tTexture]; |
843 | | - |
844 | | - pl__metal_barrier_in_encoder(ptDevice->tComputeEncoder); |
845 | 828 | } |
846 | 829 |
|
847 | 830 | void |
|
2168 | 2151 | // Add a producer queue barrier that blocks any dispatch stages in subsequent passes |
2169 | 2152 | // in the queue, not counting this one, from running until the blit stages in all |
2170 | 2153 | // previous passes finish running, including this one. |
2171 | | - [ptDevice->tRenderEncoder barrierAfterStages:MTLStageAll |
2172 | | - beforeQueueStages:MTLStageAll |
| 2154 | + |
| 2155 | + // producer queue barrier |
| 2156 | + [ptDevice->tRenderEncoder barrierAfterStages:MTLStageFragment |
| 2157 | + beforeQueueStages:MTLStageVertex |
2173 | 2158 | visibilityOptions:MTL4VisibilityOptionDevice]; |
2174 | 2159 |
|
2175 | 2160 | [ptDevice->tRenderEncoder endEncoding]; |
|
2181 | 2166 | // Add a consumer queue barrier that blocks any dispatch stages in subsequent passes |
2182 | 2167 | // in the queue, including this one, from running until blit stages in all |
2183 | 2168 | // previous passes finish running, not counting this one. |
2184 | | - [ptDevice->tRenderEncoder barrierAfterQueueStages:MTLStageAll |
2185 | | - beforeStages:MTLStageAll |
2186 | | - visibilityOptions:MTL4VisibilityOptionDevice]; |
| 2169 | + // [ptDevice->tRenderEncoder barrierAfterQueueStages:MTLStageAll |
| 2170 | + // beforeStages:MTLStageAll |
| 2171 | + // visibilityOptions:MTL4VisibilityOptionDevice]; |
2187 | 2172 | } |
2188 | 2173 |
|
2189 | 2174 | void |
|
2210 | 2195 | // Add a consumer queue barrier that blocks any dispatch stages in subsequent passes |
2211 | 2196 | // in the queue, including this one, from running until blit stages in all |
2212 | 2197 | // previous passes finish running, not counting this one. |
2213 | | - [ptDevice->tRenderEncoder barrierAfterQueueStages:MTLStageAll |
2214 | | - beforeStages:MTLStageAll |
2215 | | - visibilityOptions:MTL4VisibilityOptionDevice]; |
| 2198 | + // [ptDevice->tRenderEncoder barrierAfterQueueStages:MTLStageAll |
| 2199 | + // beforeStages:MTLStageAll |
| 2200 | + // visibilityOptions:MTL4VisibilityOptionDevice]; |
2216 | 2201 | } |
2217 | 2202 |
|
2218 | 2203 | void |
|
2226 | 2211 | // Add a producer queue barrier that blocks any dispatch stages in subsequent passes |
2227 | 2212 | // in the queue, not counting this one, from running until the blit stages in all |
2228 | 2213 | // previous passes finish running, including this one. |
2229 | | - [ptDevice->tRenderEncoder barrierAfterStages:MTLStageAll |
2230 | | - beforeQueueStages:MTLStageAll |
2231 | | - visibilityOptions:MTL4VisibilityOptionDevice]; |
| 2214 | + // [ptDevice->tRenderEncoder barrierAfterStages:MTLStageAll |
| 2215 | + // beforeQueueStages:MTLStageAll |
| 2216 | + // visibilityOptions:MTL4VisibilityOptionDevice]; |
2232 | 2217 |
|
2233 | 2218 | [ptDevice->tRenderEncoder endEncoding]; |
2234 | 2219 | ptDevice->tRenderEncoder = nil; |
|
2307 | 2292 | ptCmdBuffer->ptPool->ptCommandBufferFreeList = ptCmdBuffer; |
2308 | 2293 | } |
2309 | 2294 |
|
2310 | | -void |
2311 | | -pl_graphics_begin_blit_pass(plCommandBuffer* ptCmdBuffer) |
2312 | | -{ |
2313 | | - PL_ASSERT(gptGraphics->bEncoderActive == false); |
2314 | | - gptGraphics->bEncoderActive = true; |
2315 | | - plDevice* ptDevice = ptCmdBuffer->ptDevice; |
2316 | | - |
2317 | | - ptDevice->tComputeEncoder = [ptCmdBuffer->tCmdBuffer4 computeCommandEncoder]; |
2318 | | - |
2319 | | - // Add a consumer queue barrier that blocks any dispatch stages in subsequent passes |
2320 | | - // in the queue, including this one, from running until blit stages in all |
2321 | | - // previous passes finish running, not counting this one. |
2322 | | - [ptDevice->tComputeEncoder barrierAfterQueueStages:MTLStageAll |
2323 | | - beforeStages:MTLStageAll |
2324 | | - visibilityOptions:MTL4VisibilityOptionDevice]; |
2325 | | -} |
2326 | | - |
2327 | | -void |
2328 | | -pl_graphics_end_blit_pass(plCommandBuffer* ptCmdBuffer) |
2329 | | -{ |
2330 | | - plDevice* ptDevice = ptCmdBuffer->ptDevice; |
2331 | | - |
2332 | | - // Add a producer queue barrier that blocks any dispatch stages in subsequent passes |
2333 | | - // in the queue, not counting this one, from running until the blit stages in all |
2334 | | - // previous passes finish running, including this one. |
2335 | | - [ptDevice->tComputeEncoder barrierAfterStages:MTLStageAll |
2336 | | - beforeQueueStages:MTLStageAll |
2337 | | - visibilityOptions:MTL4VisibilityOptionDevice]; |
2338 | | - |
2339 | | - // if(ptEncoder->bActive) |
2340 | | - // { |
2341 | | - [ptDevice->tComputeEncoder endEncoding]; |
2342 | | - // } |
2343 | | - gptGraphics->bEncoderActive = false; |
2344 | | - ptDevice->tComputeEncoder = nil; |
2345 | | -} |
2346 | | - |
2347 | 2295 | void |
2348 | 2296 | pl_graphics_begin_compute_pass(plCommandBuffer* ptCmdBuffer, const plPassResources* ptResources) |
2349 | 2297 | { |
|
2353 | 2301 | // Add a consumer queue barrier that blocks any dispatch stages in subsequent passes |
2354 | 2302 | // in the queue, including this one, from running until blit stages in all |
2355 | 2303 | // previous passes finish running, not counting this one. |
2356 | | - [ptDevice->tComputeEncoder barrierAfterQueueStages:MTLStageAll |
2357 | | - beforeStages:MTLStageAll |
2358 | | - visibilityOptions:MTL4VisibilityOptionDevice]; |
| 2304 | + // [ptDevice->tComputeEncoder barrierAfterQueueStages:MTLStageAll |
| 2305 | + // beforeStages:MTLStageAll |
| 2306 | + // visibilityOptions:MTL4VisibilityOptionDevice]; |
2359 | 2307 | } |
2360 | 2308 |
|
2361 | 2309 | void |
|
2366 | 2314 | // Add a producer queue barrier that blocks any dispatch stages in subsequent passes |
2367 | 2315 | // in the queue, not counting this one, from running until the blit stages in all |
2368 | 2316 | // previous passes finish running, including this one. |
2369 | | - [ptDevice->tComputeEncoder barrierAfterStages:MTLStageAll |
2370 | | - beforeQueueStages:MTLStageAll |
2371 | | - visibilityOptions:MTL4VisibilityOptionDevice]; |
| 2317 | + // [ptDevice->tComputeEncoder barrierAfterStages:MTLStageAll |
| 2318 | + // beforeQueueStages:MTLStageAll |
| 2319 | + // visibilityOptions:MTL4VisibilityOptionDevice]; |
2372 | 2320 |
|
2373 | 2321 | [ptDevice->tComputeEncoder endEncoding]; |
2374 | 2322 | ptDevice->tComputeEncoder = nil; |
|
2472 | 2420 | MTLSize tGridSize = MTLSizeMake(ptDispatch->uGroupCountX, ptDispatch->uGroupCountY, ptDispatch->uGroupCountZ); |
2473 | 2421 | MTLSize tThreadsPerGroup = MTLSizeMake(ptDispatch->uThreadPerGroupX, ptDispatch->uThreadPerGroupY, ptDispatch->uThreadPerGroupZ); |
2474 | 2422 | [ptDevice->tComputeEncoder dispatchThreadgroups:tGridSize threadsPerThreadgroup:tThreadsPerGroup]; |
2475 | | - // pl__metal_barrier_in_encoder(ptDevice->tComputeEncoder); |
2476 | 2423 | } |
2477 | 2424 | } |
2478 | 2425 |
|
|
0 commit comments