mirror of
https://github.com/TASEmulators/desmume
synced 2025-10-05 16:22:49 +02:00
Compare commits
6 Commits
b568e4359c
...
9f009f4856
Author | SHA1 | Date | |
---|---|---|---|
|
9f009f4856 | ||
|
0fb3d46798 | ||
|
1670e3a750 | ||
|
a779eb7a59 | ||
|
107e15d20b | ||
|
df06de4cca |
@@ -107,7 +107,7 @@ Select available 3d emulation:
|
||||
|
||||
0 = 3d disabled
|
||||
1 = internal desmume software rasterizer (default)
|
||||
2 = osmesa or gtkglext opengl (if available, depending on compilation options, see desmume --help)
|
||||
2 = gtkglext opengl (if available, depending on compilation options, see desmume --help)
|
||||
|
||||
[edit] --disable-sound [gtk]
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -39,7 +39,7 @@
|
||||
|
||||
#define OPENGL_FETCH_BUFFER_COUNT 3
|
||||
|
||||
class OGLVideoOutput;
|
||||
class OGLDisplayPresenter;
|
||||
|
||||
enum ShaderSupportTier
|
||||
{
|
||||
@@ -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);
|
||||
};
|
||||
@@ -261,7 +291,7 @@ public:
|
||||
class OGLVideoLayer
|
||||
{
|
||||
protected:
|
||||
OGLVideoOutput *_output;
|
||||
OGLDisplayPresenter *_output;
|
||||
bool _isVisible;
|
||||
bool _needUpdateViewport;
|
||||
bool _needUpdateRotationScale;
|
||||
@@ -303,7 +333,7 @@ protected:
|
||||
void _UpdateVerticesOGL();
|
||||
|
||||
public:
|
||||
OGLHUDLayer(OGLVideoOutput *oglVO);
|
||||
OGLHUDLayer(OGLDisplayPresenter *oglVO);
|
||||
virtual ~OGLHUDLayer();
|
||||
|
||||
void CopyHUDFont(const FT_Face &fontFace, const size_t glyphSize, const size_t glyphTileSize, GlyphInfo *glyphInfo);
|
||||
@@ -326,10 +356,11 @@ 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() {};
|
||||
OGLDisplayLayer(OGLVideoOutput *oglVO);
|
||||
OGLDisplayLayer(OGLDisplayPresenter *oglVO);
|
||||
virtual ~OGLDisplayLayer();
|
||||
|
||||
OutputFilterTypeID SetOutputFilterOGL(const OutputFilterTypeID filterID);
|
||||
@@ -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,14 +459,14 @@ 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);
|
||||
void FetchCustomDisplayByID_OGL(const NDSDisplayInfo *displayInfoList, const NDSDisplayID displayID, const u8 bufferIndex);
|
||||
};
|
||||
|
||||
class OGLVideoOutput : public ClientDisplay3DPresenter
|
||||
class OGLDisplayPresenter : public ClientDisplay3DPresenter
|
||||
{
|
||||
protected:
|
||||
OGLContextInfo *_contextInfo;
|
||||
@@ -413,7 +478,7 @@ protected:
|
||||
GLuint _texCPUFilterDstID[2];
|
||||
GLuint _fboFrameCopyID;
|
||||
|
||||
OGLProcessedFrameInfo _processedFrameInfo;
|
||||
OGLFrameInfoProcessed _processedFrameInfo;
|
||||
|
||||
std::vector<OGLVideoLayer *> *_layerList;
|
||||
|
||||
@@ -430,8 +495,8 @@ protected:
|
||||
virtual void _ResizeCPUPixelScaler(const VideoFilterTypeID filterID);
|
||||
|
||||
public:
|
||||
OGLVideoOutput();
|
||||
~OGLVideoOutput();
|
||||
OGLDisplayPresenter();
|
||||
~OGLDisplayPresenter();
|
||||
|
||||
OGLContextInfo* GetContextInfo();
|
||||
|
||||
@@ -459,12 +524,8 @@ public:
|
||||
virtual void PrerenderStateSetupOGL();
|
||||
virtual void RenderFrameOGL(bool isRenderingFlipped);
|
||||
|
||||
virtual const OGLProcessedFrameInfo& GetProcessedFrameInfo();
|
||||
virtual void SetProcessedFrameInfo(const OGLProcessedFrameInfo &processedInfo);
|
||||
|
||||
virtual void WriteLockEmuFramebuffer(const uint8_t bufferIndex);
|
||||
virtual void ReadLockEmuFramebuffer(const uint8_t bufferIndex);
|
||||
virtual void UnlockEmuFramebuffer(const uint8_t bufferIndex);
|
||||
virtual const OGLFrameInfoProcessed& GetFrameInfoProcessed();
|
||||
virtual void SetFrameInfoProcessed(const OGLFrameInfoProcessed &processedInfo);
|
||||
};
|
||||
|
||||
extern void (*glBindVertexArrayDESMUME)(GLuint id);
|
||||
|
@@ -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);
|
||||
|
@@ -66,7 +66,7 @@ public:
|
||||
virtual void FetchFromBufferIndex(const u8 index);
|
||||
};
|
||||
|
||||
class OE_OGLDisplayPresenter : public OGLVideoOutput
|
||||
class OE_OGLDisplayPresenter : public OGLDisplayPresenter
|
||||
{
|
||||
private:
|
||||
void __InstanceInit(OE_OGLClientFetchObject *fetchObject);
|
||||
|
@@ -170,7 +170,7 @@ void OE_OGLDisplayPresenter::Init()
|
||||
this->_context = CGLGetCurrentContext();
|
||||
}
|
||||
|
||||
this->OGLVideoOutput::Init();
|
||||
this->OGLDisplayPresenter::Init();
|
||||
}
|
||||
|
||||
CGLContextObj OE_OGLDisplayPresenter::GetContext() const
|
||||
|
@@ -31,7 +31,7 @@
|
||||
@class CocoaDSDisplayVideo;
|
||||
@class EmuControllerDelegate;
|
||||
@class InputManager;
|
||||
class OGLVideoOutput;
|
||||
class OGLDisplayPresenter;
|
||||
|
||||
// Subclass NSWindow for full screen windows so that we can override some methods.
|
||||
@interface DisplayFullScreenWindow : NSWindow
|
||||
|
@@ -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);
|
||||
|
||||
@@ -84,7 +80,7 @@ public:
|
||||
virtual void FetchFromBufferIndex(const u8 index);
|
||||
};
|
||||
|
||||
class MacOGLDisplayPresenter : public OGLVideoOutput
|
||||
class MacOGLDisplayPresenter : public OGLDisplayPresenter
|
||||
{
|
||||
private:
|
||||
void __InstanceInit(MacOGLClientFetchObject *fetchObject);
|
||||
@@ -122,12 +118,8 @@ public:
|
||||
virtual void ProcessDisplays();
|
||||
virtual void CopyFrameToBuffer(uint32_t *dstBuffer);
|
||||
|
||||
virtual const OGLProcessedFrameInfo& GetProcessedFrameInfo();
|
||||
virtual void SetProcessedFrameInfo(const OGLProcessedFrameInfo &processedInfo);
|
||||
|
||||
virtual void WriteLockEmuFramebuffer(const uint8_t bufferIndex);
|
||||
virtual void ReadLockEmuFramebuffer(const uint8_t bufferIndex);
|
||||
virtual void UnlockEmuFramebuffer(const uint8_t bufferIndex);
|
||||
virtual const OGLFrameInfoProcessed& GetFrameInfoProcessed();
|
||||
virtual void SetFrameInfoProcessed(const OGLFrameInfoProcessed &processedInfo);
|
||||
};
|
||||
|
||||
class MacOGLDisplayView : public MacDisplayLayeredView
|
||||
|
@@ -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);
|
||||
|
||||
@@ -479,7 +468,7 @@ void MacOGLDisplayPresenter::Init()
|
||||
this->_contextInfo = new OGLContextInfo_Legacy;
|
||||
}
|
||||
|
||||
this->OGLVideoOutput::Init();
|
||||
this->OGLDisplayPresenter::Init();
|
||||
CGLSetCurrentContext(prevContext);
|
||||
}
|
||||
|
||||
@@ -507,7 +496,7 @@ void MacOGLDisplayPresenter::LoadHUDFont()
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::LoadHUDFont();
|
||||
this->OGLDisplayPresenter::LoadHUDFont();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
@@ -515,7 +504,7 @@ void MacOGLDisplayPresenter::SetScaleFactor(const double scaleFactor)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetScaleFactor(scaleFactor);
|
||||
this->OGLDisplayPresenter::SetScaleFactor(scaleFactor);
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
@@ -523,7 +512,7 @@ void MacOGLDisplayPresenter::SetFiltersPreferGPU(const bool preferGPU)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetFiltersPreferGPU(preferGPU);
|
||||
this->OGLDisplayPresenter::SetFiltersPreferGPU(preferGPU);
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
@@ -531,7 +520,7 @@ void MacOGLDisplayPresenter::SetOutputFilter(const OutputFilterTypeID filterID)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetOutputFilter(filterID);
|
||||
this->OGLDisplayPresenter::SetOutputFilter(filterID);
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
@@ -539,7 +528,7 @@ void MacOGLDisplayPresenter::SetPixelScaler(const VideoFilterTypeID filterID)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetPixelScaler(filterID);
|
||||
this->OGLDisplayPresenter::SetPixelScaler(filterID);
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
@@ -548,7 +537,7 @@ void MacOGLDisplayPresenter::LoadDisplays()
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::LoadDisplays();
|
||||
this->OGLDisplayPresenter::LoadDisplays();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
@@ -556,7 +545,7 @@ void MacOGLDisplayPresenter::ProcessDisplays()
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::ProcessDisplays();
|
||||
this->OGLDisplayPresenter::ProcessDisplays();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
@@ -564,44 +553,26 @@ void MacOGLDisplayPresenter::CopyFrameToBuffer(uint32_t *dstBuffer)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::CopyFrameToBuffer(dstBuffer);
|
||||
this->OGLDisplayPresenter::CopyFrameToBuffer(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->OGLDisplayPresenter::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->OGLDisplayPresenter::SetFrameInfoProcessed(processedInfo);
|
||||
apple_unfairlock_unlock(this->_unfairlockProcessedInfo);
|
||||
}
|
||||
|
||||
void MacOGLDisplayPresenter::WriteLockEmuFramebuffer(const uint8_t bufferIndex)
|
||||
{
|
||||
MacOGLClientFetchObject &fetchObj = (MacOGLClientFetchObject &)this->GetFetchObject();
|
||||
semaphore_wait( fetchObj.SemaphoreFramebufferPageAtIndex(bufferIndex) );
|
||||
}
|
||||
|
||||
void MacOGLDisplayPresenter::ReadLockEmuFramebuffer(const uint8_t bufferIndex)
|
||||
{
|
||||
MacOGLClientFetchObject &fetchObj = (MacOGLClientFetchObject &)this->GetFetchObject();
|
||||
semaphore_wait( fetchObj.SemaphoreFramebufferPageAtIndex(bufferIndex) );
|
||||
}
|
||||
|
||||
void MacOGLDisplayPresenter::UnlockEmuFramebuffer(const uint8_t bufferIndex)
|
||||
{
|
||||
MacOGLClientFetchObject &fetchObj = (MacOGLClientFetchObject &)this->GetFetchObject();
|
||||
semaphore_signal( fetchObj.SemaphoreFramebufferPageAtIndex(bufferIndex) );
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
MacOGLDisplayView::MacOGLDisplayView()
|
||||
|
@@ -25,7 +25,6 @@
|
||||
<Add option="`pkg-config --libs gtk+-2.0`" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libGL.so" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libGLESv2.so" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libOSMesa.so" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libEGL.so" />
|
||||
</Linker>
|
||||
</Target>
|
||||
@@ -72,7 +71,6 @@
|
||||
<Add option="`pkg-config --libs gtk+-3.0`" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libGL.so" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libGLESv2.so" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libOSMesa.so" />
|
||||
<Add library="/usr/lib/x86_64-linux-gnu/libEGL.so" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
@@ -2024,20 +2022,6 @@
|
||||
<Option target="<{~None~}>" />
|
||||
</Unit>
|
||||
<Unit filename="../shared/mic_openal.cpp" />
|
||||
<Unit filename="../shared/osmesa_3Demu.cpp">
|
||||
<Option target="GTK2_x64_Debug" />
|
||||
<Option target="GTK2_x64_Release" />
|
||||
<Option target="GTK3_x64_Debug" />
|
||||
<Option target="GTK3_x64_Release" />
|
||||
</Unit>
|
||||
<Unit filename="../shared/osmesa_3Demu.h">
|
||||
<Option target="GTK2_x64_Debug" />
|
||||
<Option target="GTK2_x64_Release" />
|
||||
<Option target="GTK3_x64_Debug" />
|
||||
<Option target="GTK3_x64_Release" />
|
||||
<Option target="GTK3_AArch64_Debug" />
|
||||
<Option target="GTK3_AArch64_Release" />
|
||||
</Unit>
|
||||
<Unit filename="../shared/sdl_3Demu.cpp">
|
||||
<Option target="GTK2_x64_Debug" />
|
||||
<Option target="GTK2_x64_Release" />
|
||||
|
@@ -118,7 +118,7 @@ AM_CONDITIONAL([ENABLE_OPENGL_ES], [test "${have_opengles}" = "yes"])
|
||||
|
||||
dnl - if --enable-glx is used, check for it
|
||||
AC_ARG_ENABLE([glx],
|
||||
[AC_HELP_STRING([--enable-glx], [Use a GLX context, overrides --enable-osmesa and --enable-egl])],
|
||||
[AC_HELP_STRING([--enable-glx], [Use a GLX context, overrides --enable-egl])],
|
||||
[glx=$enableval],
|
||||
[glx=no])
|
||||
|
||||
@@ -143,40 +143,6 @@ if test "$have_glx" = "yes" ; then
|
||||
fi
|
||||
AM_CONDITIONAL([ENABLE_GLX], [test "${have_glx}" = "yes"])
|
||||
|
||||
dnl - if --enable-osmesa is used, check for it
|
||||
AC_ARG_ENABLE([osmesa],
|
||||
[AC_HELP_STRING([--enable-osmesa], [Use an OSMesa context, overrides --enable-egl])],
|
||||
[osmesa=$enableval],
|
||||
[osmesa=no])
|
||||
|
||||
if test "x$osmesa" = "xyes" ; then
|
||||
AC_CHECK_HEADERS([GL/osmesa.h], [have_osmesa=yes], [have_osmesa=no])
|
||||
if test "have_osmesa" = "no" ; then
|
||||
AC_MSG_WARN([Cannot use OSMesa -- headers not found.])
|
||||
else
|
||||
AC_MSG_WARN([OSMesa contexts are deprecated.])
|
||||
AC_CHECK_LIB(dl, main)
|
||||
AC_CHECK_LIB(GL, main)
|
||||
AC_CHECK_LIB(OSMesa, main)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$have_osmesa" = "yes" ; then
|
||||
if test "$have_opengl" = "yes" ; then
|
||||
AC_DEFINE(ENABLE_OSMESA)
|
||||
OSMESA_LIBS="-lOSMesa"
|
||||
AC_SUBST(OSMESA_LIBS)
|
||||
else
|
||||
have_osmesa=no
|
||||
if test "$have_opengles" = "yes" ; then
|
||||
AC_MSG_WARN([OSMesa contexts are incompatible with OpenGL ES -- cancelling the use of OSMesa.])
|
||||
else
|
||||
AC_MSG_WARN([OSMesa contexts are only compatible with standard OpenGL -- cancelling the use of OSMesa.])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
AM_CONDITIONAL([ENABLE_OSMESA], [test "${have_osmesa}" = "yes"])
|
||||
|
||||
dnl - if --enable-egl is used, check for it
|
||||
AC_ARG_ENABLE([egl],
|
||||
[AC_HELP_STRING([--enable-egl], [Use an EGL context])],
|
||||
|
@@ -52,7 +52,7 @@ Select available 3d emulation:
|
||||
1 = internal desmume software rasterizer (default)
|
||||
.RE
|
||||
.RS
|
||||
2 = osmesa or gtkglext opengl (if available, depending on compilation options, see desmume \-\-help)
|
||||
2 = gtkglext opengl (if available, depending on compilation options, see desmume \-\-help)
|
||||
.RE
|
||||
.TP
|
||||
.B \-\-disable-sound
|
||||
|
@@ -81,8 +81,6 @@
|
||||
|
||||
#if defined(ENABLE_GLX)
|
||||
#include "../shared/glx_3Demu.h"
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
#include "../shared/osmesa_3Demu.h"
|
||||
#elif defined(ENABLE_EGL)
|
||||
#include "../shared/egl_3Demu.h"
|
||||
#else
|
||||
@@ -2325,7 +2323,7 @@ static void GraphicsSettingsDialog(GSimpleAction *action, GVariant *parameter, g
|
||||
{
|
||||
switch (sel3DCore)
|
||||
{
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_OSMESA) && !defined(ENABLE_GLX)
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_GLX)
|
||||
case 2:
|
||||
#if defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_ES_3_0;
|
||||
@@ -2337,8 +2335,6 @@ static void GraphicsSettingsDialog(GSimpleAction *action, GVariant *parameter, g
|
||||
case 2:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_StandardAuto;
|
||||
#else
|
||||
@@ -2349,8 +2345,6 @@ static void GraphicsSettingsDialog(GSimpleAction *action, GVariant *parameter, g
|
||||
case 3:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_LegacyAuto;
|
||||
#else
|
||||
@@ -2361,8 +2355,6 @@ static void GraphicsSettingsDialog(GSimpleAction *action, GVariant *parameter, g
|
||||
case 4:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_3_2_CoreProfile;
|
||||
#else
|
||||
@@ -3951,12 +3943,6 @@ common_gtk_main(GApplication *app, gpointer user_data)
|
||||
oglrender_beginOpenGL = &glx_beginOpenGL;
|
||||
oglrender_endOpenGL = &glx_endOpenGL;
|
||||
oglrender_framebufferDidResizeCallback = &glx_framebufferDidResizeCallback;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_StandardAuto;
|
||||
oglrender_deinit = &osmesa_deinitOpenGL;
|
||||
oglrender_beginOpenGL = &osmesa_beginOpenGL;
|
||||
oglrender_endOpenGL = &osmesa_endOpenGL;
|
||||
oglrender_framebufferDidResizeCallback = &osmesa_framebufferDidResizeCallback;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_StandardAuto;
|
||||
oglrender_deinit = &egl_deinitOpenGL;
|
||||
@@ -3998,7 +3984,7 @@ common_gtk_main(GApplication *app, gpointer user_data)
|
||||
|
||||
switch (core)
|
||||
{
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_OSMESA) && !defined(ENABLE_GLX)
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_GLX)
|
||||
case 2:
|
||||
#if defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_ES_3_0;
|
||||
@@ -4010,8 +3996,6 @@ common_gtk_main(GApplication *app, gpointer user_data)
|
||||
case 2:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_StandardAuto;
|
||||
#else
|
||||
@@ -4022,8 +4006,6 @@ common_gtk_main(GApplication *app, gpointer user_data)
|
||||
case 3:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_LegacyAuto;
|
||||
#else
|
||||
@@ -4034,8 +4016,6 @@ common_gtk_main(GApplication *app, gpointer user_data)
|
||||
case 4:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_3_2_CoreProfile;
|
||||
#else
|
||||
@@ -4130,8 +4110,6 @@ static void Teardown() {
|
||||
#if defined(ENABLE_OPENGL_STANDARD) || defined(ENABLE_OPENGL_ES)
|
||||
#if defined(ENABLE_GLX)
|
||||
glx_deinitOpenGL();
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
osmesa_deinitOpenGL();
|
||||
#elif defined(ENABLE_EGL)
|
||||
egl_deinitOpenGL();
|
||||
#else
|
||||
|
@@ -29,10 +29,6 @@ if get_option('glx') and dep_gl.found()
|
||||
desmume_src += [
|
||||
'../shared/glx_3Demu.cpp',
|
||||
]
|
||||
elif get_option('osmesa') and dep_osmesa.found()
|
||||
desmume_src += [
|
||||
'../shared/osmesa_3Demu.cpp',
|
||||
]
|
||||
elif get_option('egl') and dep_egl.found()
|
||||
desmume_src += [
|
||||
'../shared/egl_3Demu.cpp',
|
||||
|
@@ -39,10 +39,6 @@ endif
|
||||
if ENABLE_GLX
|
||||
desmume_SOURCES += ../shared/glx_3Demu.h ../shared/glx_3Demu.cpp
|
||||
else
|
||||
if ENABLE_OSMESA
|
||||
desmume_LDADD += $(OSMESA_LIBS)
|
||||
desmume_SOURCES += ../shared/osmesa_3Demu.h ../shared/osmesa_3Demu.cpp
|
||||
else
|
||||
if ENABLE_EGL
|
||||
desmume_LDADD += $(EGL_LIBS)
|
||||
desmume_SOURCES += ../shared/egl_3Demu.h ../shared/egl_3Demu.cpp
|
||||
@@ -50,7 +46,6 @@ else
|
||||
desmume_SOURCES += ../shared/sdl_3Demu.h ../shared/sdl_3Demu.cpp
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
UPDATE_DESKTOP = \
|
||||
appsdir=$(DESTDIR)$(datadir)/applications ; \
|
||||
|
@@ -52,7 +52,7 @@ Select available 3d emulation:
|
||||
1 = internal desmume software rasterizer (default)
|
||||
.RE
|
||||
.RS
|
||||
2 = osmesa or gtkglext opengl (if available, depending on compilation options, see desmume \-\-help)
|
||||
2 = gtkglext opengl (if available, depending on compilation options, see desmume \-\-help)
|
||||
.RE
|
||||
.TP
|
||||
.B \-\-disable-sound
|
||||
|
@@ -77,8 +77,6 @@
|
||||
|
||||
#if defined(ENABLE_GLX)
|
||||
#include "../shared/glx_3Demu.h"
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
#include "../shared/osmesa_3Demu.h"
|
||||
#elif defined(ENABLE_EGL)
|
||||
#include "../shared/egl_3Demu.h"
|
||||
#else
|
||||
@@ -2613,7 +2611,7 @@ static void GraphicsSettingsDialog() {
|
||||
{
|
||||
switch (sel3DCore)
|
||||
{
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_OSMESA) && !defined(ENABLE_GLX)
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_GLX)
|
||||
case 2:
|
||||
#if defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_ES_3_0;
|
||||
@@ -2625,8 +2623,6 @@ static void GraphicsSettingsDialog() {
|
||||
case 2:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_StandardAuto;
|
||||
#else
|
||||
@@ -2637,8 +2633,6 @@ static void GraphicsSettingsDialog() {
|
||||
case 3:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_LegacyAuto;
|
||||
#else
|
||||
@@ -2649,8 +2643,6 @@ static void GraphicsSettingsDialog() {
|
||||
case 4:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_3_2_CoreProfile;
|
||||
#else
|
||||
@@ -3828,12 +3820,6 @@ common_gtk_main( class configured_features *my_config)
|
||||
oglrender_beginOpenGL = &glx_beginOpenGL;
|
||||
oglrender_endOpenGL = &glx_endOpenGL;
|
||||
oglrender_framebufferDidResizeCallback = &glx_framebufferDidResizeCallback;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_StandardAuto;
|
||||
oglrender_deinit = &osmesa_deinitOpenGL;
|
||||
oglrender_beginOpenGL = &osmesa_beginOpenGL;
|
||||
oglrender_endOpenGL = &osmesa_endOpenGL;
|
||||
oglrender_framebufferDidResizeCallback = &osmesa_framebufferDidResizeCallback;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_StandardAuto;
|
||||
oglrender_deinit = &egl_deinitOpenGL;
|
||||
@@ -3875,7 +3861,7 @@ common_gtk_main( class configured_features *my_config)
|
||||
|
||||
switch (core)
|
||||
{
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_OSMESA) && !defined(ENABLE_GLX)
|
||||
#if defined(ENABLE_OPENGL_ES) && !defined(ENABLE_GLX)
|
||||
case 2:
|
||||
#if defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_ES_3_0;
|
||||
@@ -3887,8 +3873,6 @@ common_gtk_main( class configured_features *my_config)
|
||||
case 2:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_StandardAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_StandardAuto;
|
||||
#else
|
||||
@@ -3899,8 +3883,6 @@ common_gtk_main( class configured_features *my_config)
|
||||
case 3:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_LegacyAuto;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_LegacyAuto;
|
||||
#else
|
||||
@@ -3911,8 +3893,6 @@ common_gtk_main( class configured_features *my_config)
|
||||
case 4:
|
||||
#if defined(ENABLE_GLX)
|
||||
oglrender_init = &glx_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
oglrender_init = &osmesa_initOpenGL_3_2_CoreProfile;
|
||||
#elif defined(ENABLE_EGL)
|
||||
oglrender_init = &egl_initOpenGL_3_2_CoreProfile;
|
||||
#else
|
||||
@@ -4005,8 +3985,6 @@ common_gtk_main( class configured_features *my_config)
|
||||
#if defined(ENABLE_OPENGL_STANDARD) || defined(ENABLE_OPENGL_ES)
|
||||
#if defined(ENABLE_GLX)
|
||||
glx_deinitOpenGL();
|
||||
#elif defined(ENABLE_OSMESA)
|
||||
osmesa_deinitOpenGL();
|
||||
#elif defined(ENABLE_EGL)
|
||||
egl_deinitOpenGL();
|
||||
#else
|
||||
|
@@ -22,10 +22,6 @@ if get_option('glx') and dep_gl.found()
|
||||
desmume_src += [
|
||||
'../shared/glx_3Demu.cpp',
|
||||
]
|
||||
elif get_option('osmesa') and dep_osmesa.found()
|
||||
desmume_src += [
|
||||
'../shared/osmesa_3Demu.cpp',
|
||||
]
|
||||
elif get_option('egl') and dep_egl.found()
|
||||
desmume_src += [
|
||||
'../shared/egl_3Demu.cpp',
|
||||
|
@@ -22,7 +22,6 @@ dep_alsa = dependency('alsa', required: false)
|
||||
dep_soundtouch = dependency('soundtouch', required: false)
|
||||
dep_agg = dependency('libagg', required: false)
|
||||
dep_fontconfig = dependency('fontconfig', required: false)
|
||||
dep_osmesa = dependency('osmesa', required: false)
|
||||
dep_egl = dependency('egl', required: false)
|
||||
|
||||
# XXX: something wrong with this one.
|
||||
@@ -248,20 +247,6 @@ if get_option('glx')
|
||||
else
|
||||
message('Cannot use GLX -- gl library not found.')
|
||||
endif
|
||||
elif get_option('osmesa')
|
||||
if dep_osmesa.found()
|
||||
if get_option('opengl') and dep_gl.found()
|
||||
message('OSMesa contexts are deprecated.')
|
||||
add_global_arguments('-DENABLE_OSMESA', language: ['c', 'cpp'])
|
||||
dependencies += dep_osmesa
|
||||
elif get_option('opengles')
|
||||
message('OSMesa contexts are incompatible with OpenGL ES -- cancelling the use of OSMesa.')
|
||||
else
|
||||
message('OSMesa contexts are only compatible with standard OpenGL -- cancelling the use of OSMesa.')
|
||||
endif
|
||||
else
|
||||
message('Cannot use OSMesa -- osmesa library not found.')
|
||||
endif
|
||||
elif get_option('egl')
|
||||
if dep_egl.found()
|
||||
add_global_arguments('-DENABLE_EGL', language: ['c', 'cpp'])
|
||||
|
@@ -13,11 +13,6 @@ option('glx',
|
||||
value: false,
|
||||
description: 'Use a GLX context',
|
||||
)
|
||||
option('osmesa',
|
||||
type: 'boolean',
|
||||
value: false,
|
||||
description: 'Use a OSMesa context',
|
||||
)
|
||||
option('egl',
|
||||
type: 'boolean',
|
||||
value: false,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2024 DeSmuME team
|
||||
Copyright (C) 2024-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
|
||||
@@ -45,21 +45,73 @@ static bool __egl_initOpenGL(const int requestedAPI, const int requestedProfile,
|
||||
|
||||
EGLint eglMajorVersion;
|
||||
EGLint eglMinorVersion;
|
||||
|
||||
EGLBoolean didDisplayInitialize = EGL_FALSE;
|
||||
EGLAttrib displayAttr[] = {EGL_NONE};
|
||||
|
||||
// Try to initialize EGL on a Wayland display first, which should be available on most
|
||||
// modern platforms.
|
||||
currDisplay = eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, EGL_DEFAULT_DISPLAY, displayAttr);
|
||||
if(currDisplay == EGL_NO_DISPLAY)
|
||||
currDisplay = eglGetPlatformDisplay(EGL_PLATFORM_XCB_EXT, EGL_DEFAULT_DISPLAY, displayAttr);
|
||||
if(currDisplay == EGL_NO_DISPLAY)
|
||||
currDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if(currDisplay == EGL_NO_DISPLAY)
|
||||
if (currDisplay != EGL_NO_DISPLAY)
|
||||
{
|
||||
puts("EGL: failed to obtain display handle");
|
||||
didDisplayInitialize = eglInitialize(currDisplay, &eglMajorVersion, &eglMinorVersion);
|
||||
if (didDisplayInitialize == GL_TRUE)
|
||||
{
|
||||
puts("EGL: Successfully initialized with Wayland.");
|
||||
}
|
||||
}
|
||||
|
||||
// Try to initialize EGL for XCB next, which should be available for modern X11 platforms.
|
||||
if (didDisplayInitialize == GL_FALSE)
|
||||
{
|
||||
currDisplay = eglGetPlatformDisplay(EGL_PLATFORM_XCB_EXT, EGL_DEFAULT_DISPLAY, displayAttr);
|
||||
if (currDisplay != EGL_NO_DISPLAY)
|
||||
{
|
||||
didDisplayInitialize = eglInitialize(currDisplay, &eglMajorVersion, &eglMinorVersion);
|
||||
if (didDisplayInitialize == GL_TRUE)
|
||||
{
|
||||
puts("EGL: Successfully initialized with XCB.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If for some reason XCB didn't work, try to initialize EGL on whatever X11 is available.
|
||||
if (didDisplayInitialize == GL_FALSE)
|
||||
{
|
||||
currDisplay = eglGetPlatformDisplay(EGL_PLATFORM_X11_EXT, EGL_DEFAULT_DISPLAY, displayAttr);
|
||||
if (currDisplay != EGL_NO_DISPLAY)
|
||||
{
|
||||
didDisplayInitialize = eglInitialize(currDisplay, &eglMajorVersion, &eglMinorVersion);
|
||||
if (didDisplayInitialize == GL_TRUE)
|
||||
{
|
||||
puts("EGL: Successfully initialized with generic X11.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For ancient platforms that don't support eglGetPlatformDisplay(), an EGL v1.5 function,
|
||||
// try calling the generic eglGetDisplay() function as a last resort since it is compatible
|
||||
// with older versions of EGL.
|
||||
if (didDisplayInitialize == GL_FALSE)
|
||||
{
|
||||
currDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if (currDisplay != EGL_NO_DISPLAY)
|
||||
{
|
||||
didDisplayInitialize = eglInitialize(currDisplay, &eglMajorVersion, &eglMinorVersion);
|
||||
if (didDisplayInitialize == GL_TRUE)
|
||||
{
|
||||
puts("EGL: Successfully initialized with a generic display.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currDisplay == EGL_NO_DISPLAY)
|
||||
{
|
||||
puts("EGL: Could not acquire a display handle to initialize EGL.");
|
||||
return false;
|
||||
}
|
||||
if (eglInitialize(currDisplay, &eglMajorVersion, &eglMinorVersion) == EGL_FALSE)
|
||||
else if (didDisplayInitialize == GL_FALSE)
|
||||
{
|
||||
puts("EGL: eglInitialize failed");
|
||||
puts("EGL: Could not initialize EGL with the acquired display handle.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -1,284 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009 Guillaume Duhamel
|
||||
Copyright (C) 2009-2024 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
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <GL/osmesa.h>
|
||||
|
||||
#include "osmesa_3Demu.h"
|
||||
#include "OGLRender_3_2.h"
|
||||
|
||||
#warning OSMesa contexts are deprecated.
|
||||
|
||||
|
||||
static OSMesaContext currContext = NULL;
|
||||
static GLint currCtxFormat = GL_UNSIGNED_BYTE;
|
||||
static GLint currCtxWidth = 0;
|
||||
static GLint currCtxHeight = 0;
|
||||
static void *currCtxBuffer = NULL;
|
||||
|
||||
static OSMesaContext prevContext = NULL;
|
||||
static GLint prevCtxFormat = GL_UNSIGNED_BYTE;
|
||||
static GLint prevCtxWidth = 0;
|
||||
static GLint prevCtxHeight = 0;
|
||||
static void *prevCtxBuffer = NULL;
|
||||
|
||||
static void *pendingCtxBuffer = NULL;
|
||||
static GLint pendingCtxWidth = 0;
|
||||
static GLint pendingCtxHeight = 0;
|
||||
|
||||
static bool __osmesa_initOpenGL(const int requestedProfile, const int requestedVersionMajor, const int requestedVersionMinor)
|
||||
{
|
||||
GLboolean ret = GL_FALSE;
|
||||
|
||||
if (currContext != NULL)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#if (((OSMESA_MAJOR_VERSION * 100) + OSMESA_MINOR_VERSION) >= 1102) && defined(OSMESA_CONTEXT_MAJOR_VERSION)
|
||||
const int ctxAttributes[] = {
|
||||
OSMESA_FORMAT, OSMESA_RGBA,
|
||||
OSMESA_DEPTH_BITS, ( (requestedProfile == OSMESA_CORE_PROFILE) && ((requestedVersionMajor >= 4) || ((requestedVersionMajor == 3) && (requestedVersionMinor >= 2))) ) ? 0 : 24,
|
||||
OSMESA_STENCIL_BITS, ( (requestedProfile == OSMESA_CORE_PROFILE) && ((requestedVersionMajor >= 4) || ((requestedVersionMajor == 3) && (requestedVersionMinor >= 2))) ) ? 0 : 8,
|
||||
OSMESA_ACCUM_BITS, 0,
|
||||
OSMESA_PROFILE, requestedProfile,
|
||||
OSMESA_CONTEXT_MAJOR_VERSION, requestedVersionMajor,
|
||||
OSMESA_CONTEXT_MINOR_VERSION, requestedVersionMinor,
|
||||
0
|
||||
};
|
||||
|
||||
currContext = OSMesaCreateContextAttribs(ctxAttributes, NULL);
|
||||
if (currContext == NULL)
|
||||
{
|
||||
if (requestedProfile == OSMESA_CORE_PROFILE)
|
||||
{
|
||||
puts("OSMesa: OSMesaCreateContextAttribs() failed!");
|
||||
return false;
|
||||
}
|
||||
else if (requestedProfile == OSMESA_COMPAT_PROFILE)
|
||||
{
|
||||
puts("OSMesa: Could not create a context using OSMesaCreateContextAttribs(). Will attempt to use OSMesaCreateContextExt() instead...");
|
||||
}
|
||||
}
|
||||
|
||||
if ( (currContext == NULL) && (requestedProfile == OSMESA_COMPAT_PROFILE) )
|
||||
#endif
|
||||
{
|
||||
currContext = OSMesaCreateContextExt(OSMESA_RGBA, 24, 8, 0, NULL);
|
||||
if (currContext == NULL)
|
||||
{
|
||||
puts("OSMesa: OSMesaCreateContextExt() failed!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
currCtxFormat = GL_UNSIGNED_BYTE;
|
||||
currCtxWidth = GPU_FRAMEBUFFER_NATIVE_WIDTH;
|
||||
currCtxHeight = GPU_FRAMEBUFFER_NATIVE_HEIGHT;
|
||||
|
||||
currCtxBuffer = malloc_alignedPage(currCtxWidth * currCtxHeight * sizeof(uint32_t));
|
||||
if (currCtxBuffer == NULL)
|
||||
{
|
||||
OSMesaDestroyContext(currContext);
|
||||
currCtxFormat = GL_UNSIGNED_BYTE;
|
||||
currCtxWidth = 0;
|
||||
currCtxHeight = 0;
|
||||
|
||||
puts("OSMesa: Could not allocate enough memory for the context!");
|
||||
return false;
|
||||
}
|
||||
|
||||
puts("OSMesa: Context creation successful.");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool osmesa_initOpenGL_StandardAuto()
|
||||
{
|
||||
bool isContextCreated = __osmesa_initOpenGL(OSMESA_CORE_PROFILE, 4, 1);
|
||||
|
||||
if (!isContextCreated)
|
||||
{
|
||||
isContextCreated = osmesa_initOpenGL_3_2_CoreProfile();
|
||||
}
|
||||
|
||||
if (!isContextCreated)
|
||||
{
|
||||
isContextCreated = osmesa_initOpenGL_LegacyAuto();
|
||||
}
|
||||
|
||||
return isContextCreated;
|
||||
}
|
||||
|
||||
bool osmesa_initOpenGL_LegacyAuto()
|
||||
{
|
||||
return __osmesa_initOpenGL(OSMESA_COMPAT_PROFILE, 1, 2);
|
||||
}
|
||||
|
||||
bool osmesa_initOpenGL_3_2_CoreProfile()
|
||||
{
|
||||
return __osmesa_initOpenGL(OSMESA_CORE_PROFILE, 3, 2);
|
||||
}
|
||||
|
||||
void osmesa_deinitOpenGL()
|
||||
{
|
||||
OSMesaMakeCurrent(NULL, NULL, GL_UNSIGNED_BYTE, 0, 0);
|
||||
|
||||
if (currContext != NULL)
|
||||
{
|
||||
OSMesaDestroyContext(currContext);
|
||||
currContext = NULL;
|
||||
currCtxFormat = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
|
||||
if (currCtxBuffer != NULL)
|
||||
{
|
||||
free_aligned(currCtxBuffer);
|
||||
currCtxBuffer = NULL;
|
||||
currCtxWidth = 0;
|
||||
currCtxHeight = 0;
|
||||
}
|
||||
|
||||
if (pendingCtxBuffer != NULL)
|
||||
{
|
||||
free_aligned(pendingCtxBuffer);
|
||||
pendingCtxBuffer = NULL;
|
||||
pendingCtxWidth = 0;
|
||||
pendingCtxHeight = 0;
|
||||
}
|
||||
|
||||
prevContext = NULL;
|
||||
prevCtxFormat = GL_UNSIGNED_BYTE;
|
||||
prevCtxWidth = 0;
|
||||
prevCtxHeight = 0;
|
||||
prevCtxBuffer = NULL;
|
||||
}
|
||||
|
||||
bool osmesa_beginOpenGL()
|
||||
{
|
||||
GLboolean ret = GL_FALSE;
|
||||
OSMesaContext oldContext = OSMesaGetCurrentContext();
|
||||
|
||||
if (oldContext != NULL)
|
||||
{
|
||||
prevContext = oldContext;
|
||||
OSMesaGetColorBuffer(prevContext, &prevCtxWidth, &prevCtxHeight, &prevCtxFormat, &prevCtxBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
prevContext = currContext;
|
||||
prevCtxFormat = currCtxFormat;
|
||||
prevCtxWidth = currCtxWidth;
|
||||
prevCtxHeight = currCtxHeight;
|
||||
prevCtxBuffer = currCtxBuffer;
|
||||
}
|
||||
|
||||
if (pendingCtxBuffer != NULL)
|
||||
{
|
||||
bool previousIsCurrent = (prevCtxBuffer == currCtxBuffer);
|
||||
|
||||
ret = OSMesaMakeCurrent(currContext, pendingCtxBuffer, currCtxFormat, pendingCtxWidth, pendingCtxHeight);;
|
||||
if (ret == GL_TRUE)
|
||||
{
|
||||
free_aligned(currCtxBuffer);
|
||||
currCtxBuffer = pendingCtxBuffer;
|
||||
|
||||
if (previousIsCurrent)
|
||||
{
|
||||
prevCtxBuffer = pendingCtxBuffer;
|
||||
prevCtxWidth = pendingCtxWidth;
|
||||
prevCtxHeight = pendingCtxHeight;
|
||||
}
|
||||
|
||||
pendingCtxBuffer = NULL;
|
||||
pendingCtxWidth = 0;
|
||||
pendingCtxHeight = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = OSMesaMakeCurrent(currContext, currCtxBuffer, currCtxFormat, currCtxWidth, currCtxHeight);
|
||||
}
|
||||
|
||||
return (ret == GL_TRUE);
|
||||
}
|
||||
|
||||
void osmesa_endOpenGL()
|
||||
{
|
||||
if (prevContext == NULL)
|
||||
{
|
||||
prevContext = currContext;
|
||||
}
|
||||
|
||||
if (prevCtxBuffer == NULL)
|
||||
{
|
||||
prevCtxBuffer = currCtxBuffer;
|
||||
}
|
||||
|
||||
if (prevCtxWidth == 0)
|
||||
{
|
||||
prevCtxWidth = currCtxWidth;
|
||||
}
|
||||
|
||||
if (prevCtxHeight == 0)
|
||||
{
|
||||
prevCtxHeight = currCtxHeight;
|
||||
}
|
||||
|
||||
if (prevCtxFormat == GL_UNSIGNED_BYTE)
|
||||
{
|
||||
prevCtxFormat = currCtxFormat;
|
||||
}
|
||||
|
||||
if ( (prevContext != currContext) ||
|
||||
(prevCtxBuffer != currCtxBuffer) ||
|
||||
(prevCtxFormat != currCtxFormat) ||
|
||||
(prevCtxWidth != currCtxWidth) ||
|
||||
(prevCtxHeight != currCtxHeight) )
|
||||
{
|
||||
OSMesaMakeCurrent(prevContext, prevCtxBuffer, prevCtxFormat, prevCtxWidth, prevCtxHeight);
|
||||
}
|
||||
}
|
||||
|
||||
bool osmesa_framebufferDidResizeCallback(bool isFBOSupported, size_t w, size_t h)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (isFBOSupported)
|
||||
{
|
||||
result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
if ( (w == (size_t)currCtxWidth) && (h == (size_t)currCtxHeight) )
|
||||
{
|
||||
result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
if (pendingCtxBuffer != NULL)
|
||||
{
|
||||
free_aligned(pendingCtxBuffer);
|
||||
}
|
||||
|
||||
pendingCtxWidth = (GLint)w;
|
||||
pendingCtxHeight = (GLint)h;
|
||||
pendingCtxBuffer = malloc_alignedPage(w * h * sizeof(uint32_t));
|
||||
|
||||
result = true;
|
||||
return result;
|
||||
}
|
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009 Guillaume Duhamel
|
||||
Copyright (C) 2009-2024 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
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OSMESA_3DEMU_H
|
||||
#define OSMESA_3DEMU_H
|
||||
|
||||
bool osmesa_initOpenGL_StandardAuto();
|
||||
bool osmesa_initOpenGL_LegacyAuto();
|
||||
bool osmesa_initOpenGL_3_2_CoreProfile();
|
||||
|
||||
void osmesa_deinitOpenGL();
|
||||
bool osmesa_beginOpenGL();
|
||||
void osmesa_endOpenGL();
|
||||
bool osmesa_framebufferDidResizeCallback(bool isFBOSupported, size_t w, size_t h);
|
||||
|
||||
#endif // OSMESA_3DEMU_H
|
||||
|
@@ -609,8 +609,8 @@ struct CPoly
|
||||
typedef struct CPoly CPoly;
|
||||
|
||||
// Used to communicate state to the renderer.
|
||||
// This struct should be at least 16-bit aligned for GLSL.
|
||||
// Tables within the struct should be at least 32-bit aligned for SIMD.
|
||||
// This struct should be at least 16-byte aligned for GLSL.
|
||||
// Tables within the struct should be at least 32-byte aligned for SIMD.
|
||||
struct GFX3D_State
|
||||
{
|
||||
// First 16-byte chunk
|
||||
|
Reference in New Issue
Block a user