Misc code style fixes, rename NvGraphicBuffer::layers to planes

This commit is contained in:
fincs 2018-12-07 16:57:01 +01:00 committed by fincs
parent 7c01659953
commit bf43284c9f
5 changed files with 21 additions and 23 deletions

View File

@ -2,8 +2,7 @@
#include "../nvidia/map.h"
#include "native_window.h"
typedef struct Framebuffer
{
typedef struct Framebuffer {
NWindow *win;
NvMap map;
void* buf;

View File

@ -34,6 +34,6 @@ typedef struct {
u32 total_size; // in bytes
u32 num_planes; // usually 1
u32 unk12; // 0
NvSurface layers[3];
NvSurface planes[3];
u64 unused; // official sw writes a pointer to bookkeeping data here, but it's otherwise completely unused/overwritten during marshalling
} NvGraphicBuffer;

View File

@ -12,8 +12,7 @@
#include "display/framebuffer.h"
#include "nvidia/graphic_buffer.h"
static const u64 g_nvColorFmtTable[] =
{
static const u64 g_nvColorFmtTable[] = {
0x100532120, // PIXEL_FORMAT_RGBA_8888
0x10A532120, // PIXEL_FORMAT_RGBX_8888
0x10A881918, // PIXEL_FORMAT_RGB_888 <-- doesn't work
@ -63,12 +62,12 @@ Result framebufferCreate(Framebuffer* fb, NWindow *win, u32 width, u32 height, u
grbuf.format = format;
grbuf.ext_format = format;
grbuf.num_planes = 1;
grbuf.layers[0].width = width;
grbuf.layers[0].height = height;
grbuf.layers[0].color_format = colorfmt;
grbuf.layers[0].layout = NvLayout_BlockLinear;
grbuf.layers[0].kind = NvKind_Generic_16BX2;
grbuf.layers[0].block_height_log2 = block_height_log2;
grbuf.planes[0].width = width;
grbuf.planes[0].height = height;
grbuf.planes[0].color_format = colorfmt;
grbuf.planes[0].layout = NvLayout_BlockLinear;
grbuf.planes[0].kind = NvKind_Generic_16BX2;
grbuf.planes[0].block_height_log2 = block_height_log2;
// Calculate buffer dimensions and sizes
const u32 width_aligned_bytes = (width*bytes_per_pixel + 63) &~ 63; // GOBs are 64 bytes wide
@ -88,11 +87,11 @@ Result framebufferCreate(Framebuffer* fb, NWindow *win, u32 width, u32 height, u
grbuf.nvmap_id = nvMapGetId(&fb->map);
grbuf.stride = width_aligned;
grbuf.total_size = fb_size;
grbuf.layers[0].pitch = width_aligned_bytes;
grbuf.layers[0].size = fb_size;
grbuf.planes[0].pitch = width_aligned_bytes;
grbuf.planes[0].size = fb_size;
for (u32 i = 0; i < num_fbs; i ++) {
grbuf.layers[0].offset = i*fb_size;
grbuf.planes[0].offset = i*fb_size;
rc = nwindowConfigureBuffer(win, i, &grbuf);
if (R_FAILED(rc))
break;

View File

@ -79,7 +79,7 @@ static NvGraphicBuffer g_gfx_GraphicBuffer = {
.format = PIXEL_FORMAT_RGBA_8888,
.ext_format = PIXEL_FORMAT_RGBA_8888,
.num_planes = 1,
.layers = {
.planes = {
{
.color_format = 0x100532120UL, // this is 'A8B8G8R8' according to symbols in official sw
.layout = NvLayout_BlockLinear,
@ -206,10 +206,10 @@ Result gfxInitDefault(void) {
g_gfx_GraphicBuffer.stride = g_gfx_framebuf_aligned_width;
g_gfx_GraphicBuffer.total_size = g_gfx_singleframebuf_size;
g_gfx_GraphicBuffer.layers[0].width = g_gfx_framebuf_width;
g_gfx_GraphicBuffer.layers[0].height = g_gfx_framebuf_height;
g_gfx_GraphicBuffer.layers[0].pitch = g_gfx_framebuf_aligned_width*4;
g_gfx_GraphicBuffer.layers[0].size = g_gfx_singleframebuf_size;
g_gfx_GraphicBuffer.planes[0].width = g_gfx_framebuf_width;
g_gfx_GraphicBuffer.planes[0].height = g_gfx_framebuf_height;
g_gfx_GraphicBuffer.planes[0].pitch = g_gfx_framebuf_aligned_width*4;
g_gfx_GraphicBuffer.planes[0].size = g_gfx_singleframebuf_size;
g_gfxFramebufLinear = memalign(0x1000, g_gfx_singleframebuf_linear_size);
if (g_gfxFramebufLinear) {
@ -262,7 +262,7 @@ Result gfxInitDefault(void) {
if (R_SUCCEEDED(rc)) {
g_gfx_GraphicBuffer.nvmap_id = nvMapGetId(&g_nvmap_obj);
for (s32 i = 0; i < g_nvgfx_totalframebufs; i ++) {
g_gfx_GraphicBuffer.layers[0].offset = g_gfx_singleframebuf_size*i;
g_gfx_GraphicBuffer.planes[0].offset = g_gfx_singleframebuf_size*i;
rc = bqSetPreallocatedBuffer(&g_gfxBinderSession, i, &g_gfx_BufferInitData);
if (R_FAILED(rc))
break;

View File

@ -81,9 +81,9 @@ Result nwindowConfigureBuffer(NWindow* nw, s32 slot, NvGraphicBuffer* buf)
}
if (!nw->width)
nw->width = buf->layers[0].width;
nw->width = buf->planes[0].width;
if (!nw->height)
nw->height = buf->layers[0].height;
nw->height = buf->planes[0].height;
if (nw->format == ~0U)
nw->format = buf->format;
if (!nw->usage)
@ -93,7 +93,7 @@ Result nwindowConfigureBuffer(NWindow* nw, s32 slot, NvGraphicBuffer* buf)
bqbuf.width = nw->width;
bqbuf.height = nw->height;
bqbuf.stride = buf->stride;
//bqbuf.stride = buf->layers[0].pitch / (u8)(buf->layers[0].color_format >> 3); // this also works
//bqbuf.stride = buf->planes[0].pitch / (u8)(buf->planes[0].color_format >> 3); // this also works
bqbuf.format = nw->format;
bqbuf.usage = nw->usage;
bqbuf.native_handle = &buf->header;