GPU: Change the rendering paradigm where, rather than performing inline colorspace conversions during rendering, all rendering is performed at 15-bit until 3D rendering or 24-bit custom VRAM creates the need for a color space conversion.
- For purposes of maintaining a record and make for easier reversions, the code has NOT been fully optimized or cleaned up. This will happen over a period of time as the code settles down through testing. - All "native" buffers are no longer assumed to be in any color space and are now assumed to always be 15-bit. The native buffers are now referenced using uint16_t pointers and are now suffixed with "16" in order to reflect this change. - Of note, all clients that reference masterNativeBuffer or nativeBuffer via NDSDisplayInfo must now assume that these native buffers will always be in the 16-bit color space. - Any 18-bit and 24-bit rendering now happens in the custom buffers.
This commit is contained in:
parent
c082782fa9
commit
4578728120
File diff suppressed because it is too large
Load Diff
|
@ -1169,13 +1169,14 @@ typedef struct
|
|||
// A specific index can be chosen at the DidFrameBegin event.
|
||||
size_t sequenceNumber; // A unique number assigned to each frame that increments for each DidFrameEnd event. Never resets.
|
||||
|
||||
void *masterNativeBuffer; // Pointer to the head of the master native buffer.
|
||||
u16 *masterNativeBuffer16; // Pointer to the head of the master native buffer.
|
||||
void *masterCustomBuffer; // Pointer to the head of the master custom buffer.
|
||||
// If GPUSubsystem::GetWillAutoResolveToCustomBuffer() would return true, or if
|
||||
// GPUSubsystem::ResolveDisplayToCustomFramebuffer() is called, then this buffer is used as the
|
||||
// target buffer for resolving any native-sized renders.
|
||||
|
||||
void *nativeBuffer[2]; // Pointer to the display's native size framebuffer.
|
||||
u32 *workingNativeBuffer32[2]; // Pointer to a native size working framebuffer. (Usually used as an intermediate buffer for internal use, but might be useful for the client.)
|
||||
u16 *nativeBuffer16[2]; // Pointer to the display's native size framebuffer.
|
||||
void *customBuffer[2]; // Pointer to the display's custom size framebuffer.
|
||||
|
||||
size_t renderedWidth[2]; // The display rendered at this width, measured in pixels.
|
||||
|
@ -1388,8 +1389,9 @@ protected:
|
|||
u8 *_deferredIndexCustom;
|
||||
u16 *_deferredColorCustom;
|
||||
|
||||
u16 *_nativeBuffer16;
|
||||
u32 *_workingNativeBuffer32;
|
||||
void *_customBuffer;
|
||||
void *_nativeBuffer;
|
||||
|
||||
bool _isLineRenderNative[GPU_FRAMEBUFFER_NATIVE_HEIGHT];
|
||||
bool _isLineDisplayNative[GPU_FRAMEBUFFER_NATIVE_HEIGHT];
|
||||
|
@ -1426,7 +1428,7 @@ protected:
|
|||
|
||||
NDSDisplayID _targetDisplayID;
|
||||
|
||||
CACHE_ALIGN FragmentColor _internalRenderLineTargetNative[GPU_FRAMEBUFFER_NATIVE_WIDTH];
|
||||
CACHE_ALIGN u16 _internalRenderLineTargetNative[GPU_FRAMEBUFFER_NATIVE_WIDTH];
|
||||
CACHE_ALIGN u8 _renderLineLayerIDNative[GPU_FRAMEBUFFER_NATIVE_HEIGHT][GPU_FRAMEBUFFER_NATIVE_WIDTH];
|
||||
|
||||
void *_internalRenderLineTargetCustom;
|
||||
|
@ -1707,7 +1709,7 @@ private:
|
|||
NDSDisplayID _ID;
|
||||
GPUEngineBase *_gpu;
|
||||
|
||||
void *_nativeBuffer;
|
||||
u16 *_nativeBuffer16;
|
||||
void *_customBuffer;
|
||||
|
||||
void __constructor(const NDSDisplayID displayID, GPUEngineBase *theEngine);
|
||||
|
@ -1723,9 +1725,9 @@ public:
|
|||
GPUEngineID GetEngineID();
|
||||
void SetEngineByID(const GPUEngineID theID);
|
||||
|
||||
void* GetNativeBuffer() const;
|
||||
u16* GetNativeBuffer16() const;
|
||||
void* GetCustomBuffer() const;
|
||||
void SetDrawBuffers(void *nativeBuffer, void *customBuffer);
|
||||
void SetDrawBuffers(u16 *nativeBuffer16, void *customBuffer);
|
||||
};
|
||||
|
||||
class GPUEventHandler
|
||||
|
@ -1791,7 +1793,8 @@ private:
|
|||
void _UpdateFPSRender3D();
|
||||
void _AllocateFramebuffers(NDSColorFormat outputFormat, size_t w, size_t h, size_t pageCount);
|
||||
|
||||
u8* _DownscaleAndConvertForSavestate(const NDSDisplayID displayID, void *__restrict intermediateBuffer);
|
||||
void _DownscaleAndConvertForSavestate(const NDSDisplayID displayID, const void *srcBuffer, u16 *dstBuffer);
|
||||
void _ConvertAndUpscaleForLoadstate(const NDSDisplayID displayID, const u16 *srcBuffer, void *dstBuffer);
|
||||
|
||||
public:
|
||||
GPUSubsystem();
|
||||
|
|
|
@ -4661,15 +4661,32 @@ void OGLClientFetchObject::FetchNativeDisplayToSrcClone(const NDSDisplayID displ
|
|||
return;
|
||||
}
|
||||
|
||||
if (this->_fetchColorFormatOGL == GL_UNSIGNED_SHORT_1_5_5_5_REV)
|
||||
ColorspaceConvertBuffer555To8888Opaque<false, false, BESwapDst>(this->_fetchDisplayInfo[bufferIndex].nativeBuffer16[displayID], this->_srcNativeClone[displayID][bufferIndex], GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT);
|
||||
this->_srcCloneNeedsUpdate[displayID][bufferIndex] = false;
|
||||
|
||||
if (needsLock)
|
||||
{
|
||||
ColorspaceConvertBuffer555To8888Opaque<false, false, BESwapDst>((const uint16_t *)this->_fetchDisplayInfo[bufferIndex].nativeBuffer[displayID], this->_srcNativeClone[displayID][bufferIndex], GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT);
|
||||
pthread_rwlock_unlock(&this->_srcCloneRWLock[displayID][bufferIndex]);
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
void OGLClientFetchObject::FetchCustomDisplayToSrcClone(const NDSDisplayID displayID, const u8 bufferIndex, bool needsLock)
|
||||
{
|
||||
if (needsLock)
|
||||
{
|
||||
ColorspaceConvertBuffer888XTo8888Opaque<false, false>((const uint32_t *)this->_fetchDisplayInfo[bufferIndex].nativeBuffer[displayID], this->_srcNativeClone[displayID][bufferIndex], GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT);
|
||||
pthread_rwlock_wrlock(&this->_srcCloneRWLock[displayID][bufferIndex]);
|
||||
}
|
||||
|
||||
if (!this->_srcCloneNeedsUpdate[displayID][bufferIndex])
|
||||
{
|
||||
if (needsLock)
|
||||
{
|
||||
pthread_rwlock_unlock(&this->_srcCloneRWLock[displayID][bufferIndex]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ColorspaceConvertBuffer888XTo8888Opaque<false, false>((u32 *)this->_fetchDisplayInfo[bufferIndex].customBuffer[displayID], this->_srcNativeClone[displayID][bufferIndex], GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT);
|
||||
this->_srcCloneNeedsUpdate[displayID][bufferIndex] = false;
|
||||
|
||||
if (needsLock)
|
||||
|
@ -4762,11 +4779,11 @@ void OGLClientFetchObject::SetFetchBuffers(const NDSDisplayInfo ¤tDisplayI
|
|||
{
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchNative[NDSDisplayID_Main][i]);
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_SHARED_APPLE);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_fetchDisplayInfo[i].nativeBuffer[NDSDisplayID_Main]);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, this->_fetchDisplayInfo[i].nativeBuffer16[NDSDisplayID_Main]);
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchNative[NDSDisplayID_Touch][i]);
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_SHARED_APPLE);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_fetchDisplayInfo[i].nativeBuffer[NDSDisplayID_Touch]);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, this->_fetchDisplayInfo[i].nativeBuffer16[NDSDisplayID_Touch]);
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchCustom[NDSDisplayID_Main][i]);
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_SHARED_APPLE);
|
||||
|
@ -4831,22 +4848,28 @@ void OGLClientFetchObject::FetchFromBufferIndex(const u8 index)
|
|||
|
||||
void OGLClientFetchObject::_FetchNativeDisplayByID(const NDSDisplayID displayID, const u8 bufferIndex)
|
||||
{
|
||||
pthread_rwlock_wrlock(&this->_srcCloneRWLock[displayID][bufferIndex]);
|
||||
this->_srcCloneNeedsUpdate[displayID][bufferIndex] = true;
|
||||
|
||||
if (this->_useDirectToCPUFilterPipeline)
|
||||
{
|
||||
pthread_rwlock_wrlock(&this->_srcCloneRWLock[displayID][bufferIndex]);
|
||||
this->_srcCloneNeedsUpdate[displayID][bufferIndex] = true;
|
||||
this->FetchNativeDisplayToSrcClone(displayID, bufferIndex, false);
|
||||
pthread_rwlock_unlock(&this->_srcCloneRWLock[displayID][bufferIndex]);
|
||||
}
|
||||
|
||||
pthread_rwlock_unlock(&this->_srcCloneRWLock[displayID][bufferIndex]);
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchNative[displayID][bufferIndex]);
|
||||
glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, GL_RGBA, this->_fetchColorFormatOGL, this->_fetchDisplayInfo[bufferIndex].nativeBuffer[displayID]);
|
||||
glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, this->_fetchDisplayInfo[bufferIndex].nativeBuffer16[displayID]);
|
||||
}
|
||||
|
||||
void OGLClientFetchObject::_FetchCustomDisplayByID(const NDSDisplayID displayID, const u8 bufferIndex)
|
||||
{
|
||||
if (this->_useDirectToCPUFilterPipeline && (this->_fetchDisplayInfo[bufferIndex].renderedWidth[displayID] == GPU_FRAMEBUFFER_NATIVE_WIDTH) && (this->_fetchDisplayInfo[bufferIndex].renderedHeight[displayID] == GPU_FRAMEBUFFER_NATIVE_HEIGHT))
|
||||
{
|
||||
pthread_rwlock_wrlock(&this->_srcCloneRWLock[displayID][bufferIndex]);
|
||||
this->_srcCloneNeedsUpdate[displayID][bufferIndex] = true;
|
||||
this->FetchCustomDisplayToSrcClone(displayID, bufferIndex, false);
|
||||
pthread_rwlock_unlock(&this->_srcCloneRWLock[displayID][bufferIndex]);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchCustom[displayID][bufferIndex]);
|
||||
glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, this->_fetchDisplayInfo[bufferIndex].customWidth, this->_fetchDisplayInfo[bufferIndex].customHeight, GL_RGBA, this->_fetchColorFormatOGL, this->_fetchDisplayInfo[bufferIndex].customBuffer[displayID]);
|
||||
}
|
||||
|
@ -4958,6 +4981,11 @@ void OGLVideoOutput::_LoadNativeDisplayByID(const NDSDisplayID displayID)
|
|||
this->GetDisplayLayer()->LoadNativeDisplayByID_OGL(displayID);
|
||||
}
|
||||
|
||||
void OGLVideoOutput::_LoadCustomDisplayByID(const NDSDisplayID displayID)
|
||||
{
|
||||
this->GetDisplayLayer()->LoadCustomDisplayByID_OGL(displayID);
|
||||
}
|
||||
|
||||
void OGLVideoOutput::_ResizeCPUPixelScaler(const VideoFilterTypeID filterID)
|
||||
{
|
||||
const VideoFilterAttributes newFilterAttr = VideoFilter::GetAttributesByID(filterID);
|
||||
|
@ -7072,6 +7100,21 @@ void OGLDisplayLayer::LoadNativeDisplayByID_OGL(const NDSDisplayID displayID)
|
|||
}
|
||||
}
|
||||
|
||||
void OGLDisplayLayer::LoadCustomDisplayByID_OGL(const NDSDisplayID displayID)
|
||||
{
|
||||
if ((this->_output->GetPixelScaler() != VideoFilterTypeID_None) && !this->_output->WillFilterOnGPU() && !this->_output->GetSourceDeposterize() && (this->_output->GetEmuDisplayInfo().customWidth == GPU_FRAMEBUFFER_NATIVE_WIDTH) && (this->_output->GetEmuDisplayInfo().customHeight == GPU_FRAMEBUFFER_NATIVE_HEIGHT) )
|
||||
{
|
||||
OGLClientFetchObject &fetchObjMutable = (OGLClientFetchObject &)this->_output->GetFetchObject();
|
||||
VideoFilter *vf = this->_output->GetPixelScalerObject(displayID);
|
||||
|
||||
const uint8_t bufferIndex = fetchObjMutable.GetLastFetchIndex();
|
||||
|
||||
pthread_rwlock_wrlock(&this->_cpuFilterRWLock[displayID][bufferIndex]);
|
||||
fetchObjMutable.CopyFromSrcClone(vf->GetSrcBufferPtr(), displayID, bufferIndex);
|
||||
pthread_rwlock_unlock(&this->_cpuFilterRWLock[displayID][bufferIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
void OGLDisplayLayer::ProcessOGL()
|
||||
{
|
||||
OGLClientFetchObject &fetchObj = (OGLClientFetchObject &)this->_output->GetFetchObject();
|
||||
|
|
|
@ -326,6 +326,7 @@ public:
|
|||
bool SetGPUPixelScalerOGL(const VideoFilterTypeID filterID);
|
||||
|
||||
void LoadNativeDisplayByID_OGL(const NDSDisplayID displayID);
|
||||
void LoadCustomDisplayByID_OGL(const NDSDisplayID displayID);
|
||||
void ProcessOGL();
|
||||
|
||||
virtual void RenderOGL(bool isRenderingFlipped);
|
||||
|
@ -374,6 +375,7 @@ public:
|
|||
|
||||
void CopyFromSrcClone(uint32_t *dstBufferPtr, const NDSDisplayID displayID, const u8 bufferIndex);
|
||||
void FetchNativeDisplayToSrcClone(const NDSDisplayID displayID, const u8 bufferIndex, bool needsLock);
|
||||
void FetchCustomDisplayToSrcClone(const NDSDisplayID displayID, const u8 bufferIndex, bool needsLock);
|
||||
void FetchTextureWriteLock(const NDSDisplayID displayID);
|
||||
void FetchTextureReadLock(const NDSDisplayID displayID);
|
||||
void FetchTextureUnlock(const NDSDisplayID displayID);
|
||||
|
@ -411,6 +413,7 @@ protected:
|
|||
virtual void _UpdateViewScale();
|
||||
|
||||
virtual void _LoadNativeDisplayByID(const NDSDisplayID displayID);
|
||||
virtual void _LoadCustomDisplayByID(const NDSDisplayID displayID);
|
||||
virtual void _ResizeCPUPixelScaler(const VideoFilterTypeID filterID);
|
||||
|
||||
public:
|
||||
|
|
|
@ -325,6 +325,7 @@ protected:
|
|||
virtual void _UpdateClientSize();
|
||||
virtual void _UpdateViewScale();
|
||||
virtual void _LoadNativeDisplayByID(const NDSDisplayID displayID);
|
||||
virtual void _LoadCustomDisplayByID(const NDSDisplayID displayID);
|
||||
virtual void _ResizeCPUPixelScaler(const VideoFilterTypeID filterID);
|
||||
|
||||
public:
|
||||
|
|
|
@ -214,7 +214,7 @@
|
|||
|
||||
// Set up the loading textures. These are special because they copy the raw image data from the emulator to the GPU.
|
||||
_fetchPixelBytes = sizeof(uint16_t);
|
||||
_nativeLineSize = GPU_FRAMEBUFFER_NATIVE_WIDTH * _fetchPixelBytes;
|
||||
_nativeLineSize = GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(uint16_t);
|
||||
_nativeBufferSize = GPU_FRAMEBUFFER_NATIVE_HEIGHT * _nativeLineSize;
|
||||
_customLineSize = _nativeLineSize;
|
||||
_customBufferSize = _nativeBufferSize;
|
||||
|
@ -329,12 +329,12 @@
|
|||
const size_t w = dispInfo.customWidth;
|
||||
const size_t h = dispInfo.customHeight;
|
||||
|
||||
_nativeLineSize = GPU_FRAMEBUFFER_NATIVE_WIDTH * dispInfo.pixelBytes;
|
||||
_nativeLineSize = GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(uint16_t);
|
||||
_nativeBufferSize = GPU_FRAMEBUFFER_NATIVE_HEIGHT * _nativeLineSize;
|
||||
_customLineSize = w * dispInfo.pixelBytes;
|
||||
_customBufferSize = h * _customLineSize;
|
||||
|
||||
MTLTextureDescriptor *newTexDisplayNativeDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:(dispInfo.colorFormat == NDSColorFormat_BGR555_Rev) ? MTLPixelFormatR16Uint : MTLPixelFormatRGBA8Unorm
|
||||
/*
|
||||
MTLTextureDescriptor *newTexDisplayNativeDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatR16Uint
|
||||
width:GPU_FRAMEBUFFER_NATIVE_WIDTH
|
||||
height:GPU_FRAMEBUFFER_NATIVE_HEIGHT
|
||||
mipmapped:NO];
|
||||
|
@ -349,7 +349,7 @@
|
|||
[newTexPostprocessNativeDesc setResourceOptions:MTLResourceStorageModePrivate];
|
||||
[newTexPostprocessNativeDesc setStorageMode:MTLStorageModePrivate];
|
||||
[newTexPostprocessNativeDesc setUsage:MTLTextureUsageShaderRead | MTLTextureUsageShaderWrite];
|
||||
|
||||
*/
|
||||
MTLTextureDescriptor *newTexDisplayCustomDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:(dispInfo.colorFormat == NDSColorFormat_BGR555_Rev) ? MTLPixelFormatR16Uint : MTLPixelFormatRGBA8Unorm
|
||||
width:w
|
||||
height:h
|
||||
|
@ -375,12 +375,12 @@
|
|||
[_bufDisplayFetchCustom[NDSDisplayID_Main][i] release];
|
||||
[_bufDisplayFetchCustom[NDSDisplayID_Touch][i] release];
|
||||
|
||||
_bufDisplayFetchNative[NDSDisplayID_Main][i] = [device newBufferWithBytesNoCopy:dispInfoAtIndex.nativeBuffer[NDSDisplayID_Main]
|
||||
_bufDisplayFetchNative[NDSDisplayID_Main][i] = [device newBufferWithBytesNoCopy:dispInfoAtIndex.nativeBuffer16[NDSDisplayID_Main]
|
||||
length:_nativeBufferSize
|
||||
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
|
||||
deallocator:nil];
|
||||
|
||||
_bufDisplayFetchNative[NDSDisplayID_Touch][i] = [device newBufferWithBytesNoCopy:dispInfoAtIndex.nativeBuffer[NDSDisplayID_Touch]
|
||||
_bufDisplayFetchNative[NDSDisplayID_Touch][i] = [device newBufferWithBytesNoCopy:dispInfoAtIndex.nativeBuffer16[NDSDisplayID_Touch]
|
||||
length:_nativeBufferSize
|
||||
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
|
||||
deallocator:nil];
|
||||
|
@ -394,7 +394,7 @@
|
|||
length:_customBufferSize
|
||||
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
|
||||
deallocator:nil];
|
||||
|
||||
/*
|
||||
if (_fetchPixelBytes != dispInfo.pixelBytes)
|
||||
{
|
||||
[_texDisplayFetchNative[NDSDisplayID_Main][i] release];
|
||||
|
@ -407,7 +407,7 @@
|
|||
_texDisplayPostprocessNative[NDSDisplayID_Main][i] = [device newTextureWithDescriptor:newTexPostprocessNativeDesc];
|
||||
_texDisplayPostprocessNative[NDSDisplayID_Touch][i] = [device newTextureWithDescriptor:newTexPostprocessNativeDesc];
|
||||
}
|
||||
|
||||
*/
|
||||
if ( (_fetchPixelBytes != dispInfo.pixelBytes) ||
|
||||
([_texDisplayFetchCustom[NDSDisplayID_Main][i] width] != w) ||
|
||||
([_texDisplayFetchCustom[NDSDisplayID_Main][i] height] != h) )
|
||||
|
@ -499,7 +499,7 @@
|
|||
|
||||
if (isMainEnabled)
|
||||
{
|
||||
if (currentDisplayInfo.colorFormat == NDSColorFormat_BGR555_Rev)
|
||||
if (isMainNative || (currentDisplayInfo.colorFormat == NDSColorFormat_BGR555_Rev) )
|
||||
{
|
||||
[cce setComputePipelineState:_fetch555Pipeline];
|
||||
}
|
||||
|
@ -542,7 +542,7 @@
|
|||
|
||||
if (isTouchEnabled)
|
||||
{
|
||||
if (currentDisplayInfo.colorFormat == NDSColorFormat_BGR555_Rev)
|
||||
if (isTouchNative || (currentDisplayInfo.colorFormat == NDSColorFormat_BGR555_Rev) )
|
||||
{
|
||||
[cce setComputePipelineState:_fetch555Pipeline];
|
||||
}
|
||||
|
@ -585,13 +585,13 @@
|
|||
|
||||
[cce endEncoding];
|
||||
}
|
||||
else if (currentDisplayInfo.colorFormat != NDSColorFormat_BGR888_Rev)
|
||||
else
|
||||
{
|
||||
id<MTLComputeCommandEncoder> cce = [cb computeCommandEncoder];
|
||||
|
||||
if (isMainEnabled)
|
||||
{
|
||||
if (currentDisplayInfo.colorFormat == NDSColorFormat_BGR555_Rev)
|
||||
if (isMainNative || (currentDisplayInfo.colorFormat == NDSColorFormat_BGR555_Rev))
|
||||
{
|
||||
// 16-bit textures aren't handled natively in Metal for macOS, so we need to explicitly convert to 32-bit here.
|
||||
[cce setComputePipelineState:_fetch555ConvertOnlyPipeline];
|
||||
|
@ -627,7 +627,7 @@
|
|||
|
||||
if (isTouchEnabled)
|
||||
{
|
||||
if (currentDisplayInfo.colorFormat == NDSColorFormat_BGR555_Rev)
|
||||
if (isTouchNative || (currentDisplayInfo.colorFormat == NDSColorFormat_BGR555_Rev))
|
||||
{
|
||||
[cce setComputePipelineState:_fetch555ConvertOnlyPipeline];
|
||||
}
|
||||
|
@ -2481,16 +2481,7 @@ void MacMetalFetchObject::_FetchNativeDisplayByID(const NDSDisplayID displayID,
|
|||
GPU->PostprocessDisplay(displayID, this->_fetchDisplayInfo[bufferIndex]);
|
||||
|
||||
pthread_rwlock_wrlock(&this->_srcCloneRWLock[displayID][bufferIndex]);
|
||||
|
||||
if (this->_fetchDisplayInfo[bufferIndex].pixelBytes == 2)
|
||||
{
|
||||
ColorspaceConvertBuffer555To8888Opaque<false, false, BESwapDst>((const uint16_t *)this->_fetchDisplayInfo[bufferIndex].nativeBuffer[displayID], this->_srcNativeClone[displayID][bufferIndex], GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT);
|
||||
}
|
||||
else
|
||||
{
|
||||
ColorspaceConvertBuffer888XTo8888Opaque<false, false>((const uint32_t *)this->_fetchDisplayInfo[bufferIndex].nativeBuffer[displayID], this->_srcNativeClone[displayID][bufferIndex], GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT);
|
||||
}
|
||||
|
||||
ColorspaceConvertBuffer555To8888Opaque<false, false, BESwapDst>(this->_fetchDisplayInfo[bufferIndex].nativeBuffer16[displayID], this->_srcNativeClone[displayID][bufferIndex], GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT);
|
||||
pthread_rwlock_unlock(&this->_srcCloneRWLock[displayID][bufferIndex]);
|
||||
}
|
||||
|
||||
|
@ -2499,6 +2490,15 @@ void MacMetalFetchObject::_FetchNativeDisplayByID(const NDSDisplayID displayID,
|
|||
|
||||
void MacMetalFetchObject::_FetchCustomDisplayByID(const NDSDisplayID displayID, const u8 bufferIndex)
|
||||
{
|
||||
if (this->_useDirectToCPUFilterPipeline && (this->_fetchDisplayInfo[bufferIndex].renderedWidth[displayID] == GPU_FRAMEBUFFER_NATIVE_WIDTH) && (this->_fetchDisplayInfo[bufferIndex].renderedHeight[displayID] == GPU_FRAMEBUFFER_NATIVE_HEIGHT))
|
||||
{
|
||||
GPU->PostprocessDisplay(displayID, this->_fetchDisplayInfo[bufferIndex]);
|
||||
|
||||
pthread_rwlock_wrlock(&this->_srcCloneRWLock[displayID][bufferIndex]);
|
||||
ColorspaceConvertBuffer888XTo8888Opaque<false, false>((u32 *)this->_fetchDisplayInfo[bufferIndex].customBuffer[displayID], this->_srcNativeClone[displayID][bufferIndex], GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT);
|
||||
pthread_rwlock_unlock(&this->_srcCloneRWLock[displayID][bufferIndex]);
|
||||
}
|
||||
|
||||
[(MetalDisplayViewSharedData *)this->_clientData fetchCustomDisplayByID:displayID bufferIndex:bufferIndex blitCommandEncoder:[(MetalDisplayViewSharedData *)this->_clientData bceFetch]];
|
||||
}
|
||||
|
||||
|
@ -2586,6 +2586,21 @@ void MacMetalDisplayPresenter::_LoadNativeDisplayByID(const NDSDisplayID display
|
|||
}
|
||||
}
|
||||
|
||||
void MacMetalDisplayPresenter::_LoadCustomDisplayByID(const NDSDisplayID displayID)
|
||||
{
|
||||
if ( (this->GetPixelScaler() != VideoFilterTypeID_None) && !this->WillFilterOnGPU() && !this->GetSourceDeposterize() && (this->_emuDisplayInfo.renderedWidth[displayID] == GPU_FRAMEBUFFER_NATIVE_WIDTH) && (this->_emuDisplayInfo.renderedHeight[displayID] == GPU_FRAMEBUFFER_NATIVE_HEIGHT) )
|
||||
{
|
||||
MacMetalFetchObject &fetchObjMutable = (MacMetalFetchObject &)this->GetFetchObject();
|
||||
VideoFilter *vf = this->GetPixelScalerObject(displayID);
|
||||
|
||||
const uint8_t bufferIndex = fetchObjMutable.GetLastFetchIndex();
|
||||
|
||||
dispatch_semaphore_wait(this->_semCPUFilter[displayID], DISPATCH_TIME_FOREVER);
|
||||
fetchObjMutable.CopyFromSrcClone(vf->GetSrcBufferPtr(), displayID, bufferIndex);
|
||||
dispatch_semaphore_signal(this->_semCPUFilter[displayID]);
|
||||
}
|
||||
}
|
||||
|
||||
void MacMetalDisplayPresenter::_ResizeCPUPixelScaler(const VideoFilterTypeID filterID)
|
||||
{
|
||||
dispatch_semaphore_wait(this->_semCPUFilter[NDSDisplayID_Main], DISPATCH_TIME_FOREVER);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (C) 2006 yopyop
|
||||
Copyright (C) 2006-2007 shash
|
||||
Copyright (C) 2008-2020 DeSmuME team
|
||||
Copyright (C) 2008-2021 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
|
||||
|
@ -71,10 +71,10 @@ static void sdl_draw_no_opengl()
|
|||
{
|
||||
const NDSDisplayInfo &displayInfo = GPU->GetDisplayInfo();
|
||||
const size_t pixCount = GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT;
|
||||
ColorspaceApplyIntensityToBuffer16<false, false>((u16 *)displayInfo.masterNativeBuffer, pixCount, displayInfo.backlightIntensity[NDSDisplayID_Main]);
|
||||
ColorspaceApplyIntensityToBuffer16<false, false>((u16 *)displayInfo.masterNativeBuffer + pixCount, pixCount, displayInfo.backlightIntensity[NDSDisplayID_Touch]);
|
||||
ColorspaceApplyIntensityToBuffer16<false, false>(displayInfo.nativeBuffer16[NDSDisplayID_Main], pixCount, displayInfo.backlightIntensity[NDSDisplayID_Main]);
|
||||
ColorspaceApplyIntensityToBuffer16<false, false>(displayInfo.nativeBuffer16[NDSDisplayID_Touch], pixCount, displayInfo.backlightIntensity[NDSDisplayID_Touch]);
|
||||
|
||||
SDL_Surface *rawImage = SDL_CreateRGBSurfaceFrom(displayInfo.masterNativeBuffer, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2, 16, GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(u16), 0x001F, 0x03E0, 0x7C00, 0);
|
||||
SDL_Surface *rawImage = SDL_CreateRGBSurfaceFrom(displayInfo.masterNativeBuffer16, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2, 16, GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(u16), 0x001F, 0x03E0, 0x7C00, 0);
|
||||
if(rawImage == NULL) return;
|
||||
|
||||
SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, rawImage);
|
||||
|
@ -317,4 +317,4 @@ EXPORTED BOOL desmume_draw_window_has_quit()
|
|||
EXPORTED void desmume_draw_window_free()
|
||||
{
|
||||
SDL_Quit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (C) 2006 yopyop
|
||||
Copyright (C) 2006-2007 shash
|
||||
Copyright (C) 2008-2020 DeSmuME team
|
||||
Copyright (C) 2008-2021 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
|
||||
|
@ -230,10 +230,10 @@ EXPORTED u16 *desmume_draw_raw()
|
|||
{
|
||||
const NDSDisplayInfo &displayInfo = GPU->GetDisplayInfo();
|
||||
const size_t pixCount = GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT;
|
||||
ColorspaceApplyIntensityToBuffer16<false, false>((u16 *)displayInfo.masterNativeBuffer, pixCount, displayInfo.backlightIntensity[NDSDisplayID_Main]);
|
||||
ColorspaceApplyIntensityToBuffer16<false, false>((u16 *)displayInfo.masterNativeBuffer + pixCount, pixCount, displayInfo.backlightIntensity[NDSDisplayID_Touch]);
|
||||
ColorspaceApplyIntensityToBuffer16<false, false>(displayInfo.nativeBuffer16[NDSDisplayID_Main], pixCount, displayInfo.backlightIntensity[NDSDisplayID_Main]);
|
||||
ColorspaceApplyIntensityToBuffer16<false, false>(displayInfo.nativeBuffer16[NDSDisplayID_Touch], pixCount, displayInfo.backlightIntensity[NDSDisplayID_Touch]);
|
||||
|
||||
return (u16*) displayInfo.masterNativeBuffer;
|
||||
return displayInfo.masterNativeBuffer16;
|
||||
}
|
||||
|
||||
EXPORTED void desmume_draw_raw_as_rgbx(u8 *buffer)
|
||||
|
@ -511,7 +511,7 @@ EXPORTED void desmume_memory_register_exec(int address, int size, memory_cb_fnc
|
|||
|
||||
EXPORTED void desmume_screenshot(char *screenshot_buffer)
|
||||
{
|
||||
u16 *gpuFramebuffer = (u16 *)GPU->GetDisplayInfo().masterNativeBuffer;
|
||||
u16 *gpuFramebuffer = GPU->GetDisplayInfo().masterNativeBuffer16;
|
||||
static int seq = 0;
|
||||
|
||||
for (int i = 0; i < SCREENS_PIXEL_SIZE; i++) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* main.c - this file is part of DeSmuME
|
||||
*
|
||||
* Copyright (C) 2006-2019 DeSmuME Team
|
||||
* Copyright (C) 2006-2021 DeSmuME Team
|
||||
* Copyright (C) 2007 Pascal Giard (evilynux)
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
|
@ -433,10 +433,10 @@ static void
|
|||
Draw( void) {
|
||||
const NDSDisplayInfo &displayInfo = GPU->GetDisplayInfo();
|
||||
const size_t pixCount = GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT;
|
||||
ColorspaceApplyIntensityToBuffer16<false, false>((u16 *)displayInfo.masterNativeBuffer, pixCount, displayInfo.backlightIntensity[NDSDisplayID_Main]);
|
||||
ColorspaceApplyIntensityToBuffer16<false, false>((u16 *)displayInfo.masterNativeBuffer + pixCount, pixCount, displayInfo.backlightIntensity[NDSDisplayID_Touch]);
|
||||
ColorspaceApplyIntensityToBuffer16<false, false>(displayInfo.nativeBuffer16[NDSDisplayID_Main], pixCount, displayInfo.backlightIntensity[NDSDisplayID_Main]);
|
||||
ColorspaceApplyIntensityToBuffer16<false, false>(displayInfo.nativeBuffer16[NDSDisplayID_Touch], pixCount, displayInfo.backlightIntensity[NDSDisplayID_Touch]);
|
||||
|
||||
SDL_Surface *rawImage = SDL_CreateRGBSurfaceFrom(displayInfo.masterNativeBuffer, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2, 16, GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(u16), 0x001F, 0x03E0, 0x7C00, 0);
|
||||
SDL_Surface *rawImage = SDL_CreateRGBSurfaceFrom(displayInfo.masterNativeBuffer16, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2, 16, GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(u16), 0x001F, 0x03E0, 0x7C00, 0);
|
||||
if(rawImage == NULL) return;
|
||||
|
||||
SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, rawImage);
|
||||
|
@ -708,7 +708,7 @@ int main(int argc, char ** argv) {
|
|||
// Now that gtk port draws to RGBA buffer directly, the other one
|
||||
// has to use ugly ways to make HUD rendering work again.
|
||||
// desmume gtk: Sorry desmume-cli :(
|
||||
T_AGG_RGB555 agg_targetScreen_cli((u8 *)GPU->GetDisplayInfo().masterNativeBuffer, 256, 384, 512);
|
||||
T_AGG_RGB555 agg_targetScreen_cli((u8 *)GPU->GetDisplayInfo().masterNativeBuffer16, 256, 384, 512);
|
||||
aggDraw.hud = &agg_targetScreen_cli;
|
||||
aggDraw.hud->setFont("verdana18_bold");
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) 2007 Pascal Giard (evilynux)
|
||||
Copyright (C) 2006-2019 DeSmuME team
|
||||
Copyright (C) 2006-2021 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
|
||||
|
@ -1309,7 +1309,7 @@ static int ConfigureDrawingArea(GtkWidget *widget, GdkEventConfigure *event, gpo
|
|||
|
||||
static inline void gpu_screen_to_rgb(u32* dst)
|
||||
{
|
||||
ColorspaceConvertBuffer555To8888Opaque<false, false, BESwapDst>((const uint16_t *)GPU->GetDisplayInfo().masterNativeBuffer, dst, GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2);
|
||||
ColorspaceConvertBuffer555To8888Opaque<false, false, BESwapDst>(GPU->GetDisplayInfo().masterNativeBuffer16, dst, GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2);
|
||||
}
|
||||
|
||||
static inline void drawScreen(cairo_t* cr, u32* buf, gint w, gint h) {
|
||||
|
@ -1435,7 +1435,7 @@ static gboolean ExposeDrawingArea (GtkWidget *widget, GdkEventExpose *event, gpo
|
|||
}
|
||||
|
||||
static void RedrawScreen() {
|
||||
ColorspaceConvertBuffer555To8888Opaque<true, false, BESwapDst>((const uint16_t *)GPU->GetDisplayInfo().masterNativeBuffer, (uint32_t *)video->GetSrcBufferPtr(), GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2);
|
||||
ColorspaceConvertBuffer555To8888Opaque<true, false, BESwapDst>(GPU->GetDisplayInfo().masterNativeBuffer16, (uint32_t *)video->GetSrcBufferPtr(), GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2);
|
||||
#ifdef HAVE_LIBAGG
|
||||
aggDraw.hud->attach((u8*)video->GetSrcBufferPtr(), 256, 384, 1024);
|
||||
osd->update();
|
||||
|
@ -2525,7 +2525,7 @@ gboolean EmuLoop(gpointer data)
|
|||
desmume_cycle(); /* Emule ! */
|
||||
|
||||
_updateDTools();
|
||||
avout_x264.updateVideo((const uint16_t *)GPU->GetDisplayInfo().masterNativeBuffer);
|
||||
avout_x264.updateVideo(GPU->GetDisplayInfo().masterNativeBuffer16);
|
||||
RedrawScreen();
|
||||
|
||||
if (!config.fpslimiter || keys_latch & KEYMASK_(KEY_BOOST - 1)) {
|
||||
|
|
Loading…
Reference in New Issue