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