Store pixel-format in a global instead of hard-coding it and added a disabled func for setting it. Added a pixel-format comment to gfx.h.

This commit is contained in:
yellows8 2018-02-22 21:49:55 -05:00
parent 3c4c35e6e5
commit 2022d545dc
2 changed files with 10 additions and 1 deletions

View File

@ -22,6 +22,8 @@ typedef enum
GfxMode_LinearDouble ///< Double-buffering with linear framebuffer, which is transferred to the actual framebuffer by \ref gfxFlushBuffers().
} GfxMode;
/// Framebuffer pixel-format is RGBA8888, there's no known way to change this.
/**
* @brief Initializes the graphics subsystem.
* @warning Do not use \ref viInitialize when using this function.

View File

@ -34,6 +34,8 @@ static GfxMode g_gfxMode = GfxMode_LinearDouble;
static u8 *g_gfxFramebufLinear;
static s32 g_gfxPixelFormat = 0;
size_t g_gfx_framebuf_width=0, g_gfx_framebuf_aligned_width=0;
size_t g_gfx_framebuf_height=0, g_gfx_framebuf_aligned_height=0;
size_t g_gfx_framebuf_display_width=0, g_gfx_framebuf_display_height=0;
@ -136,7 +138,7 @@ static Result _gfxDequeueBuffer(void) {
memcpy(&tmp_fence, fence, sizeof(bufferProducerFence));//Offical sw waits on the fence from the previous DequeueBuffer call. Using the fence from the current DequeueBuffer call results in nvgfxEventWait() failing.
rc = bufferProducerDequeueBuffer(async, g_gfx_framebuf_width, g_gfx_framebuf_height, 0, 0x300, &g_gfxCurrentProducerBuffer, fence);
rc = bufferProducerDequeueBuffer(async, g_gfx_framebuf_width, g_gfx_framebuf_height, g_gfxPixelFormat, 0x300, &g_gfxCurrentProducerBuffer, fence);
//Only run nvgfxEventWait when the fence is valid and the id is not NO_FENCE.
if (R_SUCCEEDED(rc) && tmp_fence.is_valid && tmp_fence.nv_fences[0].id!=0xffffffff) rc = nvgfxEventWait(tmp_fence.nv_fences[0].id, tmp_fence.nv_fences[0].value, -1);
@ -181,6 +183,7 @@ static Result _gfxInit(ViServiceType servicetype, const char *DisplayName, u32 L
g_gfx_drawflip = true;
g_gfxQueueBufferData.transform = NATIVE_WINDOW_TRANSFORM_FLIP_V;
g_gfxPixelFormat = 0;
memset(g_gfx_ProducerSlotsRequested, 0, sizeof(g_gfx_ProducerSlotsRequested));
memset(&g_gfx_DequeueBuffer_fence, 0, sizeof(g_gfx_DequeueBuffer_fence));
@ -551,6 +554,10 @@ void gfxConfigureTransform(u32 transform) {
g_gfxQueueBufferData.transform = transform;
}
/*void gfxSetPixelFormat(s32 format) {
g_gfxPixelFormat = format;
}*/
void gfxFlushBuffers(void) {
u32 *actual_framebuf = (u32*)&g_gfxFramebuf[g_gfxCurrentBuffer*g_gfx_singleframebuf_size];