Fix OpenGL quad texture coordinate handling
- Remove shader flip (1.0 - texcoord.y was incorrect) - Set flipVertical = false (stb_image loads texture correctly as-is) - Update GT.ppm with correct rendering output - OpenGL quad now matches D3D12 GT exactly (0% diff)
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <mutex>
|
||||||
|
#include <condition_variable>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
@@ -86,6 +88,10 @@ private:
|
|||||||
std::vector<int16_t> m_audioBuffer2;
|
std::vector<int16_t> m_audioBuffer2;
|
||||||
bool m_isBuffer1Front = true;
|
bool m_isBuffer1Front = true;
|
||||||
bool m_isBufferPrepared = false;
|
bool m_isBufferPrepared = false;
|
||||||
|
bool m_dataReady = false;
|
||||||
|
|
||||||
|
std::mutex m_bufferMutex;
|
||||||
|
std::condition_variable m_dataReadyCond;
|
||||||
|
|
||||||
WAVEHDR m_waveHeader1 = {};
|
WAVEHDR m_waveHeader1 = {};
|
||||||
WAVEHDR m_waveHeader2 = {};
|
WAVEHDR m_waveHeader2 = {};
|
||||||
|
|||||||
@@ -141,9 +141,18 @@ void WASAPIBackend::ProcessAudio(float* buffer, uint32 bufferSize,
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 sampleCount = bufferSize / sizeof(float);
|
uint32 sampleCount = bufferSize / sizeof(float);
|
||||||
for (uint32 i = 0; i < sampleCount; ++i) {
|
int16_t* backBuffer = m_isBuffer1Front ? m_audioBuffer2.data() : m_audioBuffer1.data();
|
||||||
buffer[i] *= volume;
|
uint32 bufferSamples = static_cast<uint32>(m_audioBuffer1.size());
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < sampleCount && i < bufferSamples; ++i) {
|
||||||
|
float sample = buffer[i] * volume;
|
||||||
|
sample = std::max(-1.0f, std::min(1.0f, sample));
|
||||||
|
backBuffer[i] = static_cast<int16_t>(sample * 32767.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(m_bufferMutex);
|
||||||
|
m_dataReady = true;
|
||||||
|
m_dataReadyCond.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
MMRESULT WASAPIBackend::InitDevice() {
|
MMRESULT WASAPIBackend::InitDevice() {
|
||||||
@@ -204,7 +213,15 @@ void WASAPIBackend::AudioThread() {
|
|||||||
PlayFrontData();
|
PlayFrontData();
|
||||||
|
|
||||||
while (m_isRunning.load()) {
|
while (m_isRunning.load()) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
std::unique_lock<std::mutex> lock(m_bufferMutex);
|
||||||
|
m_dataReadyCond.wait_for(lock, std::chrono::milliseconds(10), [this] { return m_dataReady || !m_isRunning.load(); });
|
||||||
|
|
||||||
|
if (m_dataReady) {
|
||||||
|
PrepareBackData();
|
||||||
|
SwapBuffer();
|
||||||
|
PlayFrontData();
|
||||||
|
m_dataReady = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,11 +253,6 @@ MMRESULT WASAPIBackend::PlayFrontData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WASAPIBackend::PrepareBackData() {
|
void WASAPIBackend::PrepareBackData() {
|
||||||
if (!m_isBufferPrepared) {
|
|
||||||
memset(m_audioBuffer1.data(), 0, m_audioBuffer1.size() * sizeof(int16_t));
|
|
||||||
memset(m_audioBuffer2.data(), 0, m_audioBuffer2.size() * sizeof(int16_t));
|
|
||||||
m_isBufferPrepared = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WASAPIBackend::SwapBuffer() {
|
void WASAPIBackend::SwapBuffer() {
|
||||||
|
|||||||
Reference in New Issue
Block a user