Implement 3d_ctx

This commit is contained in:
plutoo 2018-03-10 15:44:04 +01:00
parent cb6cfca6c7
commit ff5fcbceb2
5 changed files with 11 additions and 7 deletions

View File

@ -2,6 +2,7 @@ typedef struct NvGpu NvGpu;
typedef struct {
NvGpu* parent;
u64 obj_id;
} Nv3dContext;
Result nv3dCreate(Nv3dContext* t, NvGpu* parent);

View File

@ -144,7 +144,7 @@ Result nvioctlNvmap_GetId(u32 fd, u32 nvmap_handle, u32 *id);
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_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_SetErrorNotifier(u32 fd, u64 offset, u64 size, u32 nvmap_handle);
Result nvioctlChannel_SetPriority(u32 fd, u32 priority);

View File

@ -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_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 = nvmapobjSetup(&nvmap_objs[4], 0, 0x1, 0x20000, 0);

View File

@ -3,9 +3,11 @@
Result nv3dCreate(Nv3dContext* t, NvGpu* 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) {
/**/
// Empty
}

View File

@ -46,17 +46,18 @@ Result nvioctlChannel_SubmitGpfifo(u32 fd, nvioctl_gpfifo_entry *entries, u32 nu
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 {
__nv_in u32 class_num;
__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;
memset(&data, 0, sizeof(data));
data.class_num = class_num;
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);
}