mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-04 02:22:15 +02:00
Implement 3d_ctx
This commit is contained in:
parent
cb6cfca6c7
commit
ff5fcbceb2
@ -2,6 +2,7 @@ typedef struct NvGpu NvGpu;
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NvGpu* parent;
|
NvGpu* parent;
|
||||||
|
u64 obj_id;
|
||||||
} Nv3dContext;
|
} Nv3dContext;
|
||||||
|
|
||||||
Result nv3dCreate(Nv3dContext* t, NvGpu* parent);
|
Result nv3dCreate(Nv3dContext* t, NvGpu* parent);
|
||||||
|
@ -144,7 +144,7 @@ Result nvioctlNvmap_GetId(u32 fd, u32 nvmap_handle, u32 *id);
|
|||||||
|
|
||||||
Result nvioctlChannel_SetNvmapFd(u32 fd, u32 nvmap_fd);
|
Result nvioctlChannel_SetNvmapFd(u32 fd, u32 nvmap_fd);
|
||||||
Result nvioctlChannel_SubmitGpfifo(u32 fd, nvioctl_gpfifo_entry *entries, u32 num_entries, u32 flags, nvioctl_fence *fence_out);
|
Result nvioctlChannel_SubmitGpfifo(u32 fd, nvioctl_gpfifo_entry *entries, u32 num_entries, u32 flags, nvioctl_fence *fence_out);
|
||||||
Result nvioctlChannel_AllocObjCtx(u32 fd, u32 class_num, u32 flags);
|
Result nvioctlChannel_AllocObjCtx(u32 fd, u32 class_num, u32 flags, u64* id_out);
|
||||||
Result nvioctlChannel_ZCullBind(u32 fd, u64 gpu_va, u32 mode);
|
Result nvioctlChannel_ZCullBind(u32 fd, u64 gpu_va, u32 mode);
|
||||||
Result nvioctlChannel_SetErrorNotifier(u32 fd, u64 offset, u64 size, u32 nvmap_handle);
|
Result nvioctlChannel_SetErrorNotifier(u32 fd, u64 offset, u64 size, u32 nvmap_handle);
|
||||||
Result nvioctlChannel_SetPriority(u32 fd, u32 priority);
|
Result nvioctlChannel_SetPriority(u32 fd, u32 priority);
|
||||||
|
@ -131,7 +131,7 @@ Result nvgfxInitialize(void) {
|
|||||||
|
|
||||||
if (R_SUCCEEDED(rc)) rc = nvioctlChannel_AllocGpfifoEx2(g_nvgfx_fd_nvhostgpu, 0x800, 0x1, 0, 0, 0, 0, &g_nvgfx_nvhost_fence);
|
if (R_SUCCEEDED(rc)) rc = nvioctlChannel_AllocGpfifoEx2(g_nvgfx_fd_nvhostgpu, 0x800, 0x1, 0, 0, 0, 0, &g_nvgfx_nvhost_fence);
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) rc = nvioctlChannel_AllocObjCtx(g_nvgfx_fd_nvhostgpu, g_nvgfx_gpu_characteristics.threed_class, 0);
|
if (R_SUCCEEDED(rc)) rc = nvioctlChannel_AllocObjCtx(g_nvgfx_fd_nvhostgpu, g_nvgfx_gpu_characteristics.threed_class, 0, NULL);
|
||||||
if (R_SUCCEEDED(rc)) rc = nvioctlChannel_SetPriority(g_nvgfx_fd_nvhostgpu, NvChannelPriority_Medium);
|
if (R_SUCCEEDED(rc)) rc = nvioctlChannel_SetPriority(g_nvgfx_fd_nvhostgpu, NvChannelPriority_Medium);
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) rc = nvmapobjSetup(&nvmap_objs[4], 0, 0x1, 0x20000, 0);
|
if (R_SUCCEEDED(rc)) rc = nvmapobjSetup(&nvmap_objs[4], 0, 0x1, 0x20000, 0);
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
Result nv3dCreate(Nv3dContext* t, NvGpu* parent)
|
Result nv3dCreate(Nv3dContext* t, NvGpu* parent)
|
||||||
{
|
{
|
||||||
t->parent = parent;
|
t->parent = parent;
|
||||||
return 0;
|
|
||||||
|
// TODO: Get class number from nvinfo*().
|
||||||
|
return nvioctlChannel_AllocObjCtx(parent->gpu_channel.fd, 0xB197, 0, &t->obj_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nv3dClose(Nv3dContext* t) {
|
void nv3dClose(Nv3dContext* t) {
|
||||||
/**/
|
// Empty
|
||||||
}
|
}
|
||||||
|
@ -46,17 +46,18 @@ Result nvioctlChannel_SubmitGpfifo(u32 fd, nvioctl_gpfifo_entry *entries, u32 nu
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result nvioctlChannel_AllocObjCtx(u32 fd, u32 class_num, u32 flags) {
|
Result nvioctlChannel_AllocObjCtx(u32 fd, u32 class_num, u32 flags, u64* id_out) {
|
||||||
struct {
|
struct {
|
||||||
__nv_in u32 class_num;
|
__nv_in u32 class_num;
|
||||||
__nv_in u32 flags;
|
__nv_in u32 flags;
|
||||||
__nv_in u64 obj_id; // (ignored) used for FREE_OBJ_CTX ioctl, which is not supported
|
__nv_out u64 obj_id; // (ignored) used for FREE_OBJ_CTX ioctl, which is not supported
|
||||||
} data;
|
} data;
|
||||||
|
|
||||||
memset(&data, 0, sizeof(data));
|
memset(&data, 0, sizeof(data));
|
||||||
data.class_num = class_num;
|
data.class_num = class_num;
|
||||||
data.flags = flags;
|
data.flags = flags;
|
||||||
data.obj_id = 0xDEADBEEF;
|
if (id_out != NULL)
|
||||||
|
*id_out = data.obj_id;
|
||||||
|
|
||||||
return nvIoctl(fd, _NV_IOWR(0x48, 0x09, data), &data);
|
return nvIoctl(fd, _NV_IOWR(0x48, 0x09, data), &data);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user