GPU: Instead of using fixed double-buffered output framebuffers, allow clients to request any number of framebuffer pages between 1 and 8.

- For all non-Cocoa ports, reduce the number of framebuffer pages from 2 to 1, reducing the memory usage for those ports.
- For the Cocoa port, increase the number of framebuffer pages from 2 to 3 in preparation for a new triple-buffered display scheme.
This commit is contained in:
rogerman 2017-12-19 14:33:48 -08:00
parent d3b628af47
commit 4c01e66a8a
7 changed files with 363 additions and 466 deletions

View File

@ -7413,8 +7413,9 @@ GPUSubsystem::GPUSubsystem()
_displayInfo.customWidth = GPU_FRAMEBUFFER_NATIVE_WIDTH;
_displayInfo.customHeight = GPU_FRAMEBUFFER_NATIVE_HEIGHT;
_displayInfo.framebufferSize = ((GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT) + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT)) * 2 * _displayInfo.pixelBytes;
_masterFramebuffer = malloc_alignedPage(_displayInfo.framebufferSize * 2);
_displayInfo.framebufferPageSize = ((GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT) + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT)) * 2 * _displayInfo.pixelBytes;
_displayInfo.framebufferPageCount = 1;
_masterFramebuffer = malloc_alignedPage(_displayInfo.framebufferPageSize * _displayInfo.framebufferPageCount);
_displayInfo.masterFramebufferHead = _masterFramebuffer;
_displayInfo.isDisplayEnabled[NDSDisplayID_Main] = true;
@ -7615,13 +7616,13 @@ void GPUSubsystem::UpdateRenderProperties()
this->_engineSub->isLineOutputNative[l] = true;
}
this->_displayInfo.bufferIndex = (this->_displayInfo.bufferIndex + 1) & 0x01;
this->_displayInfo.bufferIndex = (this->_displayInfo.bufferIndex + 1) % this->_displayInfo.framebufferPageCount;
const size_t nativeFramebufferSize = GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * this->_displayInfo.pixelBytes;
const size_t customFramebufferSize = this->_displayInfo.customWidth * this->_displayInfo.customHeight * this->_displayInfo.pixelBytes;
this->_displayInfo.masterNativeBuffer = (u8 *)this->_masterFramebuffer + (this->_displayInfo.bufferIndex * this->_displayInfo.framebufferSize);
this->_displayInfo.masterCustomBuffer = (u8 *)this->_masterFramebuffer + (nativeFramebufferSize * 2) + (this->_displayInfo.bufferIndex * this->_displayInfo.framebufferSize);
this->_displayInfo.masterNativeBuffer = (u8 *)this->_masterFramebuffer + (this->_displayInfo.bufferIndex * this->_displayInfo.framebufferPageSize);
this->_displayInfo.masterCustomBuffer = (u8 *)this->_masterFramebuffer + (nativeFramebufferSize * 2) + (this->_displayInfo.bufferIndex * this->_displayInfo.framebufferPageSize);
this->_displayInfo.nativeBuffer[NDSDisplayID_Main] = this->_displayInfo.masterNativeBuffer;
this->_displayInfo.customBuffer[NDSDisplayID_Main] = this->_displayInfo.masterCustomBuffer;
this->_displayInfo.nativeBuffer[NDSDisplayID_Touch] = (u8 *)this->_displayInfo.masterNativeBuffer + nativeFramebufferSize;
@ -7715,6 +7716,21 @@ NDSDisplay* GPUSubsystem::GetDisplayTouch()
return this->_display[NDSDisplayID_Touch];
}
size_t GPUSubsystem::GetFramebufferPageCount() const
{
return this->_displayInfo.framebufferPageCount;
}
void GPUSubsystem::SetFramebufferPageCount(size_t pageCount)
{
if (pageCount > MAX_FRAMEBUFFER_PAGES)
{
pageCount = MAX_FRAMEBUFFER_PAGES;
}
this->_displayInfo.framebufferPageCount = pageCount;
}
size_t GPUSubsystem::GetCustomFramebufferWidth() const
{
return this->_displayInfo.customWidth;
@ -7837,7 +7853,7 @@ void GPUSubsystem::SetCustomFramebufferSize(size_t w, size_t h)
this->_engineMain->ResetCaptureLineStates();
}
this->_AllocateFramebuffers(this->_displayInfo.colorFormat, w, h);
this->_AllocateFramebuffers(this->_displayInfo.colorFormat, w, h, this->_displayInfo.framebufferPageCount);
free_aligned(oldGpuDstToSrcIndexPtr);
free_aligned(oldGpuDstToSrcSSSE3_u8_8e);
@ -7846,6 +7862,11 @@ void GPUSubsystem::SetCustomFramebufferSize(size_t w, size_t h)
free_aligned(oldGpuDstToSrcSSSE3_u32_4e);
}
NDSColorFormat GPUSubsystem::GetColorFormat() const
{
return this->_displayInfo.colorFormat;
}
void GPUSubsystem::SetColorFormat(const NDSColorFormat outputFormat)
{
if (this->_displayInfo.colorFormat == outputFormat)
@ -7864,15 +7885,10 @@ void GPUSubsystem::SetColorFormat(const NDSColorFormat outputFormat)
this->_engineMain->ResetCaptureLineStates();
}
this->_AllocateFramebuffers(this->_displayInfo.colorFormat, this->_displayInfo.customWidth, this->_displayInfo.customHeight);
this->_AllocateFramebuffers(this->_displayInfo.colorFormat, this->_displayInfo.customWidth, this->_displayInfo.customHeight, this->_displayInfo.framebufferPageCount);
}
NDSColorFormat GPUSubsystem::GetColorFormat() const
{
return this->_displayInfo.colorFormat;
}
void GPUSubsystem::_AllocateFramebuffers(NDSColorFormat outputFormat, size_t w, size_t h)
void GPUSubsystem::_AllocateFramebuffers(NDSColorFormat outputFormat, size_t w, size_t h, size_t pageCount)
{
void *oldMasterFramebuffer = this->_masterFramebuffer;
void *oldCustomVRAM = this->_customVRAM;
@ -7885,12 +7901,13 @@ void GPUSubsystem::_AllocateFramebuffers(NDSColorFormat outputFormat, size_t w,
void *newCustomVRAM = NULL;
this->_displayInfo.framebufferSize = (nativeFramebufferSize * 2) + (customFramebufferSize * 2);
this->_masterFramebuffer = malloc_alignedPage(this->_displayInfo.framebufferSize * 2);
this->_displayInfo.framebufferPageCount = pageCount;
this->_displayInfo.framebufferPageSize = (nativeFramebufferSize * 2) + (customFramebufferSize * 2);
this->_masterFramebuffer = malloc_alignedPage(this->_displayInfo.framebufferPageSize * this->_displayInfo.framebufferPageCount);
this->_displayInfo.masterFramebufferHead = this->_masterFramebuffer;
this->_displayInfo.masterNativeBuffer = (u8 *)this->_masterFramebuffer + (this->_displayInfo.bufferIndex * this->_displayInfo.framebufferSize);
this->_displayInfo.masterCustomBuffer = (u8 *)this->_masterFramebuffer + (nativeFramebufferSize * 2) + (this->_displayInfo.bufferIndex * this->_displayInfo.framebufferSize);
this->_displayInfo.masterNativeBuffer = (u8 *)this->_masterFramebuffer + (this->_displayInfo.bufferIndex * this->_displayInfo.framebufferPageSize);
this->_displayInfo.masterCustomBuffer = (u8 *)this->_masterFramebuffer + (nativeFramebufferSize * 2) + (this->_displayInfo.bufferIndex * this->_displayInfo.framebufferPageSize);
this->_displayInfo.nativeBuffer[NDSDisplayID_Main] = this->_displayInfo.masterNativeBuffer;
this->_displayInfo.customBuffer[NDSDisplayID_Main] = this->_displayInfo.masterCustomBuffer;
@ -7928,7 +7945,7 @@ void GPUSubsystem::_AllocateFramebuffers(NDSColorFormat outputFormat, size_t w,
case NDSColorFormat_BGR555_Rev:
newCustomVRAM = (void *)malloc_alignedCacheLine(((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(u16));
memset(newCustomVRAM, 0, ((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(u16));
memset_u16(this->_masterFramebuffer, 0x8000, (this->_displayInfo.framebufferSize * 2) / sizeof(u16));
memset_u16(this->_masterFramebuffer, 0x8000, (this->_displayInfo.framebufferPageSize * this->_displayInfo.framebufferPageCount) / sizeof(u16));
this->_customVRAM = newCustomVRAM;
this->_customVRAMBlank = (u16 *)newCustomVRAM + (newCustomVRAMBlockSize * 4);
break;
@ -7936,7 +7953,7 @@ void GPUSubsystem::_AllocateFramebuffers(NDSColorFormat outputFormat, size_t w,
case NDSColorFormat_BGR666_Rev:
newCustomVRAM = (void *)malloc_alignedCacheLine(((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(u16));
memset(newCustomVRAM, 0, ((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(u16));
memset_u32(this->_masterFramebuffer, 0x1F000000, (this->_displayInfo.framebufferSize * 2) / sizeof(FragmentColor));
memset_u32(this->_masterFramebuffer, 0x1F000000, (this->_displayInfo.framebufferPageSize * this->_displayInfo.framebufferPageCount) / sizeof(FragmentColor));
this->_customVRAM = newCustomVRAM;
this->_customVRAMBlank = (u16 *)newCustomVRAM + (newCustomVRAMBlockSize * 4);
break;
@ -7944,7 +7961,7 @@ void GPUSubsystem::_AllocateFramebuffers(NDSColorFormat outputFormat, size_t w,
case NDSColorFormat_BGR888_Rev:
newCustomVRAM = (void *)malloc_alignedCacheLine(((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(FragmentColor));
memset(newCustomVRAM, 0, ((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(FragmentColor));
memset_u32(this->_masterFramebuffer, 0xFF000000, (this->_displayInfo.framebufferSize * 2) / sizeof(FragmentColor));
memset_u32(this->_masterFramebuffer, 0xFF000000, (this->_displayInfo.framebufferPageSize * this->_displayInfo.framebufferPageCount) / sizeof(FragmentColor));
this->_customVRAM = newCustomVRAM;
this->_customVRAMBlank = (FragmentColor *)newCustomVRAM + (newCustomVRAMBlockSize * 4);
break;
@ -8154,18 +8171,18 @@ void GPUSubsystem::RenderLine(const size_t l)
{
if (!this->_frameNeedsFinish)
{
u8 targetBufferIndex = this->_displayInfo.bufferIndex;
if ( (l == 0) && !this->_willFrameSkip )
{
targetBufferIndex = (targetBufferIndex + 1) & 0x01;
}
this->_event->DidApplyGPUSettingsBegin();
this->_engineMain->ApplySettings();
this->_engineSub->ApplySettings();
this->_event->DidApplyGPUSettingsEnd();
u8 targetBufferIndex = this->_displayInfo.bufferIndex;
if ( (l == 0) && !this->_willFrameSkip )
{
targetBufferIndex = (targetBufferIndex + 1) % this->_displayInfo.framebufferPageCount;
}
this->_event->DidFrameBegin(this->_willFrameSkip, targetBufferIndex, l);
this->_frameNeedsFinish = true;
}
@ -8346,11 +8363,11 @@ void GPUSubsystem::ClearWithColor(const u16 colorBGRA5551)
switch (this->_displayInfo.pixelBytes)
{
case 2:
memset_u16(this->_masterFramebuffer, color16, (this->_displayInfo.framebufferSize * 2) / this->_displayInfo.pixelBytes);
memset_u16(this->_masterFramebuffer, color16, (this->_displayInfo.framebufferPageSize * this->_displayInfo.framebufferPageCount) / this->_displayInfo.pixelBytes);
break;
case 4:
memset_u32(this->_masterFramebuffer, color32.color, (this->_displayInfo.framebufferSize * 2) / this->_displayInfo.pixelBytes);
memset_u32(this->_masterFramebuffer, color32.color, (this->_displayInfo.framebufferPageSize * this->_displayInfo.framebufferPageCount) / this->_displayInfo.pixelBytes);
break;
default:
@ -8360,8 +8377,11 @@ void GPUSubsystem::ClearWithColor(const u16 colorBGRA5551)
GPUClientFetchObject::GPUClientFetchObject()
{
memset(&_fetchDisplayInfo[0], 0, sizeof(NDSDisplayInfo));
memset(&_fetchDisplayInfo[1], 0, sizeof(NDSDisplayInfo));
for (size_t i = 0; i < MAX_FRAMEBUFFER_PAGES; i++)
{
memset(&_fetchDisplayInfo[i], 0, sizeof(NDSDisplayInfo));
}
_clientData = NULL;
_lastFetchIndex = 0;
}
@ -8373,7 +8393,28 @@ void GPUClientFetchObject::Init()
void GPUClientFetchObject::SetFetchBuffers(const NDSDisplayInfo &currentDisplayInfo)
{
// Do nothing. This is implementation dependent.
const size_t nativeSize = GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * currentDisplayInfo.pixelBytes;
const size_t customSize = currentDisplayInfo.customWidth * currentDisplayInfo.customHeight * currentDisplayInfo.pixelBytes;
for (size_t i = 0; i < currentDisplayInfo.framebufferPageCount; i++)
{
this->_fetchDisplayInfo[i] = currentDisplayInfo;
if (i == 0)
{
this->_fetchDisplayInfo[0].nativeBuffer[NDSDisplayID_Main] = (u8 *)currentDisplayInfo.masterFramebufferHead;
this->_fetchDisplayInfo[0].nativeBuffer[NDSDisplayID_Touch] = (u8 *)currentDisplayInfo.masterFramebufferHead + (nativeSize * 1);
this->_fetchDisplayInfo[0].customBuffer[NDSDisplayID_Main] = (u8 *)currentDisplayInfo.masterFramebufferHead + (nativeSize * 2);
this->_fetchDisplayInfo[0].customBuffer[NDSDisplayID_Touch] = (u8 *)currentDisplayInfo.masterFramebufferHead + (nativeSize * 2) + customSize;
}
else
{
this->_fetchDisplayInfo[i].nativeBuffer[NDSDisplayID_Main] = (u8 *)this->_fetchDisplayInfo[0].nativeBuffer[NDSDisplayID_Main] + (currentDisplayInfo.framebufferPageSize * i);
this->_fetchDisplayInfo[i].nativeBuffer[NDSDisplayID_Touch] = (u8 *)this->_fetchDisplayInfo[0].nativeBuffer[NDSDisplayID_Touch] + (currentDisplayInfo.framebufferPageSize * i);
this->_fetchDisplayInfo[i].customBuffer[NDSDisplayID_Main] = (u8 *)this->_fetchDisplayInfo[0].customBuffer[NDSDisplayID_Main] + (currentDisplayInfo.framebufferPageSize * i);
this->_fetchDisplayInfo[i].customBuffer[NDSDisplayID_Touch] = (u8 *)this->_fetchDisplayInfo[0].customBuffer[NDSDisplayID_Touch] + (currentDisplayInfo.framebufferPageSize * i);
}
}
}
void GPUClientFetchObject::FetchFromBufferIndex(const u8 index)

View File

@ -69,6 +69,8 @@ struct Render3DInterface;
#define GPU_VRAM_BLOCK_LINES 256
#define GPU_VRAM_BLANK_REGION_LINES 544
#define MAX_FRAMEBUFFER_PAGES 8
void gpu_savestate(EMUFILE &os);
bool gpu_loadstate(EMUFILE &is, int size);
@ -1141,10 +1143,11 @@ typedef struct
// false - The user requested the native size.
size_t customWidth; // The requested custom width, measured in pixels.
size_t customHeight; // The requested custom height, measured in pixels.
size_t framebufferSize; // The size of a single framebuffer, which includes the native and custom buffers of both displays,
// measured in bytes.
size_t framebufferPageSize; // The size of a single framebuffer page, which includes the native and custom buffers of both
// displays, measured in bytes.
// Changed by calling GPUSubsystem::SetColorFormat() or GPUSubsystem::SetFramebufferSize().
size_t framebufferPageCount; // The number of framebuffer pages that were requested by the client.
void *masterFramebufferHead; // Pointer to the head of the master framebuffer memory block that encompasses all buffers.
// Changed by calling GPUEngineBase::SetEnableState().
@ -1773,7 +1776,7 @@ private:
NDSDisplayInfo _displayInfo;
void _UpdateFPSRender3D();
void _AllocateFramebuffers(NDSColorFormat outputFormat, size_t w, size_t h);
void _AllocateFramebuffers(NDSColorFormat outputFormat, size_t w, size_t h, size_t pageCount);
public:
GPUSubsystem();
@ -1798,11 +1801,15 @@ public:
void* GetCustomVRAMBlankBuffer();
template<NDSColorFormat COLORFORMAT> void* GetCustomVRAMAddressUsingMappedAddress(const u32 addr, const size_t offset);
size_t GetFramebufferPageCount() const;
void SetFramebufferPageCount(size_t pageCount);
size_t GetCustomFramebufferWidth() const;
size_t GetCustomFramebufferHeight() const;
void SetCustomFramebufferSize(size_t w, size_t h);
void SetColorFormat(const NDSColorFormat outputFormat);
NDSColorFormat GetColorFormat() const;
void SetColorFormat(const NDSColorFormat outputFormat);
int Get3DRendererID();
void Set3DRendererByID(int rendererID);
@ -1856,7 +1863,7 @@ public:
class GPUClientFetchObject
{
protected:
NDSDisplayInfo _fetchDisplayInfo[2];
NDSDisplayInfo _fetchDisplayInfo[MAX_FRAMEBUFFER_PAGES];
volatile u8 _lastFetchIndex;
void *_clientData;

View File

@ -4546,25 +4546,23 @@ OGLClientFetchObject::OGLClientFetchObject()
_useDirectToCPUFilterPipeline = true;
_fetchColorFormatOGL = GL_UNSIGNED_SHORT_1_5_5_5_REV;
pthread_rwlock_init(&_srcCloneRWLock[NDSDisplayID_Main][0], NULL);
pthread_rwlock_init(&_srcCloneRWLock[NDSDisplayID_Touch][0], NULL);
pthread_rwlock_init(&_srcCloneRWLock[NDSDisplayID_Main][1], NULL);
pthread_rwlock_init(&_srcCloneRWLock[NDSDisplayID_Touch][1], NULL);
pthread_rwlock_init(&_texFetchRWLock[NDSDisplayID_Main], NULL);
pthread_rwlock_init(&_texFetchRWLock[NDSDisplayID_Touch], NULL);
_srcNativeCloneMaster = (uint32_t *)malloc_alignedPage(GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2 * 2 * sizeof(uint32_t));
_srcNativeClone[NDSDisplayID_Main][0] = _srcNativeCloneMaster + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 0);
_srcNativeClone[NDSDisplayID_Touch][0] = _srcNativeCloneMaster + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 1);
_srcNativeClone[NDSDisplayID_Main][1] = _srcNativeCloneMaster + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2);
_srcNativeClone[NDSDisplayID_Touch][1] = _srcNativeCloneMaster + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 3);
memset(_srcNativeCloneMaster, 0, GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2 * sizeof(uint32_t));
_srcNativeCloneMaster = (uint32_t *)malloc_alignedPage(GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2 * OPENGL_FETCH_BUFFER_COUNT * sizeof(uint32_t));
memset(_srcNativeCloneMaster, 0, GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2 * OPENGL_FETCH_BUFFER_COUNT * sizeof(uint32_t));
_srcCloneNeedsUpdate[NDSDisplayID_Main][0] = true;
_srcCloneNeedsUpdate[NDSDisplayID_Touch][0] = true;
_srcCloneNeedsUpdate[NDSDisplayID_Main][1] = true;
_srcCloneNeedsUpdate[NDSDisplayID_Touch][1] = true;
for (size_t i = 0; i < OPENGL_FETCH_BUFFER_COUNT; i++)
{
pthread_rwlock_init(&_srcCloneRWLock[NDSDisplayID_Main][i], NULL);
pthread_rwlock_init(&_srcCloneRWLock[NDSDisplayID_Touch][i], NULL);
_srcCloneNeedsUpdate[NDSDisplayID_Main][i] = true;
_srcCloneNeedsUpdate[NDSDisplayID_Touch][i] = true;
_srcNativeClone[NDSDisplayID_Main][i] = _srcNativeCloneMaster + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * ((i * 2) + 0));
_srcNativeClone[NDSDisplayID_Touch][i] = _srcNativeCloneMaster + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * ((i * 2) + 1));
}
}
OGLClientFetchObject::~OGLClientFetchObject()
@ -4577,25 +4575,24 @@ OGLClientFetchObject::~OGLClientFetchObject()
glDeleteTextures(4, &this->_texDisplayFetchNative[0][0]);
glDeleteTextures(4, &this->_texDisplayFetchCustom[0][0]);
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Main][0]);
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][0]);
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Main][1]);
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][1]);
for (size_t i = 0; i < OPENGL_FETCH_BUFFER_COUNT; i++)
{
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Main][i]);
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][i]);
this->_srcNativeClone[NDSDisplayID_Main][i] = NULL;
this->_srcNativeClone[NDSDisplayID_Touch][i] = NULL;
}
free_aligned(this->_srcNativeCloneMaster);
this->_srcNativeCloneMaster = NULL;
this->_srcNativeClone[NDSDisplayID_Main][0] = NULL;
this->_srcNativeClone[NDSDisplayID_Touch][0] = NULL;
this->_srcNativeClone[NDSDisplayID_Main][1] = NULL;
this->_srcNativeClone[NDSDisplayID_Touch][1] = NULL;
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][1]);
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Main][1]);
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][0]);
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Main][0]);
pthread_rwlock_destroy(&this->_srcCloneRWLock[NDSDisplayID_Main][0]);
pthread_rwlock_destroy(&this->_srcCloneRWLock[NDSDisplayID_Touch][0]);
pthread_rwlock_destroy(&this->_srcCloneRWLock[NDSDisplayID_Main][1]);
pthread_rwlock_destroy(&this->_srcCloneRWLock[NDSDisplayID_Touch][1]);
for (size_t i = OPENGL_FETCH_BUFFER_COUNT - 1; i < OPENGL_FETCH_BUFFER_COUNT; i--)
{
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][i]);
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Main][i]);
pthread_rwlock_destroy(&this->_srcCloneRWLock[NDSDisplayID_Touch][i]);
pthread_rwlock_destroy(&this->_srcCloneRWLock[NDSDisplayID_Main][i]);
}
pthread_rwlock_destroy(&this->_texFetchRWLock[NDSDisplayID_Main]);
pthread_rwlock_destroy(&this->_texFetchRWLock[NDSDisplayID_Touch]);
@ -4698,64 +4695,42 @@ void OGLClientFetchObject::FetchTextureUnlock(const NDSDisplayID displayID)
void OGLClientFetchObject::Init()
{
glGenTextures(4, &this->_texDisplayFetchNative[0][0]);
glGenTextures(4, &this->_texDisplayFetchCustom[0][0]);
glGenTextures(2 * OPENGL_FETCH_BUFFER_COUNT, &this->_texDisplayFetchNative[0][0]);
glGenTextures(2 * OPENGL_FETCH_BUFFER_COUNT, &this->_texDisplayFetchCustom[0][0]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchNative[NDSDisplayID_Main][0]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_srcNativeClone[NDSDisplayID_Main][0]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchNative[NDSDisplayID_Main][1]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_srcNativeClone[NDSDisplayID_Main][1]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchNative[NDSDisplayID_Touch][0]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_srcNativeClone[NDSDisplayID_Touch][0]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchNative[NDSDisplayID_Touch][1]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_srcNativeClone[NDSDisplayID_Touch][1]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchCustom[NDSDisplayID_Main][0]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_srcNativeClone[NDSDisplayID_Main][0]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchCustom[NDSDisplayID_Main][1]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_srcNativeClone[NDSDisplayID_Main][1]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchCustom[NDSDisplayID_Touch][0]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_srcNativeClone[NDSDisplayID_Touch][0]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchCustom[NDSDisplayID_Touch][1]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_srcNativeClone[NDSDisplayID_Touch][1]);
for (size_t i = 0; i < OPENGL_FETCH_BUFFER_COUNT; i++)
{
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchNative[NDSDisplayID_Main][i]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_srcNativeClone[NDSDisplayID_Main][i]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchNative[NDSDisplayID_Touch][i]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_srcNativeClone[NDSDisplayID_Touch][i]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchCustom[NDSDisplayID_Main][i]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_srcNativeClone[NDSDisplayID_Main][i]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchCustom[NDSDisplayID_Touch][i]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_srcNativeClone[NDSDisplayID_Touch][i]);
this->_srcCloneNeedsUpdate[NDSDisplayID_Main][i] = true;
this->_srcCloneNeedsUpdate[NDSDisplayID_Touch][i] = true;
}
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
@ -4766,30 +4741,11 @@ void OGLClientFetchObject::Init()
{
SetupHQnxLUTs_OGL(GL_TEXTURE0 + 1, this->_texLQ2xLUT, this->_texHQ2xLUT, this->_texHQ3xLUT, this->_texHQ4xLUT);
}
this->_srcCloneNeedsUpdate[NDSDisplayID_Main][0] = true;
this->_srcCloneNeedsUpdate[NDSDisplayID_Touch][0] = true;
this->_srcCloneNeedsUpdate[NDSDisplayID_Main][1] = true;
this->_srcCloneNeedsUpdate[NDSDisplayID_Touch][1] = true;
}
void OGLClientFetchObject::SetFetchBuffers(const NDSDisplayInfo &currentDisplayInfo)
{
const size_t nativeSize = GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * currentDisplayInfo.pixelBytes;
const size_t customSize = currentDisplayInfo.customWidth * currentDisplayInfo.customHeight * currentDisplayInfo.pixelBytes;
this->_fetchDisplayInfo[0] = currentDisplayInfo;
this->_fetchDisplayInfo[1] = currentDisplayInfo;
this->_fetchDisplayInfo[0].nativeBuffer[NDSDisplayID_Main] = (u8 *)currentDisplayInfo.masterFramebufferHead;
this->_fetchDisplayInfo[0].nativeBuffer[NDSDisplayID_Touch] = (u8 *)currentDisplayInfo.masterFramebufferHead + (nativeSize * 1);
this->_fetchDisplayInfo[0].customBuffer[NDSDisplayID_Main] = (u8 *)currentDisplayInfo.masterFramebufferHead + (nativeSize * 2);
this->_fetchDisplayInfo[0].customBuffer[NDSDisplayID_Touch] = (u8 *)currentDisplayInfo.masterFramebufferHead + (nativeSize * 2) + customSize;
this->_fetchDisplayInfo[1].nativeBuffer[NDSDisplayID_Main] = (u8 *)this->_fetchDisplayInfo[0].nativeBuffer[NDSDisplayID_Main] + currentDisplayInfo.framebufferSize;
this->_fetchDisplayInfo[1].nativeBuffer[NDSDisplayID_Touch] = (u8 *)this->_fetchDisplayInfo[0].nativeBuffer[NDSDisplayID_Touch] + currentDisplayInfo.framebufferSize;
this->_fetchDisplayInfo[1].customBuffer[NDSDisplayID_Main] = (u8 *)this->_fetchDisplayInfo[0].customBuffer[NDSDisplayID_Main] + currentDisplayInfo.framebufferSize;
this->_fetchDisplayInfo[1].customBuffer[NDSDisplayID_Touch] = (u8 *)this->_fetchDisplayInfo[0].customBuffer[NDSDisplayID_Touch] + currentDisplayInfo.framebufferSize;
this->GPUClientFetchObject::SetFetchBuffers(currentDisplayInfo);
#ifdef MSB_FIRST
this->_fetchColorFormatOGL = (currentDisplayInfo.pixelBytes == 2) ? GL_UNSIGNED_SHORT_1_5_5_5_REV : GL_UNSIGNED_INT_8_8_8_8;
@ -4799,60 +4755,39 @@ void OGLClientFetchObject::SetFetchBuffers(const NDSDisplayInfo &currentDisplayI
glFinish();
glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_ARB, currentDisplayInfo.framebufferSize * 2, currentDisplayInfo.masterFramebufferHead);
glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_ARB, currentDisplayInfo.framebufferPageSize * currentDisplayInfo.framebufferPageCount, currentDisplayInfo.masterFramebufferHead);
glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchNative[NDSDisplayID_Main][0]);
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[0].nativeBuffer[NDSDisplayID_Main]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchNative[NDSDisplayID_Main][1]);
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[1].nativeBuffer[NDSDisplayID_Main]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchNative[NDSDisplayID_Touch][0]);
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[0].nativeBuffer[NDSDisplayID_Touch]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchNative[NDSDisplayID_Touch][1]);
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[1].nativeBuffer[NDSDisplayID_Touch]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchCustom[NDSDisplayID_Main][0]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_SHARED_APPLE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, currentDisplayInfo.customWidth, currentDisplayInfo.customHeight, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_fetchDisplayInfo[0].customBuffer[NDSDisplayID_Main]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchCustom[NDSDisplayID_Main][1]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_SHARED_APPLE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, currentDisplayInfo.customWidth, currentDisplayInfo.customHeight, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_fetchDisplayInfo[1].customBuffer[NDSDisplayID_Main]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchCustom[NDSDisplayID_Touch][0]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_SHARED_APPLE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, currentDisplayInfo.customWidth, currentDisplayInfo.customHeight, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_fetchDisplayInfo[0].customBuffer[NDSDisplayID_Touch]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchCustom[NDSDisplayID_Touch][1]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_SHARED_APPLE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, currentDisplayInfo.customWidth, currentDisplayInfo.customHeight, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_fetchDisplayInfo[1].customBuffer[NDSDisplayID_Touch]);
for (size_t i = 0; i < currentDisplayInfo.framebufferPageCount; i++)
{
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]);
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]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchCustom[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, currentDisplayInfo.customWidth, currentDisplayInfo.customHeight, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_fetchDisplayInfo[i].customBuffer[NDSDisplayID_Main]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texDisplayFetchCustom[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, currentDisplayInfo.customWidth, currentDisplayInfo.customHeight, 0, GL_RGBA, this->_fetchColorFormatOGL, this->_fetchDisplayInfo[i].customBuffer[NDSDisplayID_Touch]);
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Main][i]);
this->_srcCloneNeedsUpdate[NDSDisplayID_Main][i] = true;
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Main][i]);
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][i]);
this->_srcCloneNeedsUpdate[NDSDisplayID_Touch][i] = true;
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][i]);
}
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
glFinish();
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Main][0]);
this->_srcCloneNeedsUpdate[NDSDisplayID_Main][0] = true;
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Main][0]);
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][0]);
this->_srcCloneNeedsUpdate[NDSDisplayID_Touch][0] = true;
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][0]);
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Main][1]);
this->_srcCloneNeedsUpdate[NDSDisplayID_Main][1] = true;
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Main][1]);
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][1]);
this->_srcCloneNeedsUpdate[NDSDisplayID_Touch][1] = true;
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][1]);
}
void OGLClientFetchObject::FetchFromBufferIndex(const u8 index)

View File

@ -35,6 +35,7 @@
#include "ClientDisplayView.h"
#define OPENGL_FETCH_BUFFER_COUNT 3
class OGLVideoOutput;
@ -342,8 +343,8 @@ class OGLClientFetchObject : public GPUClientFetchObject
protected:
OGLContextInfo *_contextInfo;
GLenum _fetchColorFormatOGL;
GLuint _texDisplayFetchNative[2][2];
GLuint _texDisplayFetchCustom[2][2];
GLuint _texDisplayFetchNative[2][OPENGL_FETCH_BUFFER_COUNT];
GLuint _texDisplayFetchCustom[2][OPENGL_FETCH_BUFFER_COUNT];
GLuint _texLQ2xLUT;
GLuint _texHQ2xLUT;
@ -354,10 +355,10 @@ protected:
bool _useDirectToCPUFilterPipeline;
uint32_t *_srcNativeCloneMaster;
uint32_t *_srcNativeClone[2][2];
pthread_rwlock_t _srcCloneRWLock[2][2];
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][2];
bool _srcCloneNeedsUpdate[2][OPENGL_FETCH_BUFFER_COUNT];
virtual void _FetchNativeDisplayByID(const NDSDisplayID displayID, const u8 bufferIndex);
virtual void _FetchCustomDisplayByID(const NDSDisplayID displayID, const u8 bufferIndex);

View File

@ -173,6 +173,7 @@ public:
}
else
{
GPU->SetFramebufferPageCount(METAL_FETCH_BUFFER_COUNT);
GPU->SetWillPostprocessDisplays(false);
}
}
@ -187,6 +188,7 @@ public:
fetchObject->Init();
gpuEvent->SetFetchObject(fetchObject);
GPU->SetFramebufferPageCount(OPENGL_FETCH_BUFFER_COUNT);
GPU->SetWillAutoResolveToCustomBuffer(false);
#endif

View File

@ -35,7 +35,8 @@
#undef BOOL
#endif
#define RENDER_BUFFER_COUNT 4
#define METAL_FETCH_BUFFER_COUNT 3
#define RENDER_BUFFER_COUNT 4
enum ClientDisplayBufferState
{
@ -104,11 +105,11 @@ typedef DisplayViewShaderProperties DisplayViewShaderProperties;
id<MTLSamplerState> samplerHUDText;
id<MTLBuffer> hudIndexBuffer;
id<MTLBuffer> _bufDisplayFetchNative[2][2];
id<MTLBuffer> _bufDisplayFetchCustom[2][2];
id<MTLBuffer> _bufDisplayFetchNative[2][METAL_FETCH_BUFFER_COUNT];
id<MTLBuffer> _bufDisplayFetchCustom[2][METAL_FETCH_BUFFER_COUNT];
id<MTLBuffer> _bufMasterBrightMode[2][2];
id<MTLBuffer> _bufMasterBrightIntensity[2][2];
id<MTLBuffer> _bufMasterBrightMode[2][METAL_FETCH_BUFFER_COUNT];
id<MTLBuffer> _bufMasterBrightIntensity[2][METAL_FETCH_BUFFER_COUNT];
size_t _fetchPixelBytes;
size_t _nativeLineSize;
@ -116,10 +117,10 @@ typedef DisplayViewShaderProperties DisplayViewShaderProperties;
size_t _customLineSize;
size_t _customBufferSize;
id<MTLTexture> _texDisplayFetchNative[2][2];
id<MTLTexture> _texDisplayFetchCustom[2][2];
id<MTLTexture> _texDisplayPostprocessNative[2][2];
id<MTLTexture> _texDisplayPostprocessCustom[2][2];
id<MTLTexture> _texDisplayFetchNative[2][METAL_FETCH_BUFFER_COUNT];
id<MTLTexture> _texDisplayFetchCustom[2][METAL_FETCH_BUFFER_COUNT];
id<MTLTexture> _texDisplayPostprocessNative[2][METAL_FETCH_BUFFER_COUNT];
id<MTLTexture> _texDisplayPostprocessCustom[2][METAL_FETCH_BUFFER_COUNT];
MetalTexturePair texPairFetch;
id<MTLBlitCommandEncoder> bceFetch;
@ -281,8 +282,8 @@ class MacMetalFetchObject : public GPUClientFetchObject
protected:
bool _useDirectToCPUFilterPipeline;
uint32_t *_srcNativeCloneMaster;
uint32_t *_srcNativeClone[2][2];
pthread_rwlock_t _srcCloneRWLock[2][2];
uint32_t *_srcNativeClone[2][METAL_FETCH_BUFFER_COUNT];
pthread_rwlock_t _srcCloneRWLock[2][METAL_FETCH_BUFFER_COUNT];
virtual void _FetchNativeDisplayByID(const NDSDisplayID displayID, const u8 bufferIndex);
virtual void _FetchCustomDisplayByID(const NDSDisplayID displayID, const u8 bufferIndex);

View File

@ -163,24 +163,6 @@
[cb waitUntilCompleted];
[tempHUDIndexBuffer release];
_bufDisplayFetchNative[NDSDisplayID_Main][0] = nil;
_bufDisplayFetchNative[NDSDisplayID_Main][1] = nil;
_bufDisplayFetchNative[NDSDisplayID_Touch][0] = nil;
_bufDisplayFetchNative[NDSDisplayID_Touch][1] = nil;
_bufDisplayFetchCustom[NDSDisplayID_Main][0] = nil;
_bufDisplayFetchCustom[NDSDisplayID_Main][1] = nil;
_bufDisplayFetchCustom[NDSDisplayID_Touch][0] = nil;
_bufDisplayFetchCustom[NDSDisplayID_Touch][1] = nil;
_bufMasterBrightMode[NDSDisplayID_Main][0] = [device newBufferWithLength:sizeof(uint8_t) * GPU_FRAMEBUFFER_NATIVE_HEIGHT options:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
_bufMasterBrightMode[NDSDisplayID_Main][1] = [device newBufferWithLength:sizeof(uint8_t) * GPU_FRAMEBUFFER_NATIVE_HEIGHT options:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
_bufMasterBrightMode[NDSDisplayID_Touch][0] = [device newBufferWithLength:sizeof(uint8_t) * GPU_FRAMEBUFFER_NATIVE_HEIGHT options:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
_bufMasterBrightMode[NDSDisplayID_Touch][1] = [device newBufferWithLength:sizeof(uint8_t) * GPU_FRAMEBUFFER_NATIVE_HEIGHT options:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
_bufMasterBrightIntensity[NDSDisplayID_Main][0] = [device newBufferWithLength:sizeof(uint8_t) * GPU_FRAMEBUFFER_NATIVE_HEIGHT options:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
_bufMasterBrightIntensity[NDSDisplayID_Main][1] = [device newBufferWithLength:sizeof(uint8_t) * GPU_FRAMEBUFFER_NATIVE_HEIGHT options:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
_bufMasterBrightIntensity[NDSDisplayID_Touch][0] = [device newBufferWithLength:sizeof(uint8_t) * GPU_FRAMEBUFFER_NATIVE_HEIGHT options:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
_bufMasterBrightIntensity[NDSDisplayID_Touch][1] = [device newBufferWithLength:sizeof(uint8_t) * GPU_FRAMEBUFFER_NATIVE_HEIGHT options:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
// Set up HUD texture samplers.
MTLSamplerDescriptor *samplerDesc = [[MTLSamplerDescriptor alloc] init];
[samplerDesc setNormalizedCoordinates:YES];
@ -219,16 +201,6 @@
[newTexDisplayDesc setCpuCacheMode:MTLCPUCacheModeWriteCombined];
[newTexDisplayDesc setUsage:MTLTextureUsageShaderRead];
_texDisplayFetchNative[NDSDisplayID_Main][0] = [device newTextureWithDescriptor:newTexDisplayDesc];
_texDisplayFetchNative[NDSDisplayID_Main][1] = [device newTextureWithDescriptor:newTexDisplayDesc];
_texDisplayFetchNative[NDSDisplayID_Touch][0] = [device newTextureWithDescriptor:newTexDisplayDesc];
_texDisplayFetchNative[NDSDisplayID_Touch][1] = [device newTextureWithDescriptor:newTexDisplayDesc];
_texDisplayFetchCustom[NDSDisplayID_Main][0] = [device newTextureWithDescriptor:newTexDisplayDesc];
_texDisplayFetchCustom[NDSDisplayID_Main][1] = [device newTextureWithDescriptor:newTexDisplayDesc];
_texDisplayFetchCustom[NDSDisplayID_Touch][0] = [device newTextureWithDescriptor:newTexDisplayDesc];
_texDisplayFetchCustom[NDSDisplayID_Touch][1] = [device newTextureWithDescriptor:newTexDisplayDesc];
MTLTextureDescriptor *newTexPostprocessDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
width:GPU_FRAMEBUFFER_NATIVE_WIDTH
height:GPU_FRAMEBUFFER_NATIVE_HEIGHT
@ -237,15 +209,28 @@
[newTexPostprocessDesc setStorageMode:MTLStorageModePrivate];
[newTexPostprocessDesc setUsage:MTLTextureUsageShaderRead | MTLTextureUsageShaderWrite];
_texDisplayPostprocessNative[NDSDisplayID_Main][0] = [device newTextureWithDescriptor:newTexPostprocessDesc];
_texDisplayPostprocessNative[NDSDisplayID_Main][1] = [device newTextureWithDescriptor:newTexPostprocessDesc];
_texDisplayPostprocessNative[NDSDisplayID_Touch][0] = [device newTextureWithDescriptor:newTexPostprocessDesc];
_texDisplayPostprocessNative[NDSDisplayID_Touch][1] = [device newTextureWithDescriptor:newTexPostprocessDesc];
_texDisplayPostprocessCustom[NDSDisplayID_Main][0] = [device newTextureWithDescriptor:newTexPostprocessDesc];
_texDisplayPostprocessCustom[NDSDisplayID_Main][1] = [device newTextureWithDescriptor:newTexPostprocessDesc];
_texDisplayPostprocessCustom[NDSDisplayID_Touch][0] = [device newTextureWithDescriptor:newTexPostprocessDesc];
_texDisplayPostprocessCustom[NDSDisplayID_Touch][1] = [device newTextureWithDescriptor:newTexPostprocessDesc];
for (size_t i = 0; i < METAL_FETCH_BUFFER_COUNT; i++)
{
_bufDisplayFetchNative[NDSDisplayID_Main][i] = nil;
_bufDisplayFetchNative[NDSDisplayID_Touch][i] = nil;
_bufDisplayFetchCustom[NDSDisplayID_Main][i] = nil;
_bufDisplayFetchCustom[NDSDisplayID_Touch][i] = nil;
_bufMasterBrightMode[NDSDisplayID_Main][i] = [device newBufferWithLength:sizeof(uint8_t) * GPU_FRAMEBUFFER_NATIVE_HEIGHT options:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
_bufMasterBrightMode[NDSDisplayID_Touch][i] = [device newBufferWithLength:sizeof(uint8_t) * GPU_FRAMEBUFFER_NATIVE_HEIGHT options:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
_bufMasterBrightIntensity[NDSDisplayID_Main][i] = [device newBufferWithLength:sizeof(uint8_t) * GPU_FRAMEBUFFER_NATIVE_HEIGHT options:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
_bufMasterBrightIntensity[NDSDisplayID_Touch][i] = [device newBufferWithLength:sizeof(uint8_t) * GPU_FRAMEBUFFER_NATIVE_HEIGHT options:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
_texDisplayFetchNative[NDSDisplayID_Main][i] = [device newTextureWithDescriptor:newTexDisplayDesc];
_texDisplayFetchNative[NDSDisplayID_Touch][i] = [device newTextureWithDescriptor:newTexDisplayDesc];
_texDisplayFetchCustom[NDSDisplayID_Main][i] = [device newTextureWithDescriptor:newTexDisplayDesc];
_texDisplayFetchCustom[NDSDisplayID_Touch][i] = [device newTextureWithDescriptor:newTexDisplayDesc];
_texDisplayPostprocessNative[NDSDisplayID_Main][i] = [device newTextureWithDescriptor:newTexPostprocessDesc];
_texDisplayPostprocessNative[NDSDisplayID_Touch][i] = [device newTextureWithDescriptor:newTexPostprocessDesc];
_texDisplayPostprocessCustom[NDSDisplayID_Main][i] = [device newTextureWithDescriptor:newTexPostprocessDesc];
_texDisplayPostprocessCustom[NDSDisplayID_Touch][i] = [device newTextureWithDescriptor:newTexPostprocessDesc];
}
texPairFetch.main = [_texDisplayPostprocessNative[NDSDisplayID_Main][0] retain];
texPairFetch.touch = [_texDisplayPostprocessNative[NDSDisplayID_Touch][0] retain];
@ -274,34 +259,28 @@
[hudRGBAPipeline release];
[hudIndexBuffer release];
[_bufMasterBrightMode[NDSDisplayID_Main][0] release];
[_bufMasterBrightMode[NDSDisplayID_Main][1] release];
[_bufMasterBrightMode[NDSDisplayID_Touch][0] release];
[_bufMasterBrightMode[NDSDisplayID_Touch][1] release];
[_bufMasterBrightIntensity[NDSDisplayID_Main][0] release];
[_bufMasterBrightIntensity[NDSDisplayID_Main][1] release];
[_bufMasterBrightIntensity[NDSDisplayID_Touch][0] release];
[_bufMasterBrightIntensity[NDSDisplayID_Touch][1] release];
[_texDisplayFetchNative[NDSDisplayID_Main][0] release];
[_texDisplayFetchNative[NDSDisplayID_Main][1] release];
[_texDisplayFetchNative[NDSDisplayID_Touch][0] release];
[_texDisplayFetchNative[NDSDisplayID_Touch][1] release];
[_texDisplayFetchCustom[NDSDisplayID_Main][0] release];
[_texDisplayFetchCustom[NDSDisplayID_Main][1] release];
[_texDisplayFetchCustom[NDSDisplayID_Touch][0] release];
[_texDisplayFetchCustom[NDSDisplayID_Touch][1] release];
[_texDisplayPostprocessNative[NDSDisplayID_Main][0] release];
[_texDisplayPostprocessNative[NDSDisplayID_Main][1] release];
[_texDisplayPostprocessNative[NDSDisplayID_Touch][0] release];
[_texDisplayPostprocessNative[NDSDisplayID_Touch][1] release];
[_texDisplayPostprocessCustom[NDSDisplayID_Main][0] release];
[_texDisplayPostprocessCustom[NDSDisplayID_Main][1] release];
[_texDisplayPostprocessCustom[NDSDisplayID_Touch][0] release];
[_texDisplayPostprocessCustom[NDSDisplayID_Touch][1] release];
for (size_t i = 0; i < METAL_FETCH_BUFFER_COUNT; i++)
{
[_bufDisplayFetchNative[NDSDisplayID_Main][i] release];
[_bufDisplayFetchNative[NDSDisplayID_Touch][i] release];
[_bufDisplayFetchCustom[NDSDisplayID_Main][i] release];
[_bufDisplayFetchCustom[NDSDisplayID_Touch][i] release];
[_bufMasterBrightMode[NDSDisplayID_Main][i] release];
[_bufMasterBrightMode[NDSDisplayID_Touch][i] release];
[_bufMasterBrightIntensity[NDSDisplayID_Main][i] release];
[_bufMasterBrightIntensity[NDSDisplayID_Touch][i] release];
[_texDisplayFetchNative[NDSDisplayID_Main][i] release];
[_texDisplayFetchNative[NDSDisplayID_Touch][i] release];
[_texDisplayFetchCustom[NDSDisplayID_Main][i] release];
[_texDisplayFetchCustom[NDSDisplayID_Touch][i] release];
[_texDisplayPostprocessNative[NDSDisplayID_Main][i] release];
[_texDisplayPostprocessNative[NDSDisplayID_Touch][i] release];
[_texDisplayPostprocessCustom[NDSDisplayID_Main][i] release];
[_texDisplayPostprocessCustom[NDSDisplayID_Touch][i] release];
}
[texPairFetch.main release];
[texPairFetch.touch release];
@ -311,15 +290,6 @@
[samplerHUDBox release];
[samplerHUDText release];
[_bufDisplayFetchNative[NDSDisplayID_Main][0] release];
[_bufDisplayFetchNative[NDSDisplayID_Main][1] release];
[_bufDisplayFetchNative[NDSDisplayID_Touch][0] release];
[_bufDisplayFetchNative[NDSDisplayID_Touch][1] release];
[_bufDisplayFetchCustom[NDSDisplayID_Main][0] release];
[_bufDisplayFetchCustom[NDSDisplayID_Main][1] release];
[_bufDisplayFetchCustom[NDSDisplayID_Touch][0] release];
[_bufDisplayFetchCustom[NDSDisplayID_Touch][1] release];
[super dealloc];
}
@ -334,162 +304,119 @@
_customLineSize = w * dispInfo.pixelBytes;
_customBufferSize = h * _customLineSize;
const NDSDisplayInfo &dispInfo0 = GPUFetchObject->GetFetchDisplayInfoForBufferIndex(0);
const NDSDisplayInfo &dispInfo1 = GPUFetchObject->GetFetchDisplayInfoForBufferIndex(1);
MTLTextureDescriptor *newTexDisplayNativeDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:(dispInfo.colorFormat == NDSColorFormat_BGR555_Rev) ? MTLPixelFormatR16Uint : MTLPixelFormatRGBA8Unorm
width:GPU_FRAMEBUFFER_NATIVE_WIDTH
height:GPU_FRAMEBUFFER_NATIVE_HEIGHT
mipmapped:NO];
[_bufDisplayFetchNative[NDSDisplayID_Main][0] release];
[_bufDisplayFetchNative[NDSDisplayID_Main][1] release];
[_bufDisplayFetchNative[NDSDisplayID_Touch][0] release];
[_bufDisplayFetchNative[NDSDisplayID_Touch][1] release];
[_bufDisplayFetchCustom[NDSDisplayID_Main][0] release];
[_bufDisplayFetchCustom[NDSDisplayID_Main][1] release];
[_bufDisplayFetchCustom[NDSDisplayID_Touch][0] release];
[_bufDisplayFetchCustom[NDSDisplayID_Touch][1] release];
[newTexDisplayNativeDesc setResourceOptions:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
[newTexDisplayNativeDesc setStorageMode:MTLStorageModeManaged];
[newTexDisplayNativeDesc setCpuCacheMode:MTLCPUCacheModeWriteCombined];
[newTexDisplayNativeDesc setUsage:MTLTextureUsageShaderRead];
_bufDisplayFetchNative[NDSDisplayID_Main][0] = [device newBufferWithBytesNoCopy:dispInfo0.nativeBuffer[NDSDisplayID_Main]
length:_nativeBufferSize
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
deallocator:nil];
_bufDisplayFetchNative[NDSDisplayID_Main][1] = [device newBufferWithBytesNoCopy:dispInfo1.nativeBuffer[NDSDisplayID_Main]
length:_nativeBufferSize
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
deallocator:nil];
_bufDisplayFetchNative[NDSDisplayID_Touch][0] = [device newBufferWithBytesNoCopy:dispInfo0.nativeBuffer[NDSDisplayID_Touch]
length:_nativeBufferSize
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
deallocator:nil];
_bufDisplayFetchNative[NDSDisplayID_Touch][1] = [device newBufferWithBytesNoCopy:dispInfo1.nativeBuffer[NDSDisplayID_Touch]
length:_nativeBufferSize
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
deallocator:nil];
_bufDisplayFetchCustom[NDSDisplayID_Main][0] = [device newBufferWithBytesNoCopy:dispInfo0.customBuffer[NDSDisplayID_Main]
length:_customBufferSize
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
deallocator:nil];
_bufDisplayFetchCustom[NDSDisplayID_Main][1] = [device newBufferWithBytesNoCopy:dispInfo1.customBuffer[NDSDisplayID_Main]
length:_customBufferSize
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
deallocator:nil];
_bufDisplayFetchCustom[NDSDisplayID_Touch][0] = [device newBufferWithBytesNoCopy:dispInfo0.customBuffer[NDSDisplayID_Touch]
length:_customBufferSize
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
deallocator:nil];
_bufDisplayFetchCustom[NDSDisplayID_Touch][1] = [device newBufferWithBytesNoCopy:dispInfo1.customBuffer[NDSDisplayID_Touch]
length:_customBufferSize
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
deallocator:nil];
if (_fetchPixelBytes != dispInfo.pixelBytes)
{
MTLTextureDescriptor *newTexDisplayNativeDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:(dispInfo.colorFormat == NDSColorFormat_BGR555_Rev) ? MTLPixelFormatR16Uint : MTLPixelFormatRGBA8Unorm
MTLTextureDescriptor *newTexPostprocessNativeDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
width:GPU_FRAMEBUFFER_NATIVE_WIDTH
height:GPU_FRAMEBUFFER_NATIVE_HEIGHT
mipmapped:NO];
[newTexDisplayNativeDesc setResourceOptions:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
[newTexDisplayNativeDesc setStorageMode:MTLStorageModeManaged];
[newTexDisplayNativeDesc setCpuCacheMode:MTLCPUCacheModeWriteCombined];
[newTexDisplayNativeDesc setUsage:MTLTextureUsageShaderRead];
[_texDisplayFetchNative[NDSDisplayID_Main][0] release];
[_texDisplayFetchNative[NDSDisplayID_Main][1] release];
[_texDisplayFetchNative[NDSDisplayID_Touch][0] release];
[_texDisplayFetchNative[NDSDisplayID_Touch][1] release];
#ifdef MAC_OS_X_VERSION_10_13
if (_isSharedBufferTextureSupported)
{
_texDisplayFetchNative[NDSDisplayID_Main][0] = [_bufDisplayFetchNative[NDSDisplayID_Main][0] newTextureWithDescriptor:newTexDisplayNativeDesc offset:0 bytesPerRow:_nativeLineSize];
_texDisplayFetchNative[NDSDisplayID_Main][1] = [_bufDisplayFetchNative[NDSDisplayID_Main][1] newTextureWithDescriptor:newTexDisplayNativeDesc offset:0 bytesPerRow:_nativeLineSize];
_texDisplayFetchNative[NDSDisplayID_Touch][0] = [_bufDisplayFetchNative[NDSDisplayID_Touch][0] newTextureWithDescriptor:newTexDisplayNativeDesc offset:0 bytesPerRow:_nativeLineSize];
_texDisplayFetchNative[NDSDisplayID_Touch][1] = [_bufDisplayFetchNative[NDSDisplayID_Touch][1] newTextureWithDescriptor:newTexDisplayNativeDesc offset:0 bytesPerRow:_nativeLineSize];
}
else
#endif
{
_texDisplayFetchNative[NDSDisplayID_Main][0] = [device newTextureWithDescriptor:newTexDisplayNativeDesc];
_texDisplayFetchNative[NDSDisplayID_Main][1] = [device newTextureWithDescriptor:newTexDisplayNativeDesc];
_texDisplayFetchNative[NDSDisplayID_Touch][0] = [device newTextureWithDescriptor:newTexDisplayNativeDesc];
_texDisplayFetchNative[NDSDisplayID_Touch][1] = [device newTextureWithDescriptor:newTexDisplayNativeDesc];
}
MTLTextureDescriptor *newTexPostprocessNativeDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
width:GPU_FRAMEBUFFER_NATIVE_WIDTH
height:GPU_FRAMEBUFFER_NATIVE_HEIGHT
mipmapped:NO];
[newTexPostprocessNativeDesc setResourceOptions:MTLResourceStorageModePrivate];
[newTexPostprocessNativeDesc setStorageMode:MTLStorageModePrivate];
[newTexPostprocessNativeDesc setUsage:MTLTextureUsageShaderRead | MTLTextureUsageShaderWrite];
[_texDisplayPostprocessNative[NDSDisplayID_Main][0] release];
[_texDisplayPostprocessNative[NDSDisplayID_Main][1] release];
[_texDisplayPostprocessNative[NDSDisplayID_Touch][0] release];
[_texDisplayPostprocessNative[NDSDisplayID_Touch][1] release];
_texDisplayPostprocessNative[NDSDisplayID_Main][0] = [device newTextureWithDescriptor:newTexPostprocessNativeDesc];
_texDisplayPostprocessNative[NDSDisplayID_Main][1] = [device newTextureWithDescriptor:newTexPostprocessNativeDesc];
_texDisplayPostprocessNative[NDSDisplayID_Touch][0] = [device newTextureWithDescriptor:newTexPostprocessNativeDesc];
_texDisplayPostprocessNative[NDSDisplayID_Touch][1] = [device newTextureWithDescriptor:newTexPostprocessNativeDesc];
}
[newTexPostprocessNativeDesc setResourceOptions:MTLResourceStorageModePrivate];
[newTexPostprocessNativeDesc setStorageMode:MTLStorageModePrivate];
[newTexPostprocessNativeDesc setUsage:MTLTextureUsageShaderRead | MTLTextureUsageShaderWrite];
if ( (_fetchPixelBytes != dispInfo.pixelBytes) ||
([_texDisplayFetchCustom[NDSDisplayID_Main][0] width] != w) ||
([_texDisplayFetchCustom[NDSDisplayID_Main][0] height] != h) )
{
MTLTextureDescriptor *newTexDisplayCustomDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:(dispInfo.colorFormat == NDSColorFormat_BGR555_Rev) ? MTLPixelFormatR16Uint : MTLPixelFormatRGBA8Unorm
MTLTextureDescriptor *newTexDisplayCustomDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:(dispInfo.colorFormat == NDSColorFormat_BGR555_Rev) ? MTLPixelFormatR16Uint : MTLPixelFormatRGBA8Unorm
width:w
height:h
mipmapped:NO];
[newTexDisplayCustomDesc setResourceOptions:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
[newTexDisplayCustomDesc setStorageMode:MTLStorageModeManaged];
[newTexDisplayCustomDesc setCpuCacheMode:MTLCPUCacheModeWriteCombined];
[newTexDisplayCustomDesc setUsage:MTLTextureUsageShaderRead];
MTLTextureDescriptor *newTexPostprocessCustomDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
width:w
height:h
mipmapped:NO];
[newTexPostprocessCustomDesc setResourceOptions:MTLResourceStorageModePrivate];
[newTexPostprocessCustomDesc setStorageMode:MTLStorageModePrivate];
[newTexPostprocessCustomDesc setUsage:MTLTextureUsageShaderRead | MTLTextureUsageShaderWrite];
for (size_t i = 0; i < dispInfo.framebufferPageCount; i++)
{
const NDSDisplayInfo &dispInfoAtIndex = GPUFetchObject->GetFetchDisplayInfoForBufferIndex(i);
[newTexDisplayCustomDesc setResourceOptions:MTLResourceStorageModeManaged | MTLResourceCPUCacheModeWriteCombined];
[newTexDisplayCustomDesc setStorageMode:MTLStorageModeManaged];
[newTexDisplayCustomDesc setCpuCacheMode:MTLCPUCacheModeWriteCombined];
[newTexDisplayCustomDesc setUsage:MTLTextureUsageShaderRead];
[_bufDisplayFetchNative[NDSDisplayID_Main][i] release];
[_bufDisplayFetchNative[NDSDisplayID_Touch][i] release];
[_bufDisplayFetchCustom[NDSDisplayID_Main][i] release];
[_bufDisplayFetchCustom[NDSDisplayID_Touch][i] release];
[_texDisplayFetchCustom[NDSDisplayID_Main][0] release];
[_texDisplayFetchCustom[NDSDisplayID_Main][1] release];
[_texDisplayFetchCustom[NDSDisplayID_Touch][0] release];
[_texDisplayFetchCustom[NDSDisplayID_Touch][1] release];
_bufDisplayFetchNative[NDSDisplayID_Main][i] = [device newBufferWithBytesNoCopy:dispInfoAtIndex.nativeBuffer[NDSDisplayID_Main]
length:_nativeBufferSize
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
deallocator:nil];
_bufDisplayFetchNative[NDSDisplayID_Touch][i] = [device newBufferWithBytesNoCopy:dispInfoAtIndex.nativeBuffer[NDSDisplayID_Touch]
length:_nativeBufferSize
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
deallocator:nil];
_bufDisplayFetchCustom[NDSDisplayID_Main][i] = [device newBufferWithBytesNoCopy:dispInfoAtIndex.customBuffer[NDSDisplayID_Main]
length:_customBufferSize
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
deallocator:nil];
_bufDisplayFetchCustom[NDSDisplayID_Touch][i] = [device newBufferWithBytesNoCopy:dispInfoAtIndex.customBuffer[NDSDisplayID_Touch]
length:_customBufferSize
options:MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined
deallocator:nil];
if (_fetchPixelBytes != dispInfo.pixelBytes)
{
[_texDisplayFetchNative[NDSDisplayID_Main][i] release];
[_texDisplayFetchNative[NDSDisplayID_Touch][i] release];
[_texDisplayPostprocessNative[NDSDisplayID_Main][i] release];
[_texDisplayPostprocessNative[NDSDisplayID_Touch][i] release];
#ifdef MAC_OS_X_VERSION_10_13
if (_isSharedBufferTextureSupported)
{
_texDisplayFetchCustom[NDSDisplayID_Main][0] = [_bufDisplayFetchCustom[NDSDisplayID_Main][0] newTextureWithDescriptor:newTexDisplayCustomDesc offset:0 bytesPerRow:_customLineSize];
_texDisplayFetchCustom[NDSDisplayID_Main][1] = [_bufDisplayFetchCustom[NDSDisplayID_Main][1] newTextureWithDescriptor:newTexDisplayCustomDesc offset:0 bytesPerRow:_customLineSize];
_texDisplayFetchCustom[NDSDisplayID_Touch][0] = [_bufDisplayFetchCustom[NDSDisplayID_Touch][0] newTextureWithDescriptor:newTexDisplayCustomDesc offset:0 bytesPerRow:_customLineSize];
_texDisplayFetchCustom[NDSDisplayID_Touch][1] = [_bufDisplayFetchCustom[NDSDisplayID_Touch][1] newTextureWithDescriptor:newTexDisplayCustomDesc offset:0 bytesPerRow:_customLineSize];
}
else
if (_isSharedBufferTextureSupported)
{
_texDisplayFetchNative[NDSDisplayID_Main][i] = [_bufDisplayFetchNative[NDSDisplayID_Main][i] newTextureWithDescriptor:newTexDisplayNativeDesc offset:0 bytesPerRow:_nativeLineSize];
_texDisplayFetchNative[NDSDisplayID_Touch][i] = [_bufDisplayFetchNative[NDSDisplayID_Touch][i] newTextureWithDescriptor:newTexDisplayNativeDesc offset:0 bytesPerRow:_nativeLineSize];
}
else
#endif
{
_texDisplayFetchCustom[NDSDisplayID_Main][0] = [device newTextureWithDescriptor:newTexDisplayCustomDesc];
_texDisplayFetchCustom[NDSDisplayID_Main][1] = [device newTextureWithDescriptor:newTexDisplayCustomDesc];
_texDisplayFetchCustom[NDSDisplayID_Touch][0] = [device newTextureWithDescriptor:newTexDisplayCustomDesc];
_texDisplayFetchCustom[NDSDisplayID_Touch][1] = [device newTextureWithDescriptor:newTexDisplayCustomDesc];
{
_texDisplayFetchNative[NDSDisplayID_Main][i] = [device newTextureWithDescriptor:newTexDisplayNativeDesc];
_texDisplayFetchNative[NDSDisplayID_Touch][i] = [device newTextureWithDescriptor:newTexDisplayNativeDesc];
}
_texDisplayPostprocessNative[NDSDisplayID_Main][i] = [device newTextureWithDescriptor:newTexPostprocessNativeDesc];
_texDisplayPostprocessNative[NDSDisplayID_Touch][i] = [device newTextureWithDescriptor:newTexPostprocessNativeDesc];
if ( ([_texDisplayFetchCustom[NDSDisplayID_Main][i] width] != w) ||
([_texDisplayFetchCustom[NDSDisplayID_Main][i] height] != h) )
{
[_texDisplayFetchCustom[NDSDisplayID_Main][i] release];
[_texDisplayFetchCustom[NDSDisplayID_Touch][i] release];
[_texDisplayPostprocessCustom[NDSDisplayID_Main][i] release];
[_texDisplayPostprocessCustom[NDSDisplayID_Touch][i] release];
#ifdef MAC_OS_X_VERSION_10_13
if (_isSharedBufferTextureSupported)
{
_texDisplayFetchCustom[NDSDisplayID_Main][i] = [_bufDisplayFetchCustom[NDSDisplayID_Main][i] newTextureWithDescriptor:newTexDisplayCustomDesc offset:0 bytesPerRow:_customLineSize];
_texDisplayFetchCustom[NDSDisplayID_Touch][i] = [_bufDisplayFetchCustom[NDSDisplayID_Touch][i] newTextureWithDescriptor:newTexDisplayCustomDesc offset:0 bytesPerRow:_customLineSize];
}
else
#endif
{
_texDisplayFetchCustom[NDSDisplayID_Main][i] = [device newTextureWithDescriptor:newTexDisplayCustomDesc];
_texDisplayFetchCustom[NDSDisplayID_Touch][i] = [device newTextureWithDescriptor:newTexDisplayCustomDesc];
}
_texDisplayPostprocessCustom[NDSDisplayID_Main][i] = [device newTextureWithDescriptor:newTexPostprocessCustomDesc];
_texDisplayPostprocessCustom[NDSDisplayID_Touch][i] = [device newTextureWithDescriptor:newTexPostprocessCustomDesc];
}
}
MTLTextureDescriptor *newTexPostprocessCustomDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
width:w
height:h
mipmapped:NO];
[newTexPostprocessCustomDesc setResourceOptions:MTLResourceStorageModePrivate];
[newTexPostprocessCustomDesc setStorageMode:MTLStorageModePrivate];
[newTexPostprocessCustomDesc setUsage:MTLTextureUsageShaderRead | MTLTextureUsageShaderWrite];
[_texDisplayPostprocessCustom[NDSDisplayID_Main][0] release];
[_texDisplayPostprocessCustom[NDSDisplayID_Main][1] release];
[_texDisplayPostprocessCustom[NDSDisplayID_Touch][0] release];
[_texDisplayPostprocessCustom[NDSDisplayID_Touch][1] release];
_texDisplayPostprocessCustom[NDSDisplayID_Main][0] = [device newTextureWithDescriptor:newTexPostprocessCustomDesc];
_texDisplayPostprocessCustom[NDSDisplayID_Main][1] = [device newTextureWithDescriptor:newTexPostprocessCustomDesc];
_texDisplayPostprocessCustom[NDSDisplayID_Touch][0] = [device newTextureWithDescriptor:newTexPostprocessCustomDesc];
_texDisplayPostprocessCustom[NDSDisplayID_Touch][1] = [device newTextureWithDescriptor:newTexPostprocessCustomDesc];
}
_fetchPixelBytes = dispInfo.pixelBytes;
@ -2281,17 +2208,16 @@ MacMetalFetchObject::MacMetalFetchObject()
{
_useDirectToCPUFilterPipeline = true;
pthread_rwlock_init(&_srcCloneRWLock[NDSDisplayID_Main][0], NULL);
pthread_rwlock_init(&_srcCloneRWLock[NDSDisplayID_Touch][0], NULL);
pthread_rwlock_init(&_srcCloneRWLock[NDSDisplayID_Main][1], NULL);
pthread_rwlock_init(&_srcCloneRWLock[NDSDisplayID_Touch][1], NULL);
_srcNativeCloneMaster = (uint32_t *)malloc_alignedPage(GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2 * METAL_FETCH_BUFFER_COUNT * sizeof(uint32_t));
memset(_srcNativeCloneMaster, 0, GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2 * METAL_FETCH_BUFFER_COUNT * sizeof(uint32_t));
_srcNativeCloneMaster = (uint32_t *)malloc_alignedPage(GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2 * 2 * sizeof(uint32_t));
_srcNativeClone[NDSDisplayID_Main][0] = _srcNativeCloneMaster + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 0);
_srcNativeClone[NDSDisplayID_Touch][0] = _srcNativeCloneMaster + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 1);
_srcNativeClone[NDSDisplayID_Main][1] = _srcNativeCloneMaster + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2);
_srcNativeClone[NDSDisplayID_Touch][1] = _srcNativeCloneMaster + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 3);
memset(_srcNativeCloneMaster, 0, GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2 * sizeof(uint32_t));
for (size_t i = 0; i < METAL_FETCH_BUFFER_COUNT; i++)
{
pthread_rwlock_init(&_srcCloneRWLock[NDSDisplayID_Main][i], NULL);
pthread_rwlock_init(&_srcCloneRWLock[NDSDisplayID_Touch][i], NULL);
_srcNativeClone[NDSDisplayID_Main][i] = _srcNativeCloneMaster + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * ((i * 2) + 0));
_srcNativeClone[NDSDisplayID_Touch][i] = _srcNativeCloneMaster + (GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * ((i * 2) + 1));
}
_clientData = [[MetalDisplayViewSharedData alloc] init];
}
@ -2300,25 +2226,24 @@ MacMetalFetchObject::~MacMetalFetchObject()
{
[(MetalDisplayViewSharedData *)this->_clientData release];
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Main][0]);
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][0]);
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Main][1]);
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][1]);
for (size_t i = 0; i < METAL_FETCH_BUFFER_COUNT; i++)
{
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Main][i]);
pthread_rwlock_wrlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][i]);
this->_srcNativeClone[NDSDisplayID_Main][i] = NULL;
this->_srcNativeClone[NDSDisplayID_Touch][i] = NULL;
}
free_aligned(this->_srcNativeCloneMaster);
this->_srcNativeCloneMaster = NULL;
this->_srcNativeClone[NDSDisplayID_Main][0] = NULL;
this->_srcNativeClone[NDSDisplayID_Touch][0] = NULL;
this->_srcNativeClone[NDSDisplayID_Main][1] = NULL;
this->_srcNativeClone[NDSDisplayID_Touch][1] = NULL;
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][1]);
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Main][1]);
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][0]);
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Main][0]);
pthread_rwlock_destroy(&this->_srcCloneRWLock[NDSDisplayID_Main][0]);
pthread_rwlock_destroy(&this->_srcCloneRWLock[NDSDisplayID_Touch][0]);
pthread_rwlock_destroy(&this->_srcCloneRWLock[NDSDisplayID_Main][1]);
pthread_rwlock_destroy(&this->_srcCloneRWLock[NDSDisplayID_Touch][1]);
for (size_t i = METAL_FETCH_BUFFER_COUNT - 1; i < METAL_FETCH_BUFFER_COUNT; i--)
{
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Touch][i]);
pthread_rwlock_unlock(&this->_srcCloneRWLock[NDSDisplayID_Main][i]);
pthread_rwlock_destroy(&this->_srcCloneRWLock[NDSDisplayID_Touch][i]);
pthread_rwlock_destroy(&this->_srcCloneRWLock[NDSDisplayID_Main][i]);
}
}
void MacMetalFetchObject::Init()
@ -2335,22 +2260,7 @@ void MacMetalFetchObject::CopyFromSrcClone(uint32_t *dstBufferPtr, const NDSDisp
void MacMetalFetchObject::SetFetchBuffers(const NDSDisplayInfo &currentDisplayInfo)
{
const size_t nativeSize = GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * currentDisplayInfo.pixelBytes;
const size_t customSize = currentDisplayInfo.customWidth * currentDisplayInfo.customHeight * currentDisplayInfo.pixelBytes;
this->_fetchDisplayInfo[0] = currentDisplayInfo;
this->_fetchDisplayInfo[1] = currentDisplayInfo;
this->_fetchDisplayInfo[0].nativeBuffer[NDSDisplayID_Main] = (u8 *)currentDisplayInfo.masterFramebufferHead;
this->_fetchDisplayInfo[0].nativeBuffer[NDSDisplayID_Touch] = (u8 *)currentDisplayInfo.masterFramebufferHead + (nativeSize * 1);
this->_fetchDisplayInfo[0].customBuffer[NDSDisplayID_Main] = (u8 *)currentDisplayInfo.masterFramebufferHead + (nativeSize * 2);
this->_fetchDisplayInfo[0].customBuffer[NDSDisplayID_Touch] = (u8 *)currentDisplayInfo.masterFramebufferHead + (nativeSize * 2) + customSize;
this->_fetchDisplayInfo[1].nativeBuffer[NDSDisplayID_Main] = (u8 *)this->_fetchDisplayInfo[0].nativeBuffer[NDSDisplayID_Main] + currentDisplayInfo.framebufferSize;
this->_fetchDisplayInfo[1].nativeBuffer[NDSDisplayID_Touch] = (u8 *)this->_fetchDisplayInfo[0].nativeBuffer[NDSDisplayID_Touch] + currentDisplayInfo.framebufferSize;
this->_fetchDisplayInfo[1].customBuffer[NDSDisplayID_Main] = (u8 *)this->_fetchDisplayInfo[0].customBuffer[NDSDisplayID_Main] + currentDisplayInfo.framebufferSize;
this->_fetchDisplayInfo[1].customBuffer[NDSDisplayID_Touch] = (u8 *)this->_fetchDisplayInfo[0].customBuffer[NDSDisplayID_Touch] + currentDisplayInfo.framebufferSize;
this->GPUClientFetchObject::SetFetchBuffers(currentDisplayInfo);
[(MetalDisplayViewSharedData *)this->_clientData setFetchBuffersWithDisplayInfo:currentDisplayInfo];
}