@@ -52,14 +52,38 @@ enum ShaderSupportTier
5252 ShaderSupport_FutureTier = 6
5353};
5454
55- struct OGLProcessedFrameInfo
55+ enum OGLDisplayTextureUnitID
5656{
57+ OGLDisplayTextureUnitID_Video = 0 ,
58+ OGLDisplayTextureUnitID_MasterBrightnessMode = 1 ,
59+ OGLDisplayTextureUnitID_MasterBrightnessIntensity
60+ };
61+
62+ struct OGLFrameInfoFetch
63+ {
64+ uint64_t sequenceNumber;
5765 uint8_t bufferIndex;
5866 GLuint texID[2 ];
59- bool isMainDisplayProcessed;
60- bool isTouchDisplayProcessed;
67+ GLsizei width[2 ];
68+ GLsizei height[2 ];
69+ float backlightIntensity[2 ];
70+
71+ bool isNativeRender[2 ];
72+ bool isNativeSize[2 ];
73+ bool isDisplayEnabled[2 ];
74+ bool isDisplayAllWhite[2 ];
75+ bool isDisplayAllBlack[2 ];
76+ bool isDisplayProcessPossible[2 ];
77+ };
78+ typedef struct OGLFrameInfoFetch OGLFrameInfoFetch;
79+
80+ struct OGLFrameInfoProcessed
81+ {
82+ uint64_t sequenceNumber;
83+ GLuint texID[2 ];
84+ float backlightIntensity[2 ];
6185};
62- typedef struct OGLProcessedFrameInfo OGLProcessedFrameInfo ;
86+ typedef struct OGLFrameInfoProcessed OGLFrameInfoProcessed ;
6387
6488class OGLContextInfo
6589{
@@ -70,11 +94,13 @@ class OGLContextInfo
7094 char _rendererString[256 ];
7195 ShaderSupportTier _shaderSupport;
7296 bool _useShader150;
97+ bool _isIntegerTextureSupported;
7398
7499 bool _isVBOSupported;
75100 bool _isVAOSupported;
76101 bool _isPBOSupported;
77102 bool _isFBOSupported;
103+ bool _isTBOSupported;
78104
79105public:
80106 OGLContextInfo ();
@@ -86,11 +112,13 @@ class OGLContextInfo
86112 const char * GetRendererString () const ;
87113
88114 bool IsUsingShader150 ();
115+ bool IsIntegerTextureSupported () const ;
89116 bool IsVBOSupported ();
90117 bool IsVAOSupported ();
91118 bool IsPBOSupported ();
92119 bool IsShaderSupported ();
93120 bool IsFBOSupported ();
121+ bool IsTBOSupported () const ;
94122 ShaderSupportTier GetShaderSupport ();
95123
96124 virtual void GetExtensionSetOGL (std::set<std::string> *oglExtensionSet) = 0;
@@ -114,8 +142,8 @@ class OGLShaderProgram
114142 GLuint _programID;
115143 ShaderSupportTier _shaderSupport;
116144
117- virtual GLuint LoadShaderOGL (GLenum shaderType, const char *shaderProgram, bool useShader150);
118- virtual bool LinkOGL ();
145+ virtual GLuint _LoadShaderOGL (GLenum shaderType, const char *shaderProgram, bool useShader150, bool useIntegerTextures );
146+ virtual bool _LinkOGL ();
119147
120148public:
121149 OGLShaderProgram ();
@@ -126,8 +154,8 @@ class OGLShaderProgram
126154 GLuint GetVertexShaderID ();
127155 void SetVertexShaderOGL (const char *shaderProgram, bool useVtxColors, bool useShader150);
128156 GLuint GetFragmentShaderID ();
129- void SetFragmentShaderOGL (const char *shaderProgram, bool useShader150);
130- void SetVertexAndFragmentShaderOGL (const char *vertShaderProgram, const char *fragShaderProgram, bool useVtxColors, bool useShader150);
157+ void SetFragmentShaderOGL (const char *shaderProgram, bool useShader150, bool useIntegerTextures );
158+ void SetVertexAndFragmentShaderOGL (const char *vertShaderProgram, const char *fragShaderProgram, bool useVtxColors, bool useShader150, bool useIntegerTextures );
131159 GLuint GetProgramID ();
132160};
133161
@@ -163,6 +191,8 @@ class OGLFilter
163191 virtual void SetSrcSizeOGL (GLsizei w, GLsizei h);
164192 GLfloat GetScale ();
165193 void SetScaleOGL (GLfloat scale, void *buffer);
194+ GLsizei GetDstWidth () const ;
195+ GLsizei GetDstHeight () const ;
166196 virtual GLuint RunFilterOGL (GLuint srcTexID);
167197 void DownloadDstBufferOGL (uint32_t *dstBuffer, size_t lineOffset, size_t readLineCount);
168198};
@@ -326,6 +356,7 @@ class OGLDisplayLayer : public OGLVideoLayer
326356
327357 void _UpdateRotationScaleOGL ();
328358 void _UpdateVerticesOGL ();
359+ GLuint _ProcessDisplayByID_OGL (NDSDisplayID displayID, GLuint texID, size_t bufferIndex, bool useDeposterize, VideoFilterTypeID filterID, VideoFilter *cpuFilter, GLsizei &inoutWidth, GLsizei &inoutHeight);
329360
330361public:
331362 OGLDisplayLayer () {};
@@ -346,40 +377,74 @@ class OGLClientSharedData
346377{
347378protected:
348379 OGLContextInfo *_contextInfo;
380+
381+ GLuint _vboVideoProcVtxID;
382+ GLuint _vboVideoProcTexCoordNativeID;
383+ GLuint _vboVideoProcTexCoordCustomID;
384+ GLuint _vaoVideoProcNativeID;
385+ GLuint _vaoVideoProcCustomID;
386+ GLuint _fboDisplayNativeID[2 ];
387+ GLuint _fboDisplayCustomID[2 ];
388+
349389 GLenum _fetchColorFormatOGL;
350390 GLuint _texDisplayFetchNative[2 ][OPENGL_FETCH_BUFFER_COUNT];
351391 GLuint _texDisplayFetchCustom[2 ][OPENGL_FETCH_BUFFER_COUNT];
392+ GLuint _texDisplayPostprocessNative[2 ];
393+ GLuint _texDisplayPostprocessCustom[2 ];
394+ GLuint _texDisplayAllWhite;
395+ GLuint _texDisplayAllBlack;
396+
397+ GLuint _texMasterBrightnessMode[2 ][OPENGL_FETCH_BUFFER_COUNT];
398+ GLuint _texMasterBrightnessIntensity[2 ][OPENGL_FETCH_BUFFER_COUNT];
352399
353400 GLuint _texLQ2xLUT;
354401 GLuint _texHQ2xLUT;
355402 GLuint _texHQ3xLUT;
356403 GLuint _texHQ4xLUT;
357404
358- GLuint _texFetch [2 ];
405+ GLuint _texFetchSelected [2 ];
359406
407+ bool _canProcessFetchOnGPU;
408+ bool _preferCPUVideoProcessing;
360409 bool _useDirectToCPUFilterPipeline;
361410 uint32_t *_srcNativeCloneMaster;
362411 uint32_t *_srcNativeClone[2 ][OPENGL_FETCH_BUFFER_COUNT];
363412 pthread_rwlock_t _srcCloneRWLock[2 ][OPENGL_FETCH_BUFFER_COUNT];
364- pthread_rwlock_t _texFetchRWLock[2 ];
365413 bool _srcCloneNeedsUpdate[2 ][OPENGL_FETCH_BUFFER_COUNT];
366414
415+ OGLShaderProgram *_programFetch666ConvertOnly;
416+ OGLShaderProgram *_programFetch666WithMB;
417+ OGLShaderProgram *_programFetch888WithMB;
418+ GLint _vtxTexCoordBufferNative[8 ];
419+ GLint _vtxTexCoordBufferCustom[8 ];
420+
421+ pthread_rwlock_t _fetchInfoRWLock;
422+ OGLFrameInfoFetch _fetchInfo;
423+
424+ GLuint _FetchFromDisplayID_OGL (const NDSDisplayInfo ¤tDisplayInfo, NDSDisplayID displayID, GLuint texVideoID, GLuint texMBModeID, GLuint texMBIntensityID);
425+
367426public:
368427 OGLClientSharedData ();
369428 virtual ~OGLClientSharedData ();
370429
371430 void SetContextInfo (OGLContextInfo *contextInfo);
372431 OGLContextInfo* GetContextInfo () const ;
373432
433+ bool CanProcessFetchOnGPU () const ;
434+
435+ void SetPreferCPUVideoProcessing (bool prefersCPUVideoProcessing);
436+ bool PreferCPUVideoProcessing () const ;
437+
374438 void SetUseDirectToCPUFilterPipeline (bool willUseDirectCPU);
375439 bool UseDirectToCPUFilterPipeline () const ;
376440
377- virtual GLuint GetFetchTexture (const NDSDisplayID displayID);
378- virtual void SetFetchTexture (const NDSDisplayID displayID, GLuint texID);
441+ OGLFrameInfoFetch GetFetchInfo ();
379442
380443 uint32_t * GetSrcClone (const NDSDisplayID displayID, const u8 bufferIndex) const ;
381444 GLuint GetTexNative (const NDSDisplayID displayID, const u8 bufferIndex) const ;
382445 GLuint GetTexCustom (const NDSDisplayID displayID, const u8 bufferIndex) const ;
446+ GLuint GetTexDisplayAllWhite () const ;
447+ GLuint GetTexDisplayAllBlack () const ;
383448
384449 // For lack of a better place, we're putting the HQnx LUTs in the fetch object because
385450 // we know that it will be shared for all display views.
@@ -394,7 +459,7 @@ class OGLClientSharedData
394459
395460 // OpenGL-specific functions that must be called in response to their
396461 // corresponding GPUClientFetchObject methods.
397- void InitOGL ();
462+ void InitOGL (const NDSDisplayInfo *displayInfoList, const NDSDisplayInfo ¤tDisplayInfo );
398463 void SetFetchBuffersOGL (const NDSDisplayInfo *displayInfoList, const NDSDisplayInfo ¤tDisplayInfo);
399464 void FetchFromBufferIndexOGL (const u8 index, const NDSDisplayInfo ¤tDisplayInfo);
400465 void FetchNativeDisplayByID_OGL (const NDSDisplayInfo *displayInfoList, const NDSDisplayID displayID, const u8 bufferIndex);
@@ -413,7 +478,7 @@ class OGLVideoOutput : public ClientDisplay3DPresenter
413478 GLuint _texCPUFilterDstID[2 ];
414479 GLuint _fboFrameCopyID;
415480
416- OGLProcessedFrameInfo _processedFrameInfo;
481+ OGLFrameInfoProcessed _processedFrameInfo;
417482
418483 std::vector<OGLVideoLayer *> *_layerList;
419484
@@ -459,8 +524,8 @@ class OGLVideoOutput : public ClientDisplay3DPresenter
459524 virtual void PrerenderStateSetupOGL ();
460525 virtual void RenderFrameOGL (bool isRenderingFlipped);
461526
462- virtual const OGLProcessedFrameInfo& GetProcessedFrameInfo ();
463- virtual void SetProcessedFrameInfo (const OGLProcessedFrameInfo &processedInfo);
527+ virtual const OGLFrameInfoProcessed& GetFrameInfoProcessed ();
528+ virtual void SetFrameInfoProcessed (const OGLFrameInfoProcessed &processedInfo);
464529
465530 virtual void WriteLockEmuFramebuffer (const uint8_t bufferIndex);
466531 virtual void ReadLockEmuFramebuffer (const uint8_t bufferIndex);
0 commit comments