Skip to content

Commit

Permalink
Merge branch 'v3' of ssh://github.com/Kode/Kore into v3
Browse files Browse the repository at this point in the history
# Conflicts:
#	backends/gpu/webgpu/sources/device.c
  • Loading branch information
RobDangerous committed Feb 25, 2025
2 parents 9b82d2a + 6249daa commit d117773
Show file tree
Hide file tree
Showing 136 changed files with 2,181 additions and 2,230 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ If applicable, add screenshots to help explain your problem.
- Host system (where you compile your code):
- Target system (where you run your code):
- IDE and/or compiler used:
- Kinc revision:
- Kinc build output:
- Kore revision:
- Kore build output:
- Application output (if it runs):

**Additional context**
Expand Down
12 changes: 6 additions & 6 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.

PROJECT_NAME = "Kinc"
PROJECT_NAME = "Kore"

# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
Expand Down Expand Up @@ -864,7 +864,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = Sources/kinc
INPUT = sources/kore

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down Expand Up @@ -908,7 +908,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.

EXCLUDE = Sources/kinc/libs Sources/kinc/io/lz4
EXCLUDE = sources/kore/libs

# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
Expand All @@ -935,7 +935,7 @@ EXCLUDE_PATTERNS =
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories use the pattern */test/*

EXCLUDE_SYMBOLS = kinc_internal_*
EXCLUDE_SYMBOLS = kore_internal_*

# The EXAMPLE_PATH tag can be used to specify one or more files or directories
# that contain example code fragments that are included (see the \include
Expand Down Expand Up @@ -1160,7 +1160,7 @@ ALPHABETICAL_INDEX = YES
# while generating the index headers.
# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.

IGNORE_PREFIX = kinc_ KINC_
IGNORE_PREFIX = kore_ KORE_

#---------------------------------------------------------------------------
# Configuration options related to the HTML output
Expand Down Expand Up @@ -2210,7 +2210,7 @@ INCLUDE_FILE_PATTERNS =
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.

PREDEFINED = KINC_DOCS
PREDEFINED = KORE_DOCS

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
Expand Down
24 changes: 12 additions & 12 deletions backends/audio/directsound/sources/DirectSound.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <kore3/audio/audio.h>

#include <kinc/system.h>
#include <kore3/system.h>

#include <kinc/backend/SystemMicrosoft.h>
#include <kinc/backend/Windows.h>
#include <kore3/backend/SystemMicrosoft.h>
#include <kore3/backend/Windows.h>

#include <dsound.h>

Expand Down Expand Up @@ -42,9 +42,9 @@ void kore_audio_init() {
audio_buffer.channels[0] = new float[audio_buffer.data_size];
audio_buffer.channels[1] = new float[audio_buffer.data_size];

kinc_microsoft_affirm(DirectSoundCreate8(nullptr, &dsound, nullptr));
kore_microsoft_affirm(DirectSoundCreate8(nullptr, &dsound, nullptr));
// TODO (DK) only for the main window?
kinc_microsoft_affirm(dsound->SetCooperativeLevel(kinc_windows_window_handle(0), DSSCL_PRIORITY));
kore_microsoft_affirm(dsound->SetCooperativeLevel(kore_windows_window_handle(0), DSSCL_PRIORITY));

WAVEFORMATEX waveFormat;
waveFormat.wFormatTag = WAVE_FORMAT_PCM;
Expand All @@ -63,18 +63,18 @@ void kore_audio_init() {
bufferDesc.lpwfxFormat = &waveFormat;
bufferDesc.guid3DAlgorithm = GUID_NULL;

kinc_microsoft_affirm(dsound->CreateSoundBuffer(&bufferDesc, &dbuffer, nullptr));
kore_microsoft_affirm(dsound->CreateSoundBuffer(&bufferDesc, &dbuffer, nullptr));

DWORD size1;
uint8_t *buffer1 = NULL;
kinc_microsoft_affirm(dbuffer->Lock(writePos, gap, (void **)&buffer1, &size1, nullptr, nullptr, 0));
kore_microsoft_affirm(dbuffer->Lock(writePos, gap, (void **)&buffer1, &size1, nullptr, nullptr, 0));
assert(buffer1 != NULL);
for (DWORD i = 0; i < size1; ++i) {
buffer1[i] = 0;
}
kinc_microsoft_affirm(dbuffer->Unlock(buffer1, size1, nullptr, 0));
kore_microsoft_affirm(dbuffer->Unlock(buffer1, size1, nullptr, 0));

kinc_microsoft_affirm(dbuffer->Play(0, 0, DSBPLAY_LOOPING));
kore_microsoft_affirm(dbuffer->Play(0, 0, DSBPLAY_LOOPING));
}

uint32_t kore_audio_samples_per_second(void) {
Expand All @@ -98,7 +98,7 @@ namespace {
void kore_audio_update() {
DWORD playPosition;
DWORD writePosition;
kinc_microsoft_affirm(dbuffer->GetCurrentPosition(&playPosition, &writePosition));
kore_microsoft_affirm(dbuffer->GetCurrentPosition(&playPosition, &writePosition));

int dif;
if (writePos >= writePosition) {
Expand Down Expand Up @@ -132,14 +132,14 @@ void kore_audio_update() {

DWORD size1;
uint8_t *buffer1;
kinc_microsoft_affirm(dbuffer->Lock(writePos, gap, (void **)&buffer1, &size1, NULL, NULL, 0));
kore_microsoft_affirm(dbuffer->Lock(writePos, gap, (void **)&buffer1, &size1, NULL, NULL, 0));

for (DWORD i = 0; i < size1 - (bitsPerSample / 8 - 1);) {
copySample(buffer1, i, ((writePos + i) / 2) % 2 == 0);
}
writePos += size1;

kinc_microsoft_affirm(dbuffer->Unlock(buffer1, size1, NULL, 0));
kore_microsoft_affirm(dbuffer->Unlock(buffer1, size1, NULL, 0));

if (writePos >= dsize) {
writePos -= dsize;
Expand Down
66 changes: 33 additions & 33 deletions backends/audio/wasapi_winrt/sources/WASAPI.winrt.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#include <kinc/audio2/audio.h>
#include <kore3/audio2/audio.h>

#include <kinc/backend/SystemMicrosoft.h>
#include <kore3/backend/SystemMicrosoft.h>

#include <kinc/error.h>
#include <kinc/log.h>
#include <kinc/threads/thread.h>
#include <kore3/error.h>
#include <kore3/log.h>
#include <kore3/threads/thread.h>

#include <AudioClient.h>
#include <Windows.h>
#include <initguid.h>
#ifdef KINC_WINDOWSAPP
#ifdef KORE_WINDOWSAPP
#include <mfapi.h>
#endif
#include <mmdeviceapi.h>
#include <wrl/implements.h>

#ifdef KINC_WINDOWSAPP
#ifdef KORE_WINDOWSAPP
using namespace ::Microsoft::WRL;
using namespace Windows::Media::Devices;
using namespace Windows::Storage::Streams;
Expand All @@ -37,8 +37,8 @@ template <class T> void SafeRelease(__deref_inout_opt T **ppT) {

// based on the implementation in soloud and Microsoft sample code
namespace {
kinc_thread_t thread;
kinc_a2_buffer_t a2_buffer;
kore_thread_t thread;
kore_a2_buffer_t a2_buffer;

IMMDeviceEnumerator *deviceEnumerator;
IMMDevice *device;
Expand All @@ -54,7 +54,7 @@ namespace {
bool initDefaultDevice();
void audioThread(LPVOID);

#ifdef KINC_WINDOWSAPP
#ifdef KORE_WINDOWSAPP
class AudioRenderer : public RuntimeClass<RuntimeClassFlags<ClassicCom>, FtmBase, IActivateAudioInterfaceCompletionHandler> {
public:
STDMETHOD(ActivateCompleted)(IActivateAudioInterfaceAsyncOperation *operation) {
Expand All @@ -74,7 +74,7 @@ namespace {
#endif

bool initDefaultDevice() {
#ifdef KINC_WINDOWSAPP
#ifdef KORE_WINDOWSAPP
HRESULT hr = S_OK;
#else
if (renderClient != NULL) {
Expand All @@ -92,7 +92,7 @@ namespace {
bufferEndEvent = 0;
}

kinc_log(KINC_LOG_LEVEL_INFO, "Initializing a new default audio device.");
kore_log(KORE_LOG_LEVEL_INFO, "Initializing a new default audio device.");

HRESULT hr = deviceEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &device);
if (hr == S_OK) {
Expand All @@ -115,7 +115,7 @@ namespace {

HRESULT supported = audioClient->IsFormatSupported(AUDCLNT_SHAREMODE_SHARED, format, &closestFormat);
if (supported == S_FALSE) {
kinc_log(KINC_LOG_LEVEL_WARNING, "Falling back to the system's preferred WASAPI mix format.", supported);
kore_log(KORE_LOG_LEVEL_WARNING, "Falling back to the system's preferred WASAPI mix format.", supported);
if (closestFormat != nullptr) {
format = closestFormat;
}
Expand All @@ -125,30 +125,30 @@ namespace {
}
HRESULT result = audioClient->Initialize(AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, 40 * 1000 * 10, 0, format, 0);
if (result != S_OK) {
kinc_log(KINC_LOG_LEVEL_WARNING, "Could not initialize WASAPI audio, going silent (error code 0x%x).", result);
kore_log(KORE_LOG_LEVEL_WARNING, "Could not initialize WASAPI audio, going silent (error code 0x%x).", result);
return false;
}

uint32_t old_samples_per_second = samples_per_second;
samples_per_second = format->nSamplesPerSec;
if (samples_per_second != old_samples_per_second) {
kinc_a2_internal_sample_rate_callback();
kore_a2_internal_sample_rate_callback();
}
a2_buffer.channel_count = 2;

bufferFrames = 0;
kinc_microsoft_affirm(audioClient->GetBufferSize(&bufferFrames));
kinc_microsoft_affirm(audioClient->GetService(__uuidof(IAudioRenderClient), reinterpret_cast<void **>(&renderClient)));
kore_microsoft_affirm(audioClient->GetBufferSize(&bufferFrames));
kore_microsoft_affirm(audioClient->GetService(__uuidof(IAudioRenderClient), reinterpret_cast<void **>(&renderClient)));

bufferEndEvent = CreateEvent(0, FALSE, FALSE, 0);
kinc_affirm(bufferEndEvent != 0);
kore_affirm(bufferEndEvent != 0);

kinc_microsoft_affirm(audioClient->SetEventHandle(bufferEndEvent));
kore_microsoft_affirm(audioClient->SetEventHandle(bufferEndEvent));

return true;
}
else {
kinc_log(KINC_LOG_LEVEL_WARNING, "Could not initialize WASAPI audio.");
kore_log(KORE_LOG_LEVEL_WARNING, "Could not initialize WASAPI audio.");
return false;
}
}
Expand Down Expand Up @@ -199,7 +199,7 @@ namespace {
return;
}

if (kinc_a2_internal_callback(&a2_buffer, frames)) {
if (kore_a2_internal_callback(&a2_buffer, frames)) {
if (format->wFormatTag == WAVE_FORMAT_PCM) {
for (UINT32 i = 0; i < frames; ++i) {
copyS16Sample((int16_t *)&buffer[i * format->nBlockAlign], (int16_t *)&buffer[i * format->nBlockAlign + 2]);
Expand Down Expand Up @@ -247,18 +247,18 @@ namespace {

} // namespace

#ifndef KINC_WINDOWSAPP
extern "C" void kinc_windows_co_initialize(void);
#ifndef KORE_WINDOWSAPP
extern "C" void kore_windows_co_initialize(void);
#endif

static bool initialized = false;

void kinc_a2_init() {
void kore_a2_init() {
if (initialized) {
return;
}

kinc_a2_internal_init();
kore_a2_internal_init();
initialized = true;

a2_buffer.read_location = 0;
Expand All @@ -268,31 +268,31 @@ void kinc_a2_init() {
a2_buffer.channels[0] = (float *)malloc(a2_buffer.data_size * sizeof(float));
a2_buffer.channels[1] = (float *)malloc(a2_buffer.data_size * sizeof(float));

#ifdef KINC_WINDOWSAPP
#ifdef KORE_WINDOWSAPP
renderer = Make<AudioRenderer>();

IActivateAudioInterfaceAsyncOperation *asyncOp;
Platform::String ^ deviceId = MediaDevice::GetDefaultAudioRenderId(Windows::Media::Devices::AudioDeviceRole::Default);
kinc_microsoft_affirm(ActivateAudioInterfaceAsync(deviceId->Data(), __uuidof(IAudioClient2), nullptr, renderer.Get(), &asyncOp));
kore_microsoft_affirm(ActivateAudioInterfaceAsync(deviceId->Data(), __uuidof(IAudioClient2), nullptr, renderer.Get(), &asyncOp));
SafeRelease(&asyncOp);
#else
kinc_windows_co_initialize();
kinc_microsoft_affirm(
kore_windows_co_initialize();
kore_microsoft_affirm(
CoCreateInstance(__uuidof(MMDeviceEnumerator), 0, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), reinterpret_cast<void **>(&deviceEnumerator)));

if (initDefaultDevice()) {
kinc_thread_init(&thread, audioThread, NULL);
kore_thread_init(&thread, audioThread, NULL);
}
#endif
}

uint32_t kinc_a2_samples_per_second(void) {
uint32_t kore_a2_samples_per_second(void) {
return samples_per_second;
}

void kinc_a2_update() {}
void kore_a2_update() {}

void kinc_a2_shutdown() {
void kore_a2_shutdown() {
// Wait for last data in buffer to play before stopping.
// Sleep((DWORD)(hnsActualDuration/REFTIMES_PER_MILLISEC/2));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void kore_d3d11_command_list_prepare_raytracing_volume(kore_gpu_command_list *li

void kore_d3d11_command_list_prepare_raytracing_hierarchy(kore_gpu_command_list *list, kore_gpu_raytracing_hierarchy *hierarchy);

void kore_d3d11_command_list_update_raytracing_hierarchy(kore_gpu_command_list *list, kinc_matrix4x4_t *volume_transforms, uint32_t volumes_count,
void kore_d3d11_command_list_update_raytracing_hierarchy(kore_gpu_command_list *list, kore_matrix4x4_t *volume_transforms, uint32_t volumes_count,
kore_gpu_raytracing_hierarchy *hierarchy);

void kore_d3d11_command_list_set_ray_pipeline(kore_gpu_command_list *list, kore_d3d11_ray_pipeline *pipeline);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <kore3/gpu/device.h>

#include <kinc/math/matrix.h>
#include <kore3/math/matrix.h>

#include "descriptorset_structs.h"

Expand Down Expand Up @@ -37,7 +37,7 @@ void kore_d3d11_device_wait_until_idle(kore_gpu_device *device);
void kore_d3d11_device_create_raytracing_volume(kore_gpu_device *device, kore_gpu_buffer *vertex_buffer, uint64_t vertex_count, kore_gpu_buffer *index_buffer,
uint32_t index_count, kore_gpu_raytracing_volume *volume);

void kore_d3d11_device_create_raytracing_hierarchy(kore_gpu_device *device, kore_gpu_raytracing_volume **volumes, kinc_matrix4x4_t *volume_transforms,
void kore_d3d11_device_create_raytracing_hierarchy(kore_gpu_device *device, kore_gpu_raytracing_volume **volumes, kore_matrix4x4_t *volume_transforms,
uint32_t volumes_count, kore_gpu_raytracing_hierarchy *hierarchy);

void kore_d3d11_device_create_query_set(kore_gpu_device *device, const kore_gpu_query_set_parameters *parameters, kore_gpu_query_set *query_set);
Expand Down
2 changes: 1 addition & 1 deletion backends/gpu/direct3d11/sources/commandlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void kore_d3d11_command_list_prepare_raytracing_volume(kore_gpu_command_list *li

void kore_d3d11_command_list_prepare_raytracing_hierarchy(kore_gpu_command_list *list, kore_gpu_raytracing_hierarchy *hierarchy) {}

void kore_d3d11_command_list_update_raytracing_hierarchy(kore_gpu_command_list *list, kinc_matrix4x4_t *volume_transforms, uint32_t volumes_count,
void kore_d3d11_command_list_update_raytracing_hierarchy(kore_gpu_command_list *list, kore_matrix4x4_t *volume_transforms, uint32_t volumes_count,
kore_gpu_raytracing_hierarchy *hierarchy) {}

void kore_d3d11_command_list_set_ray_pipeline(kore_gpu_command_list *list, kore_d3d11_ray_pipeline *pipeline) {}
Expand Down
6 changes: 3 additions & 3 deletions backends/gpu/direct3d11/sources/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <kore3/gpu/device.h>
#include <kore3/util/align.h>

#include <kinc/log.h>
#include <kinc/window.h>
#include <kore3/log.h>
#include <kore3/window.h>

#include <assert.h>

Expand Down Expand Up @@ -38,7 +38,7 @@ void kore_d3d11_device_create_sampler(kore_gpu_device *device, const kore_gpu_sa
void kore_d3d11_device_create_raytracing_volume(kore_gpu_device *device, kore_gpu_buffer *vertex_buffer, uint64_t vertex_count, kore_gpu_buffer *index_buffer,
uint32_t index_count, kore_gpu_raytracing_volume *volume) {}

void kore_d3d11_device_create_raytracing_hierarchy(kore_gpu_device *device, kore_gpu_raytracing_volume **volumes, kinc_matrix4x4_t *volume_transforms,
void kore_d3d11_device_create_raytracing_hierarchy(kore_gpu_device *device, kore_gpu_raytracing_volume **volumes, kore_matrix4x4_t *volume_transforms,
uint32_t volumes_count, kore_gpu_raytracing_hierarchy *hierarchy) {}

void kore_d3d11_device_create_query_set(kore_gpu_device *device, const kore_gpu_query_set_parameters *parameters, kore_gpu_query_set *query_set) {}
Expand Down
2 changes: 1 addition & 1 deletion backends/gpu/direct3d11/sources/pipeline.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "pipeline_functions.h"
#include "pipeline_structs.h"

#include <kinc/log.h>
#include <kore3/log.h>

void kore_d3d11_render_pipeline_init(kore_d3d11_device *device, kore_d3d11_render_pipeline *pipe, const kore_d3d11_render_pipeline_parameters *parameters) {

Expand Down
2 changes: 1 addition & 1 deletion backends/gpu/direct3d12/sources/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void kore_d3d12_device_create_buffer(kore_gpu_device *device, const kore_gpu_buf
// buffer->impl.format = format;

// static_assert(sizeof(D3D12IindexBufferView) == sizeof(D3D12_INDEX_BUFFER_VIEW), "Something is wrong with D3D12IindexBufferView");
// int uploadBufferSize = format == KINC_G5_INDEX_BUFFER_FORMAT_16BIT ? sizeof(uint16_t) * count : sizeof(uint32_t) * count;
// int uploadBufferSize = format == KORE_G5_INDEX_BUFFER_FORMAT_16BIT ? sizeof(uint16_t) * count : sizeof(uint32_t) * count;

D3D12_HEAP_PROPERTIES props;
props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
Expand Down
Loading

0 comments on commit d117773

Please sign in to comment.