setup and gpu setting changes restructured. not perfect but working. audio broken due to switch to faulty audio compression

This commit is contained in:
Dennis Eichhorn 2024-12-31 18:31:46 +01:00
parent f903ac86d7
commit ca139cd632
6 changed files with 12 additions and 32 deletions

View File

@ -20,6 +20,7 @@
#include "../object/Mesh.h"
#include "../object/Texture.h"
#include "../audio/Audio.cpp"
#include "../audio/Qoa.h"
#include "../font/Font.h"
#include "../localization/Language.h"
#include "../ui/UITheme.h"
@ -240,7 +241,6 @@ Asset* asset_archive_asset_load(const AssetArchive* archive, int32 id, AssetMana
Texture* texture = (Texture *) asset->self;
texture->image.pixels = (byte *) (texture + 1);
// @todo implement qoi encoding
qoi_decode(file.content, &texture->image);
asset->vram_size = texture->image.pixel_count * image_pixel_size_from_type(texture->image.image_settings);
@ -257,7 +257,7 @@ Asset* asset_archive_asset_load(const AssetArchive* archive, int32 id, AssetMana
Audio* audio = (Audio *) asset->self;
audio->data = (byte *) (audio + 1);
audio_from_data(file.content, audio);
qoa_decode(file.content, audio);
} break;
case ASSET_TYPE_OBJ: {
Mesh* mesh = (Mesh *) asset->self;

View File

@ -39,7 +39,7 @@ int32 audio_data_size(const Audio* audio)
return (int32) (audio->size
+ sizeof(audio->sample_rate)
+ sizeof(audio->channels)
+ sizeof(audio->bloc_size)
// + sizeof(audio->bloc_size) bit fiddling
+ sizeof(audio->size)
);
}

View File

@ -214,6 +214,8 @@ uint32 qoa_encode_frame(const int16* sample_data, int32 channels, uint32 frame_s
E.g. for stereo: (ch-0, slice 0), (ch 1, slice 0), (ch 0, slice 1), ...
*/
for (uint32 sample_index = 0; sample_index < frame_samples; sample_index += QOA_SLICE_LEN) {
QoaLms best_lms = {};
// @performance SIMDable
for (uint32 c = 0; c < channels; ++c) {
int32 slice_len = qoa_clamp(QOA_SLICE_LEN, 0, frame_samples - sample_index);
@ -225,9 +227,8 @@ uint32 qoa_encode_frame(const int16* sample_data, int32 channels, uint32 frame_s
16 scalefactors, encode all samples for the current slice and
meassure the total squared error.
*/
uint64 best_rank = -1;
uint64 best_rank = 0;
uint64 best_slice = 0;
QoaLms best_lms;
int32 best_scalefactor = 0;
for (int32 sfi = 0; sfi < 16; ++sfi) {
@ -351,7 +352,7 @@ uint32 qoa_encode(const Audio* audio, byte* data) {
return (uint32) (data - start);
}
uint32 qoa_decode_frame(const byte* bytes, int32 channels, QoaLms* lms, byte* sample_data)
uint32 qoa_decode_frame(const byte* bytes, int32 channels, QoaLms* lms, int16* sample_data)
{
const byte* start = bytes;
@ -400,7 +401,7 @@ uint32 qoa_decode_frame(const byte* bytes, int32 channels, QoaLms* lms, byte* sa
int32 dequantized = qoa_dequant_tab[scalefactor][quantized];
int32 reconstructed = qoa_clamp_s16(predicted + dequantized);
sample_data[si] = reconstructed;
sample_data[si] = (int16) reconstructed;
slice <<= 3;
qoa_lms_update(&lms[c], reconstructed, dequantized);
@ -424,7 +425,7 @@ uint32 qoa_decode(const byte* data, Audio* audio)
uint32 limit = 4 + QOA_LMS_LEN * 4 * audio->channels;
do {
frame_size = qoa_decode_frame(data + p, audio->channels, lms, sample_ptr);
frame_size = qoa_decode_frame(data + p, audio->channels, lms, (int16 *) sample_ptr);
sample_ptr += frame_size;
p += frame_size;
} while (frame_size && p < audio->size && audio->size - p >= limit);

View File

@ -16,6 +16,7 @@ struct GpuApiContainer {
uint32 frames_in_flight;
uint32 framebuffer_idx;
OpenglFrameData* framebuffers;
GLsync framebuffer_sync;
};
#endif

View File

@ -660,6 +660,8 @@ void set_pixel_format(HDC hdc, int32 multisampling = 0)
WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, GL_TRUE,
multisampling > 0 ? WGL_SAMPLE_BUFFERS_ARB : 0, (int32) (multisampling > 0),
WGL_SAMPLES_ARB, multisampling, // MSAA
0,
};

View File

@ -1,24 +0,0 @@
/**
* Jingga
*
* @copyright Jingga
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
#ifndef TOS_SCENE_STATE_H
#define TOS_SCENE_STATE_H
#include "../stdlib/Types.h"
enum SceneState : byte {
SCENE_STATE_DEFAULT = 0,
SCENE_STATE_WINDOW_CHANGED = 1,
SCENE_STATE_SHOULD_SWITCH = 2,
SCENE_STATE_STARTED_SETUP = 4,
SCENE_STATE_WAITING_SETUP = 8,
SCENE_STATE_READY = 16,
SCENE_STATE_STATIC_CHANGES = 32,
};
#endif