remove device = null test
This commit is contained in:
parent
f1ac650471
commit
5daf408aac
@ -93,6 +93,45 @@ GLOBAL struct {
|
|||||||
* ========================== */
|
* ========================== */
|
||||||
|
|
||||||
INTERNAL APP_EXIT_CALLBACK_FUNC_DEF(gpu_shutdown);
|
INTERNAL APP_EXIT_CALLBACK_FUNC_DEF(gpu_shutdown);
|
||||||
|
INTERNAL void dx12_init_base(struct sys_window *window);
|
||||||
|
INTERNAL void dx12_init_shaders(void);
|
||||||
|
|
||||||
|
struct gpu_startup_receipt gpu_startup(struct sys_window *window)
|
||||||
|
{
|
||||||
|
/* Initialize handles pool */
|
||||||
|
G.handle_entries_mutex = sys_mutex_alloc();
|
||||||
|
G.handle_entries_arena = arena_alloc(GIGABYTE(64));
|
||||||
|
|
||||||
|
/* Initialize dx12 */
|
||||||
|
dx12_init_base(window);
|
||||||
|
dx12_init_shaders();
|
||||||
|
|
||||||
|
/* Register callbacks */
|
||||||
|
app_register_exit_callback(gpu_shutdown);
|
||||||
|
|
||||||
|
struct gpu_startup_receipt res = ZI;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
INTERNAL APP_EXIT_CALLBACK_FUNC_DEF(gpu_shutdown)
|
||||||
|
{
|
||||||
|
#if DX12_DEBUG
|
||||||
|
/* Release objects to make live object reporting less noisy */
|
||||||
|
for (u64 i = 0; i < ARRAY_COUNT(G.swapchain_rtvs); ++i) {
|
||||||
|
ID3D12Resource_Release(G.swapchain_rtvs[i]);
|
||||||
|
}
|
||||||
|
ID3D12DescriptorHeap_Release(G.swapchain_rtv_heap);
|
||||||
|
ID3D12CommandQueue_Release(G.swapchain_ca);
|
||||||
|
ID3D12CommandQueue_Release(G.cq_direct);
|
||||||
|
ID3D12CommandQueue_Release(G.cq_compute);
|
||||||
|
IDXGISwapChain3_Release(G.swapchain);
|
||||||
|
ID3D12Device_Release(G.device);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ========================== *
|
||||||
|
* Dx12 base initialization
|
||||||
|
* ========================== */
|
||||||
|
|
||||||
INTERNAL void dx12_init_error(struct string error)
|
INTERNAL void dx12_init_error(struct string error)
|
||||||
{
|
{
|
||||||
@ -102,7 +141,7 @@ INTERNAL void dx12_init_error(struct string error)
|
|||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
INTERNAL void dx12_init(struct sys_window *window)
|
INTERNAL void dx12_init_base(struct sys_window *window)
|
||||||
{
|
{
|
||||||
__prof;
|
__prof;
|
||||||
struct temp_arena scratch = scratch_begin_no_conflict();
|
struct temp_arena scratch = scratch_begin_no_conflict();
|
||||||
@ -174,7 +213,6 @@ INTERNAL void dx12_init(struct sys_window *window)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
device = NULL;
|
|
||||||
if (!device) {
|
if (!device) {
|
||||||
if (first_gpu_name.len > 0) {
|
if (first_gpu_name.len > 0) {
|
||||||
struct string fmt = LIT("Could not initialize device '%F' with D3D_FEATURE_LEVEL_12_0. Ensure that the device is capable and drivers are up to date.");
|
struct string fmt = LIT("Could not initialize device '%F' with D3D_FEATURE_LEVEL_12_0. Ensure that the device is capable and drivers are up to date.");
|
||||||
@ -311,7 +349,6 @@ INTERNAL void dx12_init(struct sys_window *window)
|
|||||||
dx12_init_error(LIT("Failed to create swapchain RTV"));
|
dx12_init_error(LIT("Failed to create swapchain RTV"));
|
||||||
}
|
}
|
||||||
ID3D12Device_CreateRenderTargetView(device, swapchain_rtvs[i], NULL, rtv_handle);
|
ID3D12Device_CreateRenderTargetView(device, swapchain_rtvs[i], NULL, rtv_handle);
|
||||||
|
|
||||||
rtv_handle.ptr += desc_size_rtv;
|
rtv_handle.ptr += desc_size_rtv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -330,36 +367,12 @@ INTERNAL void dx12_init(struct sys_window *window)
|
|||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct gpu_startup_receipt gpu_startup(struct sys_window *window)
|
/* ========================== *
|
||||||
|
* Dx12 shader initialization
|
||||||
|
* ========================== */
|
||||||
|
|
||||||
|
INTERNAL void dx12_init_shaders(void)
|
||||||
{
|
{
|
||||||
/* Initialize handles pool */
|
|
||||||
G.handle_entries_mutex = sys_mutex_alloc();
|
|
||||||
G.handle_entries_arena = arena_alloc(GIGABYTE(64));
|
|
||||||
|
|
||||||
/* Initialize dx12 */
|
|
||||||
dx12_init(window);
|
|
||||||
|
|
||||||
/* Register callbacks */
|
|
||||||
app_register_exit_callback(gpu_shutdown);
|
|
||||||
|
|
||||||
struct gpu_startup_receipt res = ZI;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
INTERNAL APP_EXIT_CALLBACK_FUNC_DEF(gpu_shutdown)
|
|
||||||
{
|
|
||||||
#if DX12_DEBUG
|
|
||||||
/* Release objects to make live object reporting less noisy */
|
|
||||||
for (u64 i = 0; i < ARRAY_COUNT(G.swapchain_rtvs); ++i) {
|
|
||||||
ID3D12Resource_Release(G.swapchain_rtvs[i]);
|
|
||||||
}
|
|
||||||
ID3D12DescriptorHeap_Release(G.swapchain_rtv_heap);
|
|
||||||
ID3D12CommandQueue_Release(G.swapchain_ca);
|
|
||||||
ID3D12CommandQueue_Release(G.cq_direct);
|
|
||||||
ID3D12CommandQueue_Release(G.cq_compute);
|
|
||||||
IDXGISwapChain3_Release(G.swapchain);
|
|
||||||
ID3D12Device_Release(G.device);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user