Cocoa Port:
- Refactor the OpenGL blitter to work with 3.2 Core Profile contexts. - Simplify some of the init code.
This commit is contained in:
parent
baeb5313d2
commit
453baff89c
|
@ -741,6 +741,9 @@
|
|||
ABAD3E7913AF1D6D00502E1E /* sse_optimized.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABAD3E6D13AF1D6D00502E1E /* sse_optimized.cpp */; };
|
||||
ABAD3E7A13AF1D6D00502E1E /* TDStretch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABAD3E6E13AF1D6D00502E1E /* TDStretch.cpp */; };
|
||||
ABAD3E7B13AF1D6D00502E1E /* WavFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABAD3E6F13AF1D6D00502E1E /* WavFile.cpp */; };
|
||||
ABB24F6D1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABB24F6B1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp */; };
|
||||
ABB24F6E1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABB24F6B1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp */; };
|
||||
ABB24F6F1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABB24F6B1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp */; };
|
||||
ABB3C6621501BF4E00E0C22E /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = AB00E87914205EAE00DE561F /* InfoPlist.strings */; };
|
||||
ABB3C6631501BF4E00E0C22E /* FileTypeInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = AB64987B13ECC73800EE7DD2 /* FileTypeInfo.plist */; };
|
||||
ABB3C6641501BF8A00E0C22E /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29B97324FDCFA39411CA2CEA /* AppKit.framework */; };
|
||||
|
@ -1217,6 +1220,8 @@
|
|||
ABAD3E6D13AF1D6D00502E1E /* sse_optimized.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sse_optimized.cpp; sourceTree = "<group>"; };
|
||||
ABAD3E6E13AF1D6D00502E1E /* TDStretch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TDStretch.cpp; sourceTree = "<group>"; };
|
||||
ABAD3E6F13AF1D6D00502E1E /* WavFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WavFile.cpp; sourceTree = "<group>"; };
|
||||
ABB24F6B1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OGLDisplayOutput_3_2.cpp; sourceTree = "<group>"; };
|
||||
ABB24F6C1A81EE92006C1108 /* OGLDisplayOutput_3_2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OGLDisplayOutput_3_2.h; sourceTree = "<group>"; };
|
||||
ABB3C63B1501BB8300E0C22E /* DeSmuME_Prefix_OpenEmu.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DeSmuME_Prefix_OpenEmu.pch; sourceTree = "<group>"; };
|
||||
ABB3C63C1501BB8300E0C22E /* Info (OpenEmu Plug-in).plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info (OpenEmu Plug-in).plist"; sourceTree = "<group>"; };
|
||||
ABB3C63D1501BB8300E0C22E /* NDSGameCore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NDSGameCore.h; sourceTree = "<group>"; };
|
||||
|
@ -1540,6 +1545,7 @@
|
|||
AB23567216C2F6F400DA782E /* macosx_10_5_compat.cpp */,
|
||||
ABD10AE61715FCDD00B5729D /* mic_ext.cpp */,
|
||||
ABE6840B189E33BC007FD69C /* OGLDisplayOutput.cpp */,
|
||||
ABB24F6B1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp */,
|
||||
AB1B9E601501A78000464647 /* ringbuffer.cpp */,
|
||||
ABD104141346652500AF11D1 /* sndOSX.cpp */,
|
||||
ABD10AE31715FCDD00B5729D /* audiosamplegenerator.h */,
|
||||
|
@ -1559,6 +1565,7 @@
|
|||
ABD10AE41715FCDD00B5729D /* mic_ext.h */,
|
||||
AB1B9E621501A78000464647 /* ringbuffer.h */,
|
||||
ABE6840E189E33D5007FD69C /* OGLDisplayOutput.h */,
|
||||
ABB24F6C1A81EE92006C1108 /* OGLDisplayOutput_3_2.h */,
|
||||
ABD104011346652500AF11D1 /* sndOSX.h */,
|
||||
AB82445E1704AEC400B8EE20 /* utilities.h */,
|
||||
ABA6574A14511EC90077E5E9 /* cocoa_cheat.mm */,
|
||||
|
@ -2778,6 +2785,7 @@
|
|||
ABD1FF591345ACBF00AF11D1 /* emufat.cpp in Sources */,
|
||||
ABD1FEDE1345AC8400AF11D1 /* emufile.cpp in Sources */,
|
||||
ABD1FF5E1345ACBF00AF11D1 /* fatdir.cpp in Sources */,
|
||||
ABB24F6E1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp in Sources */,
|
||||
ABD1FF5F1345ACBF00AF11D1 /* fatfile.cpp in Sources */,
|
||||
ABD1FEDF1345AC8400AF11D1 /* FIFO.cpp in Sources */,
|
||||
ABAD3E7413AF1D6D00502E1E /* FIFOSampleBuffer.cpp in Sources */,
|
||||
|
@ -2980,6 +2988,7 @@
|
|||
AB796D1815CDCBA200C59155 /* md5.cpp in Sources */,
|
||||
AB796D1915CDCBA200C59155 /* metaspu.cpp in Sources */,
|
||||
AB796D1A15CDCBA200C59155 /* MMU.cpp in Sources */,
|
||||
ABB24F6D1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp in Sources */,
|
||||
AB796D1B15CDCBA200C59155 /* mmx_optimized.cpp in Sources */,
|
||||
AB796D1C15CDCBA200C59155 /* movie.cpp in Sources */,
|
||||
AB9038B817C5ED2200F410BD /* slot1comp_rom.cpp in Sources */,
|
||||
|
@ -3228,6 +3237,7 @@
|
|||
AB8F3CEB1A53AC2600A80BF6 /* advanscene.cpp in Sources */,
|
||||
AB8F3CEC1A53AC2600A80BF6 /* lq2x.cpp in Sources */,
|
||||
AB8F3CED1A53AC2600A80BF6 /* xbrz.cpp in Sources */,
|
||||
ABB24F6F1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp in Sources */,
|
||||
AB8F3CEE1A53AC2600A80BF6 /* scanline.cpp in Sources */,
|
||||
AB8F3CEF1A53AC2600A80BF6 /* coreaudiosound.cpp in Sources */,
|
||||
AB8F3CF01A53AC2600A80BF6 /* ringbuffer.cpp in Sources */,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -18,11 +18,15 @@
|
|||
#ifndef _OGLDISPLAYOUTPUT_H_
|
||||
#define _OGLDISPLAYOUTPUT_H_
|
||||
|
||||
#ifndef _OGLDISPLAYOUTPUT_3_2_H_
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glext.h>
|
||||
#endif
|
||||
|
||||
#endif // _OGLDISPLAYOUTPUT_3_2_H_
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include "../filter/videofilter.h"
|
||||
|
@ -53,24 +57,22 @@ enum ShaderSupportTier
|
|||
class OGLInfo
|
||||
{
|
||||
protected:
|
||||
unsigned int _versionMajor;
|
||||
unsigned int _versionMinor;
|
||||
unsigned int _versionRevision;
|
||||
GLint _versionMajor;
|
||||
GLint _versionMinor;
|
||||
GLint _versionRevision;
|
||||
ShaderSupportTier _shaderSupport;
|
||||
bool _useShader150;
|
||||
|
||||
bool _isVBOSupported;
|
||||
bool _isPBOSupported;
|
||||
bool _isShaderSupported;
|
||||
bool _isFBOSupported;
|
||||
|
||||
ShaderSupportTier DetermineShaderSupport();
|
||||
|
||||
public:
|
||||
OGLInfo();
|
||||
virtual ~OGLInfo() {};
|
||||
|
||||
static OGLInfo* GetVersionedObjectOGL();
|
||||
|
||||
bool IsUsingShader150();
|
||||
bool IsVBOSupported();
|
||||
bool IsPBOSupported();
|
||||
bool IsShaderSupported();
|
||||
|
@ -81,35 +83,15 @@ public:
|
|||
virtual bool IsExtensionPresent(const std::set<std::string> &oglExtensionSet, const std::string &extensionName) const = 0;
|
||||
};
|
||||
|
||||
class OGLInfo_1_2 : public OGLInfo
|
||||
class OGLInfo_Legacy : public OGLInfo
|
||||
{
|
||||
public:
|
||||
OGLInfo_1_2();
|
||||
OGLInfo_Legacy();
|
||||
|
||||
virtual void GetExtensionSetOGL(std::set<std::string> *oglExtensionSet);
|
||||
virtual bool IsExtensionPresent(const std::set<std::string> &oglExtensionSet, const std::string &extensionName) const;
|
||||
};
|
||||
|
||||
class OGLInfo_2_0 : public OGLInfo_1_2
|
||||
{
|
||||
public:
|
||||
OGLInfo_2_0();
|
||||
};
|
||||
|
||||
class OGLInfo_2_1 : public OGLInfo_2_0
|
||||
{
|
||||
public:
|
||||
OGLInfo_2_1();
|
||||
};
|
||||
|
||||
class OGLInfo_3_2 : public OGLInfo_2_1
|
||||
{
|
||||
public:
|
||||
OGLInfo_3_2();
|
||||
|
||||
virtual void GetExtensionSetOGL(std::set<std::string> *oglExtensionSet);
|
||||
};
|
||||
|
||||
class OGLShaderProgram
|
||||
{
|
||||
protected:
|
||||
|
@ -118,7 +100,7 @@ protected:
|
|||
GLuint _programID;
|
||||
ShaderSupportTier _shaderSupport;
|
||||
|
||||
virtual GLuint LoadShaderOGL(GLenum shaderType, const char *shaderProgram);
|
||||
virtual GLuint LoadShaderOGL(GLenum shaderType, const char *shaderProgram, bool useShader150);
|
||||
virtual bool LinkOGL();
|
||||
|
||||
public:
|
||||
|
@ -128,20 +110,18 @@ public:
|
|||
ShaderSupportTier GetShaderSupport();
|
||||
void SetShaderSupport(const ShaderSupportTier theTier);
|
||||
GLuint GetVertexShaderID();
|
||||
void SetVertexShaderOGL(const char *shaderProgram);
|
||||
void SetVertexShaderOGL(const char *shaderProgram, bool useShader150);
|
||||
GLuint GetFragmentShaderID();
|
||||
void SetFragmentShaderOGL(const char *shaderProgram);
|
||||
void SetVertexAndFragmentShaderOGL(const char *vertShaderProgram, const char *fragShaderProgram);
|
||||
void SetFragmentShaderOGL(const char *shaderProgram, bool useShader150);
|
||||
void SetVertexAndFragmentShaderOGL(const char *vertShaderProgram, const char *fragShaderProgram, bool useShader150);
|
||||
GLuint GetProgramID();
|
||||
};
|
||||
|
||||
class OGLFilter
|
||||
{
|
||||
private:
|
||||
void OGLFilterInit(GLsizei srcWidth, GLsizei srcHeight, GLfloat scale);
|
||||
|
||||
protected:
|
||||
OGLShaderProgram *_program;
|
||||
bool _isVAOPresent;
|
||||
GLuint _texDstID;
|
||||
GLint _texCoordBuffer[8];
|
||||
|
||||
|
@ -157,6 +137,8 @@ protected:
|
|||
GLsizei _dstWidth;
|
||||
GLsizei _dstHeight;
|
||||
|
||||
virtual void OGLFilterInit(GLsizei srcWidth, GLsizei srcHeight, GLfloat scale);
|
||||
|
||||
public:
|
||||
OGLFilter();
|
||||
OGLFilter(GLsizei srcWidth, GLsizei srcHeight, GLfloat scale);
|
||||
|
@ -180,7 +162,7 @@ protected:
|
|||
GLuint _texIntermediateID;
|
||||
|
||||
public:
|
||||
OGLFilterDeposterize(GLsizei srcWidth, GLsizei srcHeight);
|
||||
OGLFilterDeposterize(GLsizei srcWidth, GLsizei srcHeight, ShaderSupportTier theTier, bool useShader150);
|
||||
~OGLFilterDeposterize();
|
||||
|
||||
virtual GLuint RunFilterOGL(GLuint srcTexID, GLsizei viewportWidth, GLsizei viewportHeight);
|
||||
|
@ -210,8 +192,10 @@ public:
|
|||
class OGLDisplayLayer : public OGLVideoLayer
|
||||
{
|
||||
protected:
|
||||
bool _isVAOPresent;
|
||||
bool _canUseShaderBasedFilters;
|
||||
bool _canUseShaderOutput;
|
||||
bool _useShader150;
|
||||
ShaderSupportTier _shaderSupport;
|
||||
|
||||
bool _needUploadVertices;
|
||||
|
@ -221,7 +205,7 @@ protected:
|
|||
int _outputFilter;
|
||||
VideoFilterTypeID _pixelScaler;
|
||||
|
||||
OGLFilterDeposterize *_filterDeposterize;
|
||||
OGLFilter *_filterDeposterize;
|
||||
OGLFilter *_shaderFilter;
|
||||
OGLShaderProgram *_finalOutputProgram;
|
||||
|
||||
|
@ -275,8 +259,9 @@ protected:
|
|||
void UpdateTexCoords(GLfloat s, GLfloat t);
|
||||
|
||||
public:
|
||||
OGLDisplayLayer() {};
|
||||
OGLDisplayLayer(OGLVideoOutput *oglVO);
|
||||
~OGLDisplayLayer();
|
||||
virtual ~OGLDisplayLayer();
|
||||
|
||||
bool GetFiltersPreferGPU();
|
||||
void SetFiltersPreferGPUOGL(bool preferGPU);
|
||||
|
@ -333,4 +318,9 @@ public:
|
|||
virtual void SetViewportSizeOGL(GLsizei w, GLsizei h);
|
||||
};
|
||||
|
||||
extern OGLInfo* (*OGLInfoCreate_Func)();
|
||||
extern void (*glBindVertexArrayDESMUME)(GLuint id);
|
||||
extern void (*glDeleteVertexArraysDESMUME)(GLsizei n, const GLuint *ids);
|
||||
extern void (*glGenVertexArraysDESMUME)(GLsizei n, GLuint *ids);
|
||||
|
||||
#endif // _OGLDISPLAYOUTPUT_H_
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
Copyright (C) 2015 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 "OGLDisplayOutput_3_2.h"
|
||||
|
||||
enum OGLVertexAttributeID
|
||||
{
|
||||
OGLVertexAttributeID_Position = 0,
|
||||
OGLVertexAttributeID_TexCoord0 = 8
|
||||
};
|
||||
|
||||
OGLInfo* OGLInfoCreate_3_2()
|
||||
{
|
||||
return new OGLInfo_3_2;
|
||||
}
|
||||
|
||||
void glBindVertexArray_3_2(GLuint vaoID)
|
||||
{
|
||||
glBindVertexArray(vaoID);
|
||||
}
|
||||
|
||||
void glDeleteVertexArrays_3_2(GLsizei n, const GLuint *vaoIDs)
|
||||
{
|
||||
glDeleteVertexArrays(n, vaoIDs);
|
||||
}
|
||||
|
||||
void glGenVertexArrays_3_2(GLsizei n, GLuint *vaoIDs)
|
||||
{
|
||||
glGenVertexArrays(n, vaoIDs);
|
||||
}
|
||||
|
||||
OGLInfo_3_2::OGLInfo_3_2()
|
||||
{
|
||||
_useShader150 = true;
|
||||
_isShaderSupported = true;
|
||||
_isVBOSupported = true;
|
||||
_isPBOSupported = true;
|
||||
_isFBOSupported = true;
|
||||
|
||||
glBindVertexArrayDESMUME = &glBindVertexArray_3_2;
|
||||
glDeleteVertexArraysDESMUME = &glDeleteVertexArrays_3_2;
|
||||
glGenVertexArraysDESMUME = &glGenVertexArrays_3_2;
|
||||
|
||||
_shaderSupport = ShaderSupport_MidTier;
|
||||
|
||||
if (_versionMajor == 4)
|
||||
{
|
||||
if (_versionMinor <= 1)
|
||||
{
|
||||
_shaderSupport = ShaderSupport_HighTier;
|
||||
}
|
||||
else
|
||||
{
|
||||
_shaderSupport = ShaderSupport_TopTier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OGLInfo_3_2::GetExtensionSetOGL(std::set<std::string> *oglExtensionSet)
|
||||
{
|
||||
GLint extensionCount = 0;
|
||||
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &extensionCount);
|
||||
for (unsigned int i = 0; i < extensionCount; i++)
|
||||
{
|
||||
std::string extensionName = std::string((const char *)glGetStringi(GL_EXTENSIONS, i));
|
||||
oglExtensionSet->insert(extensionName);
|
||||
}
|
||||
}
|
||||
|
||||
bool OGLInfo_3_2::IsExtensionPresent(const std::set<std::string> &oglExtensionSet, const std::string &extensionName) const
|
||||
{
|
||||
if (oglExtensionSet.size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (oglExtensionSet.find(extensionName) != oglExtensionSet.end());
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Copyright (C) 2015 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 _OGLDISPLAYOUTPUT_3_2_H_
|
||||
#define _OGLDISPLAYOUTPUT_3_2_H_
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <OpenGL/gl3.h>
|
||||
#include <OpenGL/gl3ext.h>
|
||||
#endif
|
||||
|
||||
#include "OGLDisplayOutput.h"
|
||||
|
||||
class OGLInfo_3_2 : public OGLInfo
|
||||
{
|
||||
public:
|
||||
OGLInfo_3_2();
|
||||
|
||||
virtual void GetExtensionSetOGL(std::set<std::string> *oglExtensionSet);
|
||||
virtual bool IsExtensionPresent(const std::set<std::string> &oglExtensionSet, const std::string &extensionName) const;
|
||||
};
|
||||
|
||||
OGLInfo* OGLInfoCreate_3_2();
|
||||
|
||||
#endif
|
|
@ -25,7 +25,12 @@
|
|||
#import "cocoa_videofilter.h"
|
||||
#import "cocoa_util.h"
|
||||
|
||||
#ifdef MAC_OS_X_VERSION_10_7
|
||||
#include "OGLDisplayOutput_3_2.h"
|
||||
#else
|
||||
#include "OGLDisplayOutput.h"
|
||||
#endif
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
#if defined(__ppc__) || defined(__ppc64__)
|
||||
|
@ -1286,8 +1291,21 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
|
|||
NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)0,
|
||||
NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)0,
|
||||
NSOpenGLPFADoubleBuffer,
|
||||
(NSOpenGLPixelFormatAttribute)0, (NSOpenGLPixelFormatAttribute)0,
|
||||
(NSOpenGLPixelFormatAttribute)0 };
|
||||
|
||||
#ifdef _OGLDISPLAYOUTPUT_3_2_H_
|
||||
// If we can support a 3.2 Core Profile context, then request that in our
|
||||
// pixel format attributes.
|
||||
if (IsOSXVersionSupported(10, 7, 0))
|
||||
{
|
||||
attributes[9] = kCGLPFAOpenGLProfile;
|
||||
attributes[10] = (CGLPixelFormatAttribute)kCGLOGLPVersion_3_2_Core;
|
||||
|
||||
OGLInfoCreate_Func = &OGLInfoCreate_3_2;
|
||||
}
|
||||
#endif
|
||||
|
||||
NSOpenGLPixelFormat *format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
||||
context = [[NSOpenGLContext alloc] initWithFormat:format shareContext:nil];
|
||||
[format release];
|
||||
|
|
Loading…
Reference in New Issue