mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-04 18:42:15 +02:00
Add NvRenderTargetConfig
This commit is contained in:
parent
c5b626a17b
commit
5083c015cd
@ -72,6 +72,7 @@ extern "C" {
|
|||||||
#include "switch/nvidia/cmds/common.h"
|
#include "switch/nvidia/cmds/common.h"
|
||||||
#include "switch/nvidia/cmds/3d.h"
|
#include "switch/nvidia/cmds/3d.h"
|
||||||
#include "switch/nvidia/cmds/3d_init.h"
|
#include "switch/nvidia/cmds/3d_init.h"
|
||||||
|
#include "switch/nvidia/cmds/3d_rendertarget.h"
|
||||||
#include "switch/nvidia/cmds/3d_clear.h"
|
#include "switch/nvidia/cmds/3d_clear.h"
|
||||||
|
|
||||||
#include "switch/runtime/env.h"
|
#include "switch/runtime/env.h"
|
||||||
|
@ -95,6 +95,9 @@ enum {
|
|||||||
#define NvReg3D_ViewportSubpixelPrecisionBias(n) \
|
#define NvReg3D_ViewportSubpixelPrecisionBias(n) \
|
||||||
(NvReg3D_ViewportNSubpixelPrecisionBias + 8*(n))
|
(NvReg3D_ViewportNSubpixelPrecisionBias + 8*(n))
|
||||||
|
|
||||||
|
#define NvReg3D_RenderTargetAddr(n) \
|
||||||
|
(NvReg3D_RenderTargetNAddr + 16*(n))
|
||||||
|
|
||||||
#define NvReg3D_ViewportHorizontal(n) \
|
#define NvReg3D_ViewportHorizontal(n) \
|
||||||
(NvReg3D_ViewportNHorizontal + 4*(n))
|
(NvReg3D_ViewportNHorizontal + 4*(n))
|
||||||
#define NvReg3D_ViewportVertical(n) \
|
#define NvReg3D_ViewportVertical(n) \
|
||||||
|
21
nx/include/switch/nvidia/cmds/3d_rendertarget.h
Normal file
21
nx/include/switch/nvidia/cmds/3d_rendertarget.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
typedef struct {
|
||||||
|
NvBuffer* color_buffer;
|
||||||
|
size_t width;
|
||||||
|
size_t height;
|
||||||
|
NvBufferKind format;
|
||||||
|
} VnRenderTargetConfig;
|
||||||
|
|
||||||
|
void vnRenderTargetSetColorBuffer(VnRenderTargetConfig* c, NvBuffer* buffer) {
|
||||||
|
c->color_buffer = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vnRenderTargetSetDimensions(VnRenderTargetConfig* c, size_t width, size_t height) {
|
||||||
|
c->width = width;
|
||||||
|
c->height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vnRenderTargetSetFormat(VnRenderTargetConfig* c, NvBufferKind format) {
|
||||||
|
c->format = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vnSetRenderTargets(Vn* vn, VnRenderTargetConfig* targets, size_t num_targets);
|
@ -9,7 +9,6 @@ void vnClearBuffer(
|
|||||||
NvIncr(0, NvReg3D_ScreenScissorHorizontal, 0 | (width << 16), 0 | (height << 16)),
|
NvIncr(0, NvReg3D_ScreenScissorHorizontal, 0 | (width << 16), 0 | (height << 16)),
|
||||||
NvIncr(0, NvReg3D_RenderTargetControl, (076543210 << 4) | 1)); // bit0 probably enables RT #0
|
NvIncr(0, NvReg3D_RenderTargetControl, (076543210 << 4) | 1)); // bit0 probably enables RT #0
|
||||||
|
|
||||||
// TODO: this function does not seem to update buffer, but when i give it an invalid gpu_addr i get a gpfifo error so at least something is going on
|
|
||||||
iova_t gpu_addr = nvBufferGetGpuAddr(buf);
|
iova_t gpu_addr = nvBufferGetGpuAddr(buf);
|
||||||
VnCmd(vn,
|
VnCmd(vn,
|
||||||
NvIncr(0, NvReg3D_RenderTargetNAddr + 0x10*0,
|
NvIncr(0, NvReg3D_RenderTargetNAddr + 0x10*0,
|
||||||
|
@ -78,7 +78,7 @@ Result vnInit3D(Vn* vn) {
|
|||||||
vn,
|
vn,
|
||||||
NvImm(3, 0xab, 3), // SetOperation?
|
NvImm(3, 0xab, 3), // SetOperation?
|
||||||
NvImm(3, 0xa4, 0), // SetClipEnable
|
NvImm(3, 0xa4, 0), // SetClipEnable
|
||||||
NvImm(3, 0x221, 0x3f));
|
NvImm(3, 0x221, 0x3f)
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: Call macro_14f(0x00418800, 1, 1).
|
// TODO: Call macro_14f(0x00418800, 1, 1).
|
||||||
|
27
nx/source/nvidia/cmds/3d_rendertarget.c
Normal file
27
nx/source/nvidia/cmds/3d_rendertarget.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include <switch.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void vnSetRenderTargets(Vn* vn, VnRenderTargetConfig* targets, size_t num_targets) {
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
VnCmd(vn, NvIncr(0, NvReg3D_RenderTargetControl, (076543210 << 4) | num_targets));
|
||||||
|
|
||||||
|
for (i=0; i<num_targets; i++) {
|
||||||
|
iova_t gpu_addr = nvBufferGetGpuAddr(targets[i].color_buffer);
|
||||||
|
|
||||||
|
VnCmd(
|
||||||
|
vn,
|
||||||
|
NvIncr(0,
|
||||||
|
NvReg3D_RenderTargetAddr(i),
|
||||||
|
gpu_addr >> 32,
|
||||||
|
gpu_addr,
|
||||||
|
targets[i].width,
|
||||||
|
targets[i].height,
|
||||||
|
targets[i].format,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
targets[i].width, // TODO: Round up to power of 2?
|
||||||
|
0
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user