Update Sources/viewport_server.cpp

This commit is contained in:
2026-06-10 02:29:45 +00:00
parent c24828f11d
commit 9c4ff352a8

View File

@ -12,7 +12,7 @@
#include <stdlib.h>
#include <math.h>
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
#include <d3d11.h>
#include <dxgi.h>
@ -49,7 +49,7 @@ struct dx_context {
extern "C" struct dx_context dx_ctx;
#endif
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
#include <Windows.h>
#else
#include <sys/mman.h>
@ -66,7 +66,7 @@ static ViewportServerState g_viewport_state = {0};
// Platform-specific Shared Memory Implementation
// ============================================================================
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
static bool shmem_create_windows(const char* name, size_t size) {
// Create file mapping
@ -197,7 +197,7 @@ static void shmem_destroy_posix(void) {
#endif
static bool shmem_create(const char* name, size_t size) {
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
return shmem_create_windows(name, size);
#else
return shmem_create_posix(name, size);
@ -205,7 +205,7 @@ static bool shmem_create(const char* name, size_t size) {
}
static void shmem_destroy(void) {
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
shmem_destroy_windows();
#else
shmem_destroy_posix();
@ -275,7 +275,7 @@ bool viewport_server_init(const char* shmem_name, int width, int height) {
return true;
}
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
static ID3D11Texture2D* g_stagingTexture = NULL;
static int g_stagingWidth = 0, g_stagingHeight = 0;
#endif
@ -285,7 +285,7 @@ void viewport_server_shutdown(void) {
return;
}
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
if (g_stagingTexture) {
g_stagingTexture->Release();
g_stagingTexture = NULL;
@ -346,7 +346,7 @@ void viewport_server_end_frame(void) {
uint8_t* pixels = g_viewport_state.pixel_buffer;
uint8_t* pixel_dest = (uint8_t*)g_viewport_state.shmem_ptr + VIEWPORT_HEADER_SIZE;
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
// Direct3D11 - read from backbuffer BEFORE swap_buffers
ID3D11DeviceContext* context = dx_ctx.context;
ID3D11Device* device = dx_ctx.device;
@ -435,7 +435,7 @@ void viewport_server_end_frame(void) {
// (Blender sends view_matrix -> we extract camera -> Blender applies it -> repeat)
// Memory barrier to ensure writes complete before setting ready flag
#ifdef KORE_WINDOWS
#ifdef KINC_WINDOWS
MemoryBarrier();
#else
__sync_synchronize();