|
217 | 217 |
|
218 | 218 | id<MTL4ArgumentTable> tArgumentTable; |
219 | 219 | id<MTLResidencySet> tResidencySet; |
| 220 | + plStackedBarrier* sbtBarrierStack; |
220 | 221 | } plDevice; |
221 | 222 |
|
222 | 223 | typedef struct _plSwapchain |
|
1841 | 1842 |
|
1842 | 1843 | return true; |
1843 | 1844 | } |
1844 | | -void |
1845 | | -pl_graphics_change_texture_role(plCommandBuffer* ptCmdBuffer, plTextureHandle tTexture, plPassResourceRole tOldRole, |
1846 | | - plPassResourceAccess tOldAccess, plPassResourceRole tNewRole, plPassResourceAccess tNewAccess) |
| 1845 | + |
| 1846 | +static void |
| 1847 | +pl__graphics_consumer_barrier(plCommandBuffer* ptCmdBuffer, plPipelineStageFlags tSrcStages, plPipelineStageFlags tDstStages, plBarrierScope tScope) |
1847 | 1848 | { |
1848 | | - // plDevice* ptDevice = ptCmdBuffer->ptDevice; |
1849 | | - // PL_ASSERT(gptGraphics->bEncoderActive); |
1850 | | - // // PL_ASSERT(tSrcStages != 0); |
1851 | | - // // PL_ASSERT(tDstStages != 0); |
| 1849 | + plDevice* ptDevice = ptCmdBuffer->ptDevice; |
1852 | 1850 |
|
1853 | | - // MTLStages tSrcStage = MTLStageVertex | MTLStageFragment; |
1854 | | - // MTLStages tDstStage = MTLStageVertex | MTLStageFragment; |
1855 | | - // MTL4VisibilityOptions tOptions = MTL4VisibilityOptionDevice; |
| 1851 | + MTLStages tSrcStage = 0; |
| 1852 | + MTLStages tDstStage = 0; |
| 1853 | + MTL4VisibilityOptions tOptions = MTL4VisibilityOptionNone; |
1856 | 1854 |
|
1857 | | - // // if(tScope != 0) tOptions = MTL4VisibilityOptionDevice; |
| 1855 | + if(tScope != 0) tOptions = MTL4VisibilityOptionDevice; |
1858 | 1856 |
|
1859 | | - // // if(tSrcStages & PL_PIPELINE_STAGE_COMPUTE) tSrcStage |= MTLStageDispatch; |
1860 | | - // // if(tSrcStages & PL_PIPELINE_STAGE_BLIT) tSrcStage |= MTLStageBlit; |
1861 | | - // // if(tSrcStages & PL_PIPELINE_STAGE_VERTEX) tSrcStage |= MTLStageVertex; |
1862 | | - // // if(tSrcStages & PL_PIPELINE_STAGE_FRAGMENT) tSrcStage |= MTLStageFragment; |
| 1857 | + if(tSrcStages & PL_PIPELINE_STAGE_COMPUTE) tSrcStage |= MTLStageDispatch; |
| 1858 | + if(tSrcStages & PL_PIPELINE_STAGE_BLIT) tSrcStage |= MTLStageBlit; |
| 1859 | + if(tSrcStages & PL_PIPELINE_STAGE_VERTEX) tSrcStage |= MTLStageVertex; |
| 1860 | + if(tSrcStages & PL_PIPELINE_STAGE_FRAGMENT) tSrcStage |= MTLStageFragment; |
1863 | 1861 |
|
1864 | | - // // if(tDstStages & PL_PIPELINE_STAGE_COMPUTE) tDstStage |= MTLStageDispatch; |
1865 | | - // // if(tDstStages & PL_PIPELINE_STAGE_BLIT) tDstStage |= MTLStageBlit; |
1866 | | - // // if(tDstStages & PL_PIPELINE_STAGE_VERTEX) tDstStage |= MTLStageVertex; |
1867 | | - // // if(tDstStages & PL_PIPELINE_STAGE_FRAGMENT) tDstStage |= MTLStageFragment; |
| 1862 | + if(tDstStages & PL_PIPELINE_STAGE_COMPUTE) tDstStage |= MTLStageDispatch; |
| 1863 | + if(tDstStages & PL_PIPELINE_STAGE_BLIT) tDstStage |= MTLStageBlit; |
| 1864 | + if(tDstStages & PL_PIPELINE_STAGE_VERTEX) tDstStage |= MTLStageVertex; |
| 1865 | + if(tDstStages & PL_PIPELINE_STAGE_FRAGMENT) tDstStage |= MTLStageFragment; |
1868 | 1866 |
|
1869 | | - // [ptDevice->tRenderEncoder barrierAfterEncoderStages:tSrcStage beforeEncoderStages:tDstStage visibilityOptions:tOptions]; |
| 1867 | + if(gptGraphics->bComputeEncoderActive) |
| 1868 | + [ptDevice->tComputeEncoder barrierAfterQueueStages:tSrcStage beforeStages:tDstStage visibilityOptions:tOptions]; |
| 1869 | + else if(gptGraphics->bRenderEncoderActive) |
| 1870 | + [ptDevice->tRenderEncoder barrierAfterQueueStages:tSrcStage beforeStages:tDstStage visibilityOptions:tOptions]; |
1870 | 1871 | } |
1871 | 1872 |
|
1872 | 1873 | void |
1873 | | -pl_graphics_reset_roles(plCommandBuffer* ptCmdBuffer) |
| 1874 | +pl_graphics_consumer_barrier(plCommandBuffer* ptCmdBuffer, plPipelineStageFlags tSrcStages, plPipelineStageFlags tDstStages, plBarrierScope tScope) |
1874 | 1875 | { |
1875 | | -} |
| 1876 | + plDevice* ptDevice = ptCmdBuffer->ptDevice; |
| 1877 | + PL_ASSERT(gptGraphics->bRenderEncoderActive || gptGraphics->bComputeEncoderActive); |
| 1878 | + PL_ASSERT(tSrcStages != 0); |
| 1879 | + PL_ASSERT(tDstStages != 0); |
1876 | 1880 |
|
1877 | | -void |
1878 | | -pl_graphics_set_roles(plCommandBuffer* ptCmdBuffer, const plPassResources* ptResources) |
1879 | | -{ |
| 1881 | + plStackedBarrier tBarrier = { |
| 1882 | + .tSrcStages = tSrcStages, |
| 1883 | + .tDstStages = tDstStages, |
| 1884 | + .tScope = tScope |
| 1885 | + }; |
| 1886 | + pl_sb_push(ptCmdBuffer->ptDevice->sbtBarrierStack, tBarrier); |
1880 | 1887 | } |
1881 | 1888 |
|
1882 | 1889 | void |
|
1949 | 1956 | { |
1950 | 1957 | ptDevice->ptRenderPassDescriptor.stencilAttachment.loadAction = MTLLoadActionLoad; |
1951 | 1958 | } |
| 1959 | + |
| 1960 | + while(pl_sb_size(ptDevice->sbtBarrierStack) > 0) |
| 1961 | + { |
| 1962 | + plStackedBarrier tBarrier = pl_sb_pop(ptDevice->sbtBarrierStack); |
| 1963 | + pl__graphics_consumer_barrier(ptCmdBuffer, tBarrier.tSrcStages, tBarrier.tDstStages, tBarrier.tScope); |
| 1964 | + } |
1952 | 1965 | } |
1953 | 1966 |
|
1954 | 1967 | void |
|
2051 | 2064 | } |
2052 | 2065 |
|
2053 | 2066 | void |
2054 | | -pl_graphics_intra_pass_barrier(plCommandBuffer* ptCmdBuffer, plPipelineStageFlags tSrcStages, plPipelineStageFlags tDstStages, plBarrierScope tScope) |
| 2067 | +pl_graphics_intra_pass_barrier(plCommandBuffer* ptCmdBuffer, plPipelineStageFlags tSrcStages, plPipelineStageFlags tDstStages, plBarrierScope tScope, const plPassResources* ptResources) |
2055 | 2068 | { |
2056 | 2069 | plDevice* ptDevice = ptCmdBuffer->ptDevice; |
2057 | 2070 | PL_ASSERT(gptGraphics->bRenderEncoderActive || gptGraphics->bComputeEncoderActive); |
|
2099 | 2112 | return ptDevice->ptRenderPassDescriptor; |
2100 | 2113 | } |
2101 | 2114 |
|
2102 | | -void |
2103 | | -pl_graphics_consumer_barrier(plCommandBuffer* ptCmdBuffer, plPipelineStageFlags tSrcStages, plPipelineStageFlags tDstStages, plBarrierScope tScope) |
2104 | | -{ |
2105 | | - plDevice* ptDevice = ptCmdBuffer->ptDevice; |
2106 | | - PL_ASSERT(gptGraphics->bRenderEncoderActive || gptGraphics->bComputeEncoderActive); |
2107 | | - PL_ASSERT(tSrcStages != 0); |
2108 | | - PL_ASSERT(tDstStages != 0); |
2109 | | - |
2110 | | - MTLStages tSrcStage = 0; |
2111 | | - MTLStages tDstStage = 0; |
2112 | | - MTL4VisibilityOptions tOptions = MTL4VisibilityOptionNone; |
2113 | | - |
2114 | | - if(tScope != 0) tOptions = MTL4VisibilityOptionDevice; |
2115 | | - |
2116 | | - if(tSrcStages & PL_PIPELINE_STAGE_COMPUTE) tSrcStage |= MTLStageDispatch; |
2117 | | - if(tSrcStages & PL_PIPELINE_STAGE_BLIT) tSrcStage |= MTLStageBlit; |
2118 | | - if(tSrcStages & PL_PIPELINE_STAGE_VERTEX) tSrcStage |= MTLStageVertex; |
2119 | | - if(tSrcStages & PL_PIPELINE_STAGE_FRAGMENT) tSrcStage |= MTLStageFragment; |
2120 | | - |
2121 | | - if(tDstStages & PL_PIPELINE_STAGE_COMPUTE) tDstStage |= MTLStageDispatch; |
2122 | | - if(tDstStages & PL_PIPELINE_STAGE_BLIT) tDstStage |= MTLStageBlit; |
2123 | | - if(tDstStages & PL_PIPELINE_STAGE_VERTEX) tDstStage |= MTLStageVertex; |
2124 | | - if(tDstStages & PL_PIPELINE_STAGE_FRAGMENT) tDstStage |= MTLStageFragment; |
2125 | | - |
2126 | | - if(gptGraphics->bComputeEncoderActive) |
2127 | | - [ptDevice->tComputeEncoder barrierAfterQueueStages:tSrcStage beforeStages:tDstStage visibilityOptions:tOptions]; |
2128 | | - else if(gptGraphics->bRenderEncoderActive) |
2129 | | - [ptDevice->tRenderEncoder barrierAfterQueueStages:tSrcStage beforeStages:tDstStage visibilityOptions:tOptions]; |
2130 | | -} |
2131 | | - |
2132 | 2115 | void |
2133 | 2116 | pl_graphics_producer_barrier(plCommandBuffer* ptCmdBuffer, plPipelineStageFlags tSrcStages, plPipelineStageFlags tDstStages, plBarrierScope tScope) |
2134 | 2117 | { |
|
0 commit comments