Cocoa Port: For Metal display views, be much smarter about how we do synchronization. Should fix the performance issues introduced with commit 26ac91ed
.
This commit is contained in:
parent
1ea95cdde4
commit
a65ceae98f
|
@ -35,17 +35,32 @@
|
||||||
#undef BOOL
|
#undef BOOL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define METAL_BUFFER_COUNT 3
|
||||||
|
|
||||||
class MacMetalFetchObject;
|
class MacMetalFetchObject;
|
||||||
class MacMetalDisplayPresenter;
|
class MacMetalDisplayPresenter;
|
||||||
class MacMetalDisplayView;
|
class MacMetalDisplayView;
|
||||||
|
|
||||||
struct MetalProcessedFrameInfo
|
struct MetalProcessedFrameInfo
|
||||||
{
|
{
|
||||||
uint8_t bufferIndex;
|
uint8_t processIndex;
|
||||||
id<MTLTexture> tex[2];
|
id<MTLTexture> tex[2];
|
||||||
};
|
};
|
||||||
typedef struct MetalProcessedFrameInfo MetalProcessedFrameInfo;
|
typedef struct MetalProcessedFrameInfo MetalProcessedFrameInfo;
|
||||||
|
|
||||||
|
struct MetalRenderFrameInfo
|
||||||
|
{
|
||||||
|
uint8_t renderIndex;
|
||||||
|
bool needEncodeViewport;
|
||||||
|
MTLViewport newViewport;
|
||||||
|
bool willDrawHUD;
|
||||||
|
bool willDrawHUDInput;
|
||||||
|
size_t hudStringLength;
|
||||||
|
size_t hudTouchLineLength;
|
||||||
|
size_t hudTotalLength;
|
||||||
|
};
|
||||||
|
typedef struct MetalRenderFrameInfo MetalRenderFrameInfo;
|
||||||
|
|
||||||
struct DisplayViewShaderProperties
|
struct DisplayViewShaderProperties
|
||||||
{
|
{
|
||||||
float width;
|
float width;
|
||||||
|
@ -71,8 +86,6 @@ typedef DisplayViewShaderProperties DisplayViewShaderProperties;
|
||||||
id<MTLRenderPipelineState> hudPipeline;
|
id<MTLRenderPipelineState> hudPipeline;
|
||||||
id<MTLRenderPipelineState> hudRGBAPipeline;
|
id<MTLRenderPipelineState> hudRGBAPipeline;
|
||||||
|
|
||||||
id<MTLBlitCommandEncoder> _fetchEncoder;
|
|
||||||
|
|
||||||
id<MTLSamplerState> samplerHUDBox;
|
id<MTLSamplerState> samplerHUDBox;
|
||||||
id<MTLSamplerState> samplerHUDText;
|
id<MTLSamplerState> samplerHUDText;
|
||||||
|
|
||||||
|
@ -80,8 +93,8 @@ typedef DisplayViewShaderProperties DisplayViewShaderProperties;
|
||||||
id<MTLBuffer> _bufDisplayFetchNative[2][2];
|
id<MTLBuffer> _bufDisplayFetchNative[2][2];
|
||||||
id<MTLBuffer> _bufDisplayFetchCustom[2][2];
|
id<MTLBuffer> _bufDisplayFetchCustom[2][2];
|
||||||
|
|
||||||
id<MTLBuffer> _bufMasterBrightMode[2];
|
id<MTLBuffer> _bufMasterBrightMode[2][2];
|
||||||
id<MTLBuffer> _bufMasterBrightIntensity[2];
|
id<MTLBuffer> _bufMasterBrightIntensity[2][2];
|
||||||
|
|
||||||
size_t _fetchPixelBytes;
|
size_t _fetchPixelBytes;
|
||||||
size_t _nativeLineSize;
|
size_t _nativeLineSize;
|
||||||
|
@ -110,6 +123,8 @@ typedef DisplayViewShaderProperties DisplayViewShaderProperties;
|
||||||
MTLSize _fetchThreadGroupsPerGridCustom;
|
MTLSize _fetchThreadGroupsPerGridCustom;
|
||||||
MTLSize deposterizeThreadsPerGroup;
|
MTLSize deposterizeThreadsPerGroup;
|
||||||
MTLSize deposterizeThreadGroupsPerGrid;
|
MTLSize deposterizeThreadGroupsPerGrid;
|
||||||
|
|
||||||
|
BOOL _isSharedBufferTextureSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (readonly, nonatomic) id<MTLDevice> device;
|
@property (readonly, nonatomic) id<MTLDevice> device;
|
||||||
|
@ -158,18 +173,17 @@ typedef DisplayViewShaderProperties DisplayViewShaderProperties;
|
||||||
id<MTLRenderPipelineState> outputDrawablePipeline;
|
id<MTLRenderPipelineState> outputDrawablePipeline;
|
||||||
MTLPixelFormat drawableFormat;
|
MTLPixelFormat drawableFormat;
|
||||||
|
|
||||||
id<MTLBuffer> _cdvPropertiesBuffer;
|
id<MTLBuffer> _hudVtxPositionBuffer[METAL_BUFFER_COUNT];
|
||||||
id<MTLBuffer> _displayVtxPositionBuffer;
|
id<MTLBuffer> _hudVtxColorBuffer[METAL_BUFFER_COUNT];
|
||||||
id<MTLBuffer> _displayTexCoordBuffer;
|
id<MTLBuffer> _hudTexCoordBuffer[METAL_BUFFER_COUNT];
|
||||||
id<MTLBuffer> _hudVtxPositionBuffer;
|
|
||||||
id<MTLBuffer> _hudVtxColorBuffer;
|
|
||||||
id<MTLBuffer> _hudTexCoordBuffer;
|
|
||||||
id<MTLBuffer> _bufCPUFilterSrcMain;
|
id<MTLBuffer> _bufCPUFilterSrcMain;
|
||||||
id<MTLBuffer> _bufCPUFilterSrcTouch;
|
id<MTLBuffer> _bufCPUFilterSrcTouch;
|
||||||
id<MTLBuffer> bufCPUFilterDstMain;
|
|
||||||
id<MTLBuffer> bufCPUFilterDstTouch;
|
|
||||||
|
|
||||||
id<MTLTexture> _texDisplaySrcDeposterize[2][2];
|
float _vtxPositionBuffer[32];
|
||||||
|
float _texCoordBuffer[32];
|
||||||
|
DisplayViewShaderProperties _cdvPropertiesBuffer;
|
||||||
|
|
||||||
|
id<MTLTexture> _texDisplaySrcDeposterize[METAL_BUFFER_COUNT][2][2]; // [_processIndex][NDSDisplayID][stage]
|
||||||
id<MTLTexture> texDisplayPixelScaleMain;
|
id<MTLTexture> texDisplayPixelScaleMain;
|
||||||
id<MTLTexture> texDisplayPixelScaleTouch;
|
id<MTLTexture> texDisplayPixelScaleTouch;
|
||||||
id<MTLTexture> texHUDCharMap;
|
id<MTLTexture> texHUDCharMap;
|
||||||
|
@ -182,29 +196,22 @@ typedef DisplayViewShaderProperties DisplayViewShaderProperties;
|
||||||
BOOL needsScreenVerticesUpdate;
|
BOOL needsScreenVerticesUpdate;
|
||||||
BOOL needsHUDVerticesUpdate;
|
BOOL needsHUDVerticesUpdate;
|
||||||
|
|
||||||
dispatch_semaphore_t _semDisplayLayoutUpdate;
|
dispatch_semaphore_t _semProcessBuffers;
|
||||||
dispatch_semaphore_t _semTexProcessUpdate;
|
dispatch_semaphore_t _semRenderBuffers;
|
||||||
bool _needEncodeViewport;
|
OSSpinLock _spinlockProcessedFrameInfo;
|
||||||
MTLViewport _newViewport;
|
|
||||||
bool _willDrawHUD;
|
|
||||||
bool _willDrawHUDInput;
|
|
||||||
size_t _hudStringLength;
|
|
||||||
size_t _hudTouchLineLength;
|
|
||||||
|
|
||||||
MetalProcessedFrameInfo _processedFrameInfo;
|
uint8_t _processIndex;
|
||||||
|
MetalProcessedFrameInfo _mpfi;
|
||||||
|
MetalRenderFrameInfo _mrfi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (readonly, nonatomic) ClientDisplay3DPresenter *cdp;
|
@property (readonly, nonatomic) ClientDisplay3DPresenter *cdp;
|
||||||
@property (assign, nonatomic) MetalDisplayViewSharedData *sharedData;
|
@property (assign, nonatomic) MetalDisplayViewSharedData *sharedData;
|
||||||
@property (readonly, nonatomic) MTLRenderPassColorAttachmentDescriptor *colorAttachment0Desc;
|
@property (readonly, nonatomic) MTLRenderPassColorAttachmentDescriptor *colorAttachment0Desc;
|
||||||
@property (readonly, nonatomic) dispatch_semaphore_t semDisplayLayoutUpdate;
|
|
||||||
@property (readonly, nonatomic) dispatch_semaphore_t semTexProcessUpdate;
|
|
||||||
@property (retain) id<MTLComputePipelineState> pixelScalePipeline;
|
@property (retain) id<MTLComputePipelineState> pixelScalePipeline;
|
||||||
@property (retain) id<MTLRenderPipelineState> outputRGBAPipeline;
|
@property (retain) id<MTLRenderPipelineState> outputRGBAPipeline;
|
||||||
@property (retain) id<MTLRenderPipelineState> outputDrawablePipeline;
|
@property (retain) id<MTLRenderPipelineState> outputDrawablePipeline;
|
||||||
@property (assign) MTLPixelFormat drawableFormat;
|
@property (assign) MTLPixelFormat drawableFormat;
|
||||||
@property (retain) id<MTLBuffer> bufCPUFilterDstMain;
|
|
||||||
@property (retain) id<MTLBuffer> bufCPUFilterDstTouch;
|
|
||||||
@property (retain) id<MTLTexture> texDisplayPixelScaleMain;
|
@property (retain) id<MTLTexture> texDisplayPixelScaleMain;
|
||||||
@property (retain) id<MTLTexture> texDisplayPixelScaleTouch;
|
@property (retain) id<MTLTexture> texDisplayPixelScaleTouch;
|
||||||
@property (retain) id<MTLTexture> texHUDCharMap;
|
@property (retain) id<MTLTexture> texHUDCharMap;
|
||||||
|
@ -216,19 +223,18 @@ typedef DisplayViewShaderProperties DisplayViewShaderProperties;
|
||||||
@property (assign, nonatomic) OutputFilterTypeID outputFilter;
|
@property (assign, nonatomic) OutputFilterTypeID outputFilter;
|
||||||
|
|
||||||
- (id) initWithDisplayPresenter:(MacMetalDisplayPresenter *)thePresenter;
|
- (id) initWithDisplayPresenter:(MacMetalDisplayPresenter *)thePresenter;
|
||||||
- (const MetalProcessedFrameInfo &) processedFrameInfo;
|
- (MetalProcessedFrameInfo) processedFrameInfo;
|
||||||
- (id<MTLCommandBuffer>) newCommandBuffer;
|
- (id<MTLCommandBuffer>) newCommandBuffer;
|
||||||
- (void) setup;
|
- (void) setup;
|
||||||
- (void) resizeCPUPixelScalerUsingFilterID:(const VideoFilterTypeID)filterID;
|
|
||||||
- (void) copyHUDFontUsingFace:(const FT_Face &)fontFace size:(const size_t)glyphSize tileSize:(const size_t)glyphTileSize info:(GlyphInfo *)glyphInfo;
|
- (void) copyHUDFontUsingFace:(const FT_Face &)fontFace size:(const size_t)glyphSize tileSize:(const size_t)glyphTileSize info:(GlyphInfo *)glyphInfo;
|
||||||
- (void) processDisplays;
|
- (void) processDisplays;
|
||||||
- (void) updateTexCoordBuffer;
|
|
||||||
- (void) updateRenderBuffers;
|
- (void) updateRenderBuffers;
|
||||||
- (void) renderForCommandBuffer:(id<MTLCommandBuffer>)cb
|
- (void) renderForCommandBuffer:(id<MTLCommandBuffer>)cb
|
||||||
outputPipelineState:(id<MTLRenderPipelineState>)outputPipelineState
|
outputPipelineState:(id<MTLRenderPipelineState>)outputPipelineState
|
||||||
hudPipelineState:(id<MTLRenderPipelineState>)hudPipelineState
|
hudPipelineState:(id<MTLRenderPipelineState>)hudPipelineState
|
||||||
texDisplayMain:(id<MTLTexture>)texDisplayMain
|
texDisplayMain:(id<MTLTexture>)texDisplayMain
|
||||||
texDisplayTouch:(id<MTLTexture>)texDisplayTouch;
|
texDisplayTouch:(id<MTLTexture>)texDisplayTouch;
|
||||||
|
- (void) renderFinish;
|
||||||
- (void) renderToBuffer:(uint32_t *)dstBuffer;
|
- (void) renderToBuffer:(uint32_t *)dstBuffer;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -288,7 +294,6 @@ protected:
|
||||||
virtual void _UpdateClientSize();
|
virtual void _UpdateClientSize();
|
||||||
virtual void _UpdateViewScale();
|
virtual void _UpdateViewScale();
|
||||||
virtual void _LoadNativeDisplayByID(const NDSDisplayID displayID);
|
virtual void _LoadNativeDisplayByID(const NDSDisplayID displayID);
|
||||||
virtual void _ResizeCPUPixelScaler(const VideoFilterTypeID filterID);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MacMetalDisplayPresenter();
|
MacMetalDisplayPresenter();
|
||||||
|
@ -310,7 +315,6 @@ public:
|
||||||
|
|
||||||
// Client view interface
|
// Client view interface
|
||||||
virtual void ProcessDisplays();
|
virtual void ProcessDisplays();
|
||||||
virtual void UpdateLayout();
|
|
||||||
|
|
||||||
virtual void CopyFrameToBuffer(uint32_t *dstBuffer);
|
virtual void CopyFrameToBuffer(uint32_t *dstBuffer);
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue