Skip to content

Commit

Permalink
Rename the QUEUE_SLOT_COUNT
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Jun 18, 2024
1 parent 6734897 commit 1fe6080
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ID3D12DescriptorHeap* cbvHeap;*/
extern "C" {
ID3D12CommandQueue *commandQueue;
#ifdef KINC_DIRECT3D_HAS_NO_SWAPCHAIN
ID3D12Resource *swapChainRenderTargets[QUEUE_SLOT_COUNT];
ID3D12Resource *swapChainRenderTargets[KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT];
#else
// IDXGISwapChain *swapChain;
#endif
Expand All @@ -63,7 +63,7 @@ struct RenderEnvironment {
ID3D12Device *device;
ID3D12CommandQueue *queue;
#ifdef KINC_DIRECT3D_HAS_NO_SWAPCHAIN
ID3D12Resource *renderTargets[QUEUE_SLOT_COUNT];
ID3D12Resource *renderTargets[KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT];
#else
IDXGISwapChain *swapChain;
#endif
Expand All @@ -83,9 +83,9 @@ extern bool bilinearFiltering;
// ID3D12DescriptorHeap* renderTargetDescriptorHeap;

// static UINT64 window->current_fence_value;
// static UINT64 window->current_fence_value[QUEUE_SLOT_COUNT];
// static HANDLE window->frame_fence_events[QUEUE_SLOT_COUNT];
// static ID3D12Fence *window->frame_fences[QUEUE_SLOT_COUNT];
// static UINT64 window->current_fence_value[KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT];
// static HANDLE window->frame_fence_events[KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT];
// static ID3D12Fence *window->frame_fences[KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT];
static ID3D12Fence *uploadFence;
static ID3D12GraphicsCommandList *initCommandList;
static ID3D12CommandAllocator *initCommandAllocator;
Expand All @@ -108,7 +108,7 @@ extern "C" struct RenderEnvironment createDeviceAndSwapChainHelper(D3D_FEATURE_L
kinc_microsoft_affirm(dxgiFactory->CreateSwapChain((IUnknown *)result.queue, &swapChainDescCopy, &result.swapChain));
#else
#ifdef KINC_DIRECT3D_HAS_NO_SWAPCHAIN
createSwapChain(&result, QUEUE_SLOT_COUNT);
createSwapChain(&result, KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT);
#else
createSwapChain(&result, swapChainDesc);
#endif
Expand Down Expand Up @@ -157,7 +157,7 @@ extern "C" void setupSwapChain(struct dx_window *window) {

window->current_fence_value = 0;

for (int i = 0; i < QUEUE_SLOT_COUNT; ++i) {
for (int i = 0; i < KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT; ++i) {
window->frame_fence_events[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
window->fence_values[i] = 0;
device->CreateFence(window->current_fence_value, D3D12_FENCE_FLAG_NONE, IID_GRAPHICS_PPV_ARGS(&window->frame_fences[i]));
Expand All @@ -180,7 +180,7 @@ static void createDeviceAndSwapChain(struct dx_window *window) {
struct DXGI_SWAP_CHAIN_DESC swapChainDesc;
ZeroMemory(&swapChainDesc, sizeof(swapChainDesc));

swapChainDesc.BufferCount = QUEUE_SLOT_COUNT;
swapChainDesc.BufferCount = KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT;
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferDesc.Width = window->width;
Expand Down Expand Up @@ -398,11 +398,11 @@ static void initialize(struct dx_window *window) {
}

static void shutdown() {
for (int i = 0; i < QUEUE_SLOT_COUNT; ++i) {
for (int i = 0; i < KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT; ++i) {
// waitForFence(window->frame_fences[i], window->current_fence_value[i], window->frame_fence_events[i]);
}

for (int i = 0; i < QUEUE_SLOT_COUNT; ++i) {
for (int i = 0; i < KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT; ++i) {
// CloseHandle(window->frame_fence_events[i]);
}
}
Expand All @@ -414,7 +414,7 @@ static void initWindow(struct dx_window *window, int windowIndex) {
DXGI_SWAP_CHAIN_DESC swapChainDesc;
ZeroMemory(&swapChainDesc, sizeof(swapChainDesc));

swapChainDesc.BufferCount = QUEUE_SLOT_COUNT;
swapChainDesc.BufferCount = KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT;
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferDesc.Width = kinc_window_width(windowIndex);
Expand Down Expand Up @@ -524,11 +524,12 @@ void kinc_g5_begin(kinc_g5_render_target_t *renderTarget, int windowId) {
struct dx_window *window = &dx_ctx.windows[windowId];
dx_ctx.current_window = windowId;

window->current_backbuffer = (window->current_backbuffer + 1) % QUEUE_SLOT_COUNT;
window->current_backbuffer = (window->current_backbuffer + 1) % KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT;

if (window->new_width != window->width || window->new_height != window->height) {
#ifndef KINC_DIRECT3D_HAS_NO_SWAPCHAIN
kinc_microsoft_affirm(window->swapChain->ResizeBuffers(QUEUE_SLOT_COUNT, window->new_width, window->new_height, DXGI_FORMAT_R8G8B8A8_UNORM, 0));
kinc_microsoft_affirm(
window->swapChain->ResizeBuffers(KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT, window->new_width, window->new_height, DXGI_FORMAT_R8G8B8A8_UNORM, 0));
#endif
setupSwapChain(window);
window->width = window->new_width;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ struct D3D12Rect {
long bottom;
};

#define QUEUE_SLOT_COUNT 2
#define KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT 2

struct dx_window {
#ifndef KINC_DIRECT3D_HAS_NO_SWAPCHAIN
struct IDXGISwapChain *swapChain;
#endif
UINT64 current_fence_value;
UINT64 fence_values[QUEUE_SLOT_COUNT];
HANDLE frame_fence_events[QUEUE_SLOT_COUNT];
struct ID3D12Fence *frame_fences[QUEUE_SLOT_COUNT];
UINT64 fence_values[KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT];
HANDLE frame_fence_events[KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT];
struct ID3D12Fence *frame_fences[KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT];
int width;
int height;
int new_width;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#endif

#ifdef KINC_DIRECT3D_HAS_NO_SWAPCHAIN
extern ID3D12Resource *swapChainRenderTargets[QUEUE_SLOT_COUNT];
extern ID3D12Resource *swapChainRenderTargets[KINC_INTERNAL_D3D12_SWAP_CHAIN_COUNT];
#endif

static void WaitForFence(ID3D12Fence *fence, UINT64 completionValue, HANDLE waitEvent) {
Expand Down

0 comments on commit 1fe6080

Please sign in to comment.