mirror of
https://github.com/TASEmulators/desmume
synced 2025-10-05 16:22:49 +02:00
Cocoa Port: OpenGL display views can now perform color conversions and apply the NDS Master Brightness on the GPU during video fetch, just like how Metal display views do it.
- Systems with fast non-Metal capable GPUs (such as the MacBook Pro 17" Late-2011 or the iMac 27" Mid-2011) will see the most benefit, especially when running 18-bit video at high GPU scaling factors. - For older systems with slower GPUs, running the new GPU-based video postprocessing may result in an overall performance loss. In order to run the video postprocessing on the CPU like before, you can use the menu option "View > Run Filters on GPU" to control whether video postprocessing happens on the GPU or on the CPU.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -52,14 +52,38 @@ enum ShaderSupportTier
|
||||
ShaderSupport_FutureTier = 6
|
||||
};
|
||||
|
||||
struct OGLProcessedFrameInfo
|
||||
enum OGLDisplayTextureUnitID
|
||||
{
|
||||
OGLDisplayTextureUnitID_Video = 0,
|
||||
OGLDisplayTextureUnitID_MasterBrightnessMode = 1,
|
||||
OGLDisplayTextureUnitID_MasterBrightnessIntensity
|
||||
};
|
||||
|
||||
struct OGLFrameInfoFetch
|
||||
{
|
||||
uint64_t sequenceNumber;
|
||||
uint8_t bufferIndex;
|
||||
GLuint texID[2];
|
||||
bool isMainDisplayProcessed;
|
||||
bool isTouchDisplayProcessed;
|
||||
GLsizei width[2];
|
||||
GLsizei height[2];
|
||||
float backlightIntensity[2];
|
||||
|
||||
bool isNativeRender[2];
|
||||
bool isNativeSize[2];
|
||||
bool isDisplayEnabled[2];
|
||||
bool isDisplayAllWhite[2];
|
||||
bool isDisplayAllBlack[2];
|
||||
bool isDisplayProcessPossible[2];
|
||||
};
|
||||
typedef struct OGLProcessedFrameInfo OGLProcessedFrameInfo;
|
||||
typedef struct OGLFrameInfoFetch OGLFrameInfoFetch;
|
||||
|
||||
struct OGLFrameInfoProcessed
|
||||
{
|
||||
uint64_t sequenceNumber;
|
||||
GLuint texID[2];
|
||||
float backlightIntensity[2];
|
||||
};
|
||||
typedef struct OGLFrameInfoProcessed OGLFrameInfoProcessed;
|
||||
|
||||
class OGLContextInfo
|
||||
{
|
||||
@@ -70,11 +94,13 @@ protected:
|
||||
char _rendererString[256];
|
||||
ShaderSupportTier _shaderSupport;
|
||||
bool _useShader150;
|
||||
bool _isIntegerTextureSupported;
|
||||
|
||||
bool _isVBOSupported;
|
||||
bool _isVAOSupported;
|
||||
bool _isPBOSupported;
|
||||
bool _isFBOSupported;
|
||||
bool _isTBOSupported;
|
||||
|
||||
public:
|
||||
OGLContextInfo();
|
||||
@@ -86,11 +112,13 @@ public:
|
||||
const char* GetRendererString() const;
|
||||
|
||||
bool IsUsingShader150();
|
||||
bool IsIntegerTextureSupported() const;
|
||||
bool IsVBOSupported();
|
||||
bool IsVAOSupported();
|
||||
bool IsPBOSupported();
|
||||
bool IsShaderSupported();
|
||||
bool IsFBOSupported();
|
||||
bool IsTBOSupported() const;
|
||||
ShaderSupportTier GetShaderSupport();
|
||||
|
||||
virtual void GetExtensionSetOGL(std::set<std::string> *oglExtensionSet) = 0;
|
||||
@@ -114,8 +142,8 @@ protected:
|
||||
GLuint _programID;
|
||||
ShaderSupportTier _shaderSupport;
|
||||
|
||||
virtual GLuint LoadShaderOGL(GLenum shaderType, const char *shaderProgram, bool useShader150);
|
||||
virtual bool LinkOGL();
|
||||
virtual GLuint _LoadShaderOGL(GLenum shaderType, const char *shaderProgram, bool useShader150, bool useIntegerTextures);
|
||||
virtual bool _LinkOGL();
|
||||
|
||||
public:
|
||||
OGLShaderProgram();
|
||||
@@ -126,8 +154,8 @@ public:
|
||||
GLuint GetVertexShaderID();
|
||||
void SetVertexShaderOGL(const char *shaderProgram, bool useVtxColors, bool useShader150);
|
||||
GLuint GetFragmentShaderID();
|
||||
void SetFragmentShaderOGL(const char *shaderProgram, bool useShader150);
|
||||
void SetVertexAndFragmentShaderOGL(const char *vertShaderProgram, const char *fragShaderProgram, bool useVtxColors, bool useShader150);
|
||||
void SetFragmentShaderOGL(const char *shaderProgram, bool useShader150, bool useIntegerTextures);
|
||||
void SetVertexAndFragmentShaderOGL(const char *vertShaderProgram, const char *fragShaderProgram, bool useVtxColors, bool useShader150, bool useIntegerTextures);
|
||||
GLuint GetProgramID();
|
||||
};
|
||||
|
||||
@@ -163,6 +191,8 @@ public:
|
||||
virtual void SetSrcSizeOGL(GLsizei w, GLsizei h);
|
||||
GLfloat GetScale();
|
||||
void SetScaleOGL(GLfloat scale, void *buffer);
|
||||
GLsizei GetDstWidth() const;
|
||||
GLsizei GetDstHeight() const;
|
||||
virtual GLuint RunFilterOGL(GLuint srcTexID);
|
||||
void DownloadDstBufferOGL(uint32_t *dstBuffer, size_t lineOffset, size_t readLineCount);
|
||||
};
|
||||
@@ -326,6 +356,7 @@ protected:
|
||||
|
||||
void _UpdateRotationScaleOGL();
|
||||
void _UpdateVerticesOGL();
|
||||
GLuint _ProcessDisplayByID_OGL(NDSDisplayID displayID, GLuint texID, size_t bufferIndex, bool useDeposterize, VideoFilterTypeID filterID, VideoFilter *cpuFilter, GLsizei &inoutWidth, GLsizei &inoutHeight);
|
||||
|
||||
public:
|
||||
OGLDisplayLayer() {};
|
||||
@@ -346,24 +377,52 @@ class OGLClientSharedData
|
||||
{
|
||||
protected:
|
||||
OGLContextInfo *_contextInfo;
|
||||
|
||||
GLuint _vboVideoProcVtxID;
|
||||
GLuint _vboVideoProcTexCoordNativeID;
|
||||
GLuint _vboVideoProcTexCoordCustomID;
|
||||
GLuint _vaoVideoProcNativeID;
|
||||
GLuint _vaoVideoProcCustomID;
|
||||
GLuint _fboDisplayNativeID[2];
|
||||
GLuint _fboDisplayCustomID[2];
|
||||
|
||||
GLenum _fetchColorFormatOGL;
|
||||
GLuint _texDisplayFetchNative[2][OPENGL_FETCH_BUFFER_COUNT];
|
||||
GLuint _texDisplayFetchCustom[2][OPENGL_FETCH_BUFFER_COUNT];
|
||||
GLuint _texDisplayPostprocessNative[2];
|
||||
GLuint _texDisplayPostprocessCustom[2];
|
||||
GLuint _texDisplayAllWhite;
|
||||
GLuint _texDisplayAllBlack;
|
||||
|
||||
GLuint _texMasterBrightnessMode[2][OPENGL_FETCH_BUFFER_COUNT];
|
||||
GLuint _texMasterBrightnessIntensity[2][OPENGL_FETCH_BUFFER_COUNT];
|
||||
|
||||
GLuint _texLQ2xLUT;
|
||||
GLuint _texHQ2xLUT;
|
||||
GLuint _texHQ3xLUT;
|
||||
GLuint _texHQ4xLUT;
|
||||
|
||||
GLuint _texFetch[2];
|
||||
GLuint _texFetchSelected[2];
|
||||
|
||||
bool _canProcessFetchOnGPU;
|
||||
bool _preferCPUVideoProcessing;
|
||||
bool _useDirectToCPUFilterPipeline;
|
||||
uint32_t *_srcNativeCloneMaster;
|
||||
uint32_t *_srcNativeClone[2][OPENGL_FETCH_BUFFER_COUNT];
|
||||
pthread_rwlock_t _srcCloneRWLock[2][OPENGL_FETCH_BUFFER_COUNT];
|
||||
pthread_rwlock_t _texFetchRWLock[2];
|
||||
bool _srcCloneNeedsUpdate[2][OPENGL_FETCH_BUFFER_COUNT];
|
||||
|
||||
OGLShaderProgram *_programFetch666ConvertOnly;
|
||||
OGLShaderProgram *_programFetch666WithMB;
|
||||
OGLShaderProgram *_programFetch888WithMB;
|
||||
GLint _vtxTexCoordBufferNative[8];
|
||||
GLint _vtxTexCoordBufferCustom[8];
|
||||
|
||||
pthread_rwlock_t _fetchInfoRWLock;
|
||||
OGLFrameInfoFetch _fetchInfo;
|
||||
|
||||
GLuint _FetchFromDisplayID_OGL(const NDSDisplayInfo ¤tDisplayInfo, NDSDisplayID displayID, GLuint texVideoID, GLuint texMBModeID, GLuint texMBIntensityID);
|
||||
|
||||
public:
|
||||
OGLClientSharedData();
|
||||
virtual ~OGLClientSharedData();
|
||||
@@ -371,15 +430,21 @@ public:
|
||||
void SetContextInfo(OGLContextInfo *contextInfo);
|
||||
OGLContextInfo* GetContextInfo() const;
|
||||
|
||||
bool CanProcessFetchOnGPU() const;
|
||||
|
||||
void SetPreferCPUVideoProcessing(bool prefersCPUVideoProcessing);
|
||||
bool PreferCPUVideoProcessing() const;
|
||||
|
||||
void SetUseDirectToCPUFilterPipeline(bool willUseDirectCPU);
|
||||
bool UseDirectToCPUFilterPipeline() const;
|
||||
|
||||
virtual GLuint GetFetchTexture(const NDSDisplayID displayID);
|
||||
virtual void SetFetchTexture(const NDSDisplayID displayID, GLuint texID);
|
||||
OGLFrameInfoFetch GetFetchInfo();
|
||||
|
||||
uint32_t* GetSrcClone(const NDSDisplayID displayID, const u8 bufferIndex) const;
|
||||
GLuint GetTexNative(const NDSDisplayID displayID, const u8 bufferIndex) const;
|
||||
GLuint GetTexCustom(const NDSDisplayID displayID, const u8 bufferIndex) const;
|
||||
GLuint GetTexDisplayAllWhite() const;
|
||||
GLuint GetTexDisplayAllBlack() const;
|
||||
|
||||
// For lack of a better place, we're putting the HQnx LUTs in the fetch object because
|
||||
// we know that it will be shared for all display views.
|
||||
@@ -394,7 +459,7 @@ public:
|
||||
|
||||
// OpenGL-specific functions that must be called in response to their
|
||||
// corresponding GPUClientFetchObject methods.
|
||||
void InitOGL();
|
||||
void InitOGL(const NDSDisplayInfo *displayInfoList, const NDSDisplayInfo ¤tDisplayInfo);
|
||||
void SetFetchBuffersOGL(const NDSDisplayInfo *displayInfoList, const NDSDisplayInfo ¤tDisplayInfo);
|
||||
void FetchFromBufferIndexOGL(const u8 index, const NDSDisplayInfo ¤tDisplayInfo);
|
||||
void FetchNativeDisplayByID_OGL(const NDSDisplayInfo *displayInfoList, const NDSDisplayID displayID, const u8 bufferIndex);
|
||||
@@ -413,7 +478,7 @@ protected:
|
||||
GLuint _texCPUFilterDstID[2];
|
||||
GLuint _fboFrameCopyID;
|
||||
|
||||
OGLProcessedFrameInfo _processedFrameInfo;
|
||||
OGLFrameInfoProcessed _processedFrameInfo;
|
||||
|
||||
std::vector<OGLVideoLayer *> *_layerList;
|
||||
|
||||
@@ -459,8 +524,8 @@ public:
|
||||
virtual void PrerenderStateSetupOGL();
|
||||
virtual void RenderFrameOGL(bool isRenderingFlipped);
|
||||
|
||||
virtual const OGLProcessedFrameInfo& GetProcessedFrameInfo();
|
||||
virtual void SetProcessedFrameInfo(const OGLProcessedFrameInfo &processedInfo);
|
||||
virtual const OGLFrameInfoProcessed& GetFrameInfoProcessed();
|
||||
virtual void SetFrameInfoProcessed(const OGLFrameInfoProcessed &processedInfo);
|
||||
|
||||
virtual void WriteLockEmuFramebuffer(const uint8_t bufferIndex);
|
||||
virtual void ReadLockEmuFramebuffer(const uint8_t bufferIndex);
|
||||
|
@@ -41,6 +41,7 @@ void glGenVertexArrays_3_2(GLsizei n, GLuint *vaoIDs)
|
||||
OGLContextInfo_3_2::OGLContextInfo_3_2()
|
||||
{
|
||||
_useShader150 = true;
|
||||
_isIntegerTextureSupported = true;
|
||||
_isVBOSupported = true;
|
||||
_isVAOSupported = true;
|
||||
_isPBOSupported = true;
|
||||
|
@@ -114,6 +114,7 @@ protected:
|
||||
pthread_rwlock_t *_rwlockOutputList;
|
||||
pthread_mutex_t _mutexDisplayLinkLists;
|
||||
NSMutableArray *_cdsOutputList;
|
||||
volatile int32_t _numberViewsPreferringCPUVideoProcessing;
|
||||
volatile int32_t _numberViewsUsingDirectToCPUFiltering;
|
||||
|
||||
DisplayLinksActiveMap _displayLinksActiveList;
|
||||
@@ -123,11 +124,17 @@ public:
|
||||
MacGPUFetchObjectDisplayLink();
|
||||
~MacGPUFetchObjectDisplayLink();
|
||||
|
||||
volatile int32_t GetNumberViewsPreferringCPUVideoProcessing() const;
|
||||
volatile int32_t GetNumberViewsUsingDirectToCPUFiltering() const;
|
||||
|
||||
void SetOutputList(NSMutableArray *theOutputList, pthread_rwlock_t *theRWLock);
|
||||
|
||||
void IncrementViewsPreferringCPUVideoProcessing();
|
||||
void DecrementViewsPreferringCPUVideoProcessing();
|
||||
|
||||
void IncrementViewsUsingDirectToCPUFiltering();
|
||||
void DecrementViewsUsingDirectToCPUFiltering();
|
||||
|
||||
void PushVideoDataToAllDisplayViews();
|
||||
|
||||
void DisplayLinkStartUsingID(CGDirectDisplayID displayID);
|
||||
|
@@ -173,6 +173,7 @@ char __hostRendererString[256] = {0};
|
||||
{
|
||||
#ifdef PORT_VERSION_OS_X_APP
|
||||
fetchObject = new MacOGLClientFetchObject;
|
||||
GPU->SetWillPostprocessDisplays(false);
|
||||
#else
|
||||
fetchObject = new OE_OGLClientFetchObject;
|
||||
#endif
|
||||
@@ -1474,6 +1475,7 @@ MacGPUFetchObjectDisplayLink::MacGPUFetchObjectDisplayLink()
|
||||
|
||||
_rwlockOutputList = NULL;
|
||||
_cdsOutputList = nil;
|
||||
_numberViewsPreferringCPUVideoProcessing = 0;
|
||||
_numberViewsUsingDirectToCPUFiltering = 0;
|
||||
|
||||
_displayLinksActiveList.clear();
|
||||
@@ -1532,6 +1534,11 @@ MacGPUFetchObjectDisplayLink::~MacGPUFetchObjectDisplayLink()
|
||||
}
|
||||
}
|
||||
|
||||
volatile int32_t MacGPUFetchObjectDisplayLink::GetNumberViewsPreferringCPUVideoProcessing() const
|
||||
{
|
||||
return this->_numberViewsPreferringCPUVideoProcessing;
|
||||
}
|
||||
|
||||
volatile int32_t MacGPUFetchObjectDisplayLink::GetNumberViewsUsingDirectToCPUFiltering() const
|
||||
{
|
||||
return this->_numberViewsUsingDirectToCPUFiltering;
|
||||
@@ -1558,6 +1565,16 @@ void MacGPUFetchObjectDisplayLink::SetOutputList(NSMutableArray *theOutputList,
|
||||
this->_rwlockOutputList = theRWLock;
|
||||
}
|
||||
|
||||
void MacGPUFetchObjectDisplayLink::IncrementViewsPreferringCPUVideoProcessing()
|
||||
{
|
||||
atomic_inc_32(&this->_numberViewsPreferringCPUVideoProcessing);
|
||||
}
|
||||
|
||||
void MacGPUFetchObjectDisplayLink::DecrementViewsPreferringCPUVideoProcessing()
|
||||
{
|
||||
atomic_dec_32(&this->_numberViewsPreferringCPUVideoProcessing);
|
||||
}
|
||||
|
||||
void MacGPUFetchObjectDisplayLink::IncrementViewsUsingDirectToCPUFiltering()
|
||||
{
|
||||
atomic_inc_32(&this->_numberViewsUsingDirectToCPUFiltering);
|
||||
|
@@ -2005,23 +2005,40 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
||||
|
||||
- (void) setVideoFiltersPreferGPU:(BOOL)theState
|
||||
{
|
||||
const BOOL oldState = ( ![[self cdsVideoOutput] willFilterOnGPU] && ![[self cdsVideoOutput] sourceDeposterize] && ([[self cdsVideoOutput] pixelScaler] != VideoFilterTypeID_None) );
|
||||
const BOOL oldStateWillFilterDirectToCPU = ( ![[self cdsVideoOutput] willFilterOnGPU] && ![[self cdsVideoOutput] sourceDeposterize] && ([[self cdsVideoOutput] pixelScaler] != VideoFilterTypeID_None) );
|
||||
const BOOL oldStateRequestFilterOnCPU = ![[self cdsVideoOutput] videoFiltersPreferGPU];
|
||||
[[self cdsVideoOutput] setVideoFiltersPreferGPU:theState];
|
||||
const BOOL newState = ( ![[self cdsVideoOutput] willFilterOnGPU] && ![[self cdsVideoOutput] sourceDeposterize] && ([[self cdsVideoOutput] pixelScaler] != VideoFilterTypeID_None) );
|
||||
const BOOL newStateRequestFilterOnCPU = ![[self cdsVideoOutput] videoFiltersPreferGPU];
|
||||
const BOOL newStateWillFilterDirectToCPU = ( ![[self cdsVideoOutput] willFilterOnGPU] && ![[self cdsVideoOutput] sourceDeposterize] && ([[self cdsVideoOutput] pixelScaler] != VideoFilterTypeID_None) );
|
||||
|
||||
if (oldState != newState)
|
||||
if ( (oldStateRequestFilterOnCPU != newStateRequestFilterOnCPU) || (oldStateWillFilterDirectToCPU != newStateWillFilterDirectToCPU) )
|
||||
{
|
||||
DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate];
|
||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[[[windowController emuControl] cdsCoreController] content];
|
||||
MacGPUFetchObjectDisplayLink *dlFetchObj = (MacGPUFetchObjectDisplayLink *)[[cdsCore cdsGPU] fetchObject];
|
||||
|
||||
if (newState)
|
||||
if (oldStateRequestFilterOnCPU != newStateRequestFilterOnCPU)
|
||||
{
|
||||
dlFetchObj->IncrementViewsUsingDirectToCPUFiltering();
|
||||
if (newStateRequestFilterOnCPU)
|
||||
{
|
||||
dlFetchObj->IncrementViewsPreferringCPUVideoProcessing();
|
||||
}
|
||||
else
|
||||
{
|
||||
dlFetchObj->DecrementViewsPreferringCPUVideoProcessing();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (oldStateWillFilterDirectToCPU != newStateWillFilterDirectToCPU)
|
||||
{
|
||||
dlFetchObj->DecrementViewsUsingDirectToCPUFiltering();
|
||||
if (newStateWillFilterDirectToCPU)
|
||||
{
|
||||
dlFetchObj->IncrementViewsUsingDirectToCPUFiltering();
|
||||
}
|
||||
else
|
||||
{
|
||||
dlFetchObj->DecrementViewsUsingDirectToCPUFiltering();
|
||||
}
|
||||
}
|
||||
|
||||
[[self cdsVideoOutput] signalMessage:MESSAGE_RELOAD_REPROCESS_REDRAW];
|
||||
@@ -2035,17 +2052,17 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
||||
|
||||
- (void) setSourceDeposterize:(BOOL)theState
|
||||
{
|
||||
const BOOL oldState = ( ![[self cdsVideoOutput] willFilterOnGPU] && ![[self cdsVideoOutput] sourceDeposterize] && ([[self cdsVideoOutput] pixelScaler] != VideoFilterTypeID_None) );
|
||||
const BOOL oldStateWillFilterDirectToCPU = ( ![[self cdsVideoOutput] willFilterOnGPU] && ![[self cdsVideoOutput] sourceDeposterize] && ([[self cdsVideoOutput] pixelScaler] != VideoFilterTypeID_None) );
|
||||
[[self cdsVideoOutput] setSourceDeposterize:theState];
|
||||
const BOOL newState = ( ![[self cdsVideoOutput] willFilterOnGPU] && ![[self cdsVideoOutput] sourceDeposterize] && ([[self cdsVideoOutput] pixelScaler] != VideoFilterTypeID_None) );
|
||||
const BOOL newStateWillFilterDirectToCPU = ( ![[self cdsVideoOutput] willFilterOnGPU] && ![[self cdsVideoOutput] sourceDeposterize] && ([[self cdsVideoOutput] pixelScaler] != VideoFilterTypeID_None) );
|
||||
|
||||
if (oldState != newState)
|
||||
if (oldStateWillFilterDirectToCPU != newStateWillFilterDirectToCPU)
|
||||
{
|
||||
DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate];
|
||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[[[windowController emuControl] cdsCoreController] content];
|
||||
MacGPUFetchObjectDisplayLink *dlFetchObj = (MacGPUFetchObjectDisplayLink *)[[cdsCore cdsGPU] fetchObject];
|
||||
|
||||
if (newState)
|
||||
if (newStateWillFilterDirectToCPU)
|
||||
{
|
||||
dlFetchObj->IncrementViewsUsingDirectToCPUFiltering();
|
||||
}
|
||||
@@ -2076,17 +2093,17 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
||||
|
||||
- (void) setPixelScaler:(NSInteger)filterID
|
||||
{
|
||||
const BOOL oldState = ( ![[self cdsVideoOutput] willFilterOnGPU] && ![[self cdsVideoOutput] sourceDeposterize] && ([[self cdsVideoOutput] pixelScaler] != VideoFilterTypeID_None) );
|
||||
const BOOL oldStateWillFilterDirectToCPU = ( ![[self cdsVideoOutput] willFilterOnGPU] && ![[self cdsVideoOutput] sourceDeposterize] && ([[self cdsVideoOutput] pixelScaler] != VideoFilterTypeID_None) );
|
||||
[[self cdsVideoOutput] setPixelScaler:filterID];
|
||||
const BOOL newState = ( ![[self cdsVideoOutput] willFilterOnGPU] && ![[self cdsVideoOutput] sourceDeposterize] && ([[self cdsVideoOutput] pixelScaler] != VideoFilterTypeID_None) );
|
||||
const BOOL newStateWillFilterDirectToCPU = ( ![[self cdsVideoOutput] willFilterOnGPU] && ![[self cdsVideoOutput] sourceDeposterize] && ([[self cdsVideoOutput] pixelScaler] != VideoFilterTypeID_None) );
|
||||
|
||||
if (oldState != newState)
|
||||
if (oldStateWillFilterDirectToCPU != newStateWillFilterDirectToCPU)
|
||||
{
|
||||
DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate];
|
||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[[[windowController emuControl] cdsCoreController] content];
|
||||
MacGPUFetchObjectDisplayLink *dlFetchObj = (MacGPUFetchObjectDisplayLink *)[[cdsCore cdsGPU] fetchObject];
|
||||
|
||||
if (newState)
|
||||
if (newStateWillFilterDirectToCPU)
|
||||
{
|
||||
dlFetchObj->IncrementViewsUsingDirectToCPUFiltering();
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2017-2022 DeSmuME team
|
||||
Copyright (C) 2017-2025 DeSmuME team
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -46,15 +46,9 @@ class MacOGLDisplayView;
|
||||
|
||||
class MacOGLClientSharedData : public OGLClientSharedData
|
||||
{
|
||||
protected:
|
||||
apple_unfairlock_t _unfairlockTexFetch[2];
|
||||
|
||||
public:
|
||||
MacOGLClientSharedData();
|
||||
~MacOGLClientSharedData();
|
||||
|
||||
virtual GLuint GetFetchTexture(const NDSDisplayID displayID);
|
||||
virtual void SetFetchTexture(const NDSDisplayID displayID, GLuint texID);
|
||||
};
|
||||
|
||||
class MacOGLClientFetchObject : public MacGPUFetchObjectDisplayLink
|
||||
@@ -75,6 +69,8 @@ public:
|
||||
NSOpenGLContext* GetNSContext() const;
|
||||
CGLContextObj GetContext() const;
|
||||
|
||||
bool CanProcessFetchOnGPU() const;
|
||||
|
||||
void FetchNativeDisplayToSrcClone(const NDSDisplayID displayID, const u8 bufferIndex, bool needsLock);
|
||||
void FetchCustomDisplayToSrcClone(const NDSDisplayID displayID, const u8 bufferIndex, bool needsLock);
|
||||
|
||||
@@ -122,8 +118,8 @@ public:
|
||||
virtual void ProcessDisplays();
|
||||
virtual void CopyFrameToBuffer(uint32_t *dstBuffer);
|
||||
|
||||
virtual const OGLProcessedFrameInfo& GetProcessedFrameInfo();
|
||||
virtual void SetProcessedFrameInfo(const OGLProcessedFrameInfo &processedInfo);
|
||||
virtual const OGLFrameInfoProcessed& GetFrameInfoProcessed();
|
||||
virtual void SetFrameInfoProcessed(const OGLFrameInfoProcessed &processedInfo);
|
||||
|
||||
virtual void WriteLockEmuFramebuffer(const uint8_t bufferIndex);
|
||||
virtual void ReadLockEmuFramebuffer(const uint8_t bufferIndex);
|
||||
|
@@ -81,32 +81,12 @@
|
||||
|
||||
MacOGLClientSharedData::MacOGLClientSharedData()
|
||||
{
|
||||
_unfairlockTexFetch[NDSDisplayID_Main] = apple_unfairlock_create();
|
||||
_unfairlockTexFetch[NDSDisplayID_Touch] = apple_unfairlock_create();
|
||||
// Do nothing. This class is a platform-specific placeholder.
|
||||
}
|
||||
|
||||
MacOGLClientSharedData::~MacOGLClientSharedData()
|
||||
{
|
||||
apple_unfairlock_destroy(this->_unfairlockTexFetch[NDSDisplayID_Main]);
|
||||
this->_unfairlockTexFetch[NDSDisplayID_Main] = NULL;
|
||||
apple_unfairlock_destroy(this->_unfairlockTexFetch[NDSDisplayID_Touch]);
|
||||
this->_unfairlockTexFetch[NDSDisplayID_Touch] = NULL;
|
||||
}
|
||||
|
||||
GLuint MacOGLClientSharedData::GetFetchTexture(const NDSDisplayID displayID)
|
||||
{
|
||||
apple_unfairlock_lock(this->_unfairlockTexFetch[displayID]);
|
||||
const GLuint texFetchID = this->OGLClientSharedData::GetFetchTexture(displayID);
|
||||
apple_unfairlock_unlock(this->_unfairlockTexFetch[displayID]);
|
||||
|
||||
return texFetchID;
|
||||
}
|
||||
|
||||
void MacOGLClientSharedData::SetFetchTexture(const NDSDisplayID displayID, GLuint texID)
|
||||
{
|
||||
apple_unfairlock_lock(this->_unfairlockTexFetch[displayID]);
|
||||
this->OGLClientSharedData::SetFetchTexture(displayID, texID);
|
||||
apple_unfairlock_unlock(this->_unfairlockTexFetch[displayID]);
|
||||
// Do nothing. This class is a platform-specific placeholder.
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
@@ -256,6 +236,11 @@ CGLContextObj MacOGLClientFetchObject::GetContext() const
|
||||
return this->_context;
|
||||
}
|
||||
|
||||
bool MacOGLClientFetchObject::CanProcessFetchOnGPU() const
|
||||
{
|
||||
return ((MacOGLClientSharedData *)this->_clientData)->CanProcessFetchOnGPU();
|
||||
}
|
||||
|
||||
void MacOGLClientFetchObject::FetchNativeDisplayToSrcClone(const NDSDisplayID displayID, const u8 bufferIndex, bool needsLock)
|
||||
{
|
||||
MacOGLClientSharedData *sharedData = (MacOGLClientSharedData *)this->_clientData;
|
||||
@@ -271,10 +256,11 @@ void MacOGLClientFetchObject::FetchCustomDisplayToSrcClone(const NDSDisplayID di
|
||||
void MacOGLClientFetchObject::Init()
|
||||
{
|
||||
MacOGLClientSharedData *sharedData = (MacOGLClientSharedData *)this->_clientData;
|
||||
const NDSDisplayInfo ¤tDisplayInfo = GPU->GetDisplayInfo();
|
||||
|
||||
CGLContextObj prevContext = CGLGetCurrentContext();
|
||||
CGLSetCurrentContext(this->_context);
|
||||
sharedData->InitOGL();
|
||||
sharedData->InitOGL(this->_fetchDisplayInfo, currentDisplayInfo);
|
||||
CGLSetCurrentContext(prevContext);
|
||||
|
||||
this->MacGPUFetchObjectDisplayLink::Init();
|
||||
@@ -295,8 +281,11 @@ void MacOGLClientFetchObject::FetchFromBufferIndex(const u8 index)
|
||||
{
|
||||
MacOGLClientSharedData *sharedData = (MacOGLClientSharedData *)this->_clientData;
|
||||
|
||||
const bool willUseDirectCPU = (this->GetNumberViewsUsingDirectToCPUFiltering() > 0);
|
||||
sharedData->SetUseDirectToCPUFilterPipeline(willUseDirectCPU);
|
||||
const bool preferCPUVideoProcessing = (this->GetNumberViewsPreferringCPUVideoProcessing() > 0);
|
||||
sharedData->SetPreferCPUVideoProcessing(preferCPUVideoProcessing);
|
||||
|
||||
const bool willFilterDirectToCPU = (this->GetNumberViewsUsingDirectToCPUFiltering() > 0);
|
||||
sharedData->SetUseDirectToCPUFilterPipeline(willFilterDirectToCPU);
|
||||
|
||||
semaphore_wait( this->SemaphoreFramebufferPageAtIndex(index) );
|
||||
this->SetFramebufferState(ClientDisplayBufferState_Reading, index);
|
||||
@@ -305,10 +294,10 @@ void MacOGLClientFetchObject::FetchFromBufferIndex(const u8 index)
|
||||
CGLSetCurrentContext(this->_context);
|
||||
|
||||
this->GPUClientFetchObject::FetchFromBufferIndex(index);
|
||||
glFlush();
|
||||
|
||||
const NDSDisplayInfo ¤tDisplayInfo = this->GetFetchDisplayInfoForBufferIndex(index);
|
||||
sharedData->FetchFromBufferIndexOGL(index, currentDisplayInfo);
|
||||
glFlush();
|
||||
|
||||
CGLUnlockContext(this->_context);
|
||||
|
||||
@@ -568,19 +557,19 @@ void MacOGLDisplayPresenter::CopyFrameToBuffer(uint32_t *dstBuffer)
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
const OGLProcessedFrameInfo& MacOGLDisplayPresenter::GetProcessedFrameInfo()
|
||||
const OGLFrameInfoProcessed& MacOGLDisplayPresenter::GetFrameInfoProcessed()
|
||||
{
|
||||
apple_unfairlock_lock(this->_unfairlockProcessedInfo);
|
||||
const OGLProcessedFrameInfo &processedInfo = this->OGLVideoOutput::GetProcessedFrameInfo();
|
||||
const OGLFrameInfoProcessed &processedInfo = this->OGLVideoOutput::GetFrameInfoProcessed();
|
||||
apple_unfairlock_unlock(this->_unfairlockProcessedInfo);
|
||||
|
||||
return processedInfo;
|
||||
}
|
||||
|
||||
void MacOGLDisplayPresenter::SetProcessedFrameInfo(const OGLProcessedFrameInfo &processedInfo)
|
||||
void MacOGLDisplayPresenter::SetFrameInfoProcessed(const OGLFrameInfoProcessed &processedInfo)
|
||||
{
|
||||
apple_unfairlock_lock(this->_unfairlockProcessedInfo);
|
||||
this->OGLVideoOutput::SetProcessedFrameInfo(processedInfo);
|
||||
this->OGLVideoOutput::SetFrameInfoProcessed(processedInfo);
|
||||
apple_unfairlock_unlock(this->_unfairlockProcessedInfo);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user