gs-vertexbuffer: Update to new API adding flush_direct functionality

This fixes the crashes on deleting a filter without requiring painful memory editing.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2017-12-14 00:22:27 +01:00
parent 9a56c0c8ef
commit 9e813d98f1

View file

@ -54,7 +54,7 @@ GS::VertexBuffer::VertexBuffer(uint32_t maximumVertices) {
// Allocate GPU
obs_enter_graphics();
m_vertexbuffer = gs_vertexbuffer_create(&m_vertexbufferdata, GS_DYNAMIC);
m_vertexbuffer = gs_vertexbuffer_create(&m_vertexbufferdata, GS_DYNAMIC | GS_DUP_BUFFER);
obs_leave_graphics();
if (!m_vertexbuffer) {
throw std::runtime_error("Failed to create vertex buffer.");
@ -79,19 +79,6 @@ GS::VertexBuffer::~VertexBuffer() {
if (m_vertexbuffer) {
std::memset(&m_vertexbufferdata, 0, sizeof(m_vertexbufferdata));
// Workaround API stupidity in obs-studio.
// See PR: https://github.com/jp9000/obs-studio/pull/993
if (gs_get_device_type() == GS_DEVICE_DIRECT3D_11) {
#ifdef _DEBUG
*(reinterpret_cast<intptr_t*>(m_vertexbuffer) + 14) = 0;
#else
*(reinterpret_cast<intptr_t*>(m_vertexbuffer) + 13) = 0;
#endif
} else {
//*(reinterpret_cast<intptr_t*>(m_vertexbuffer)+14) = 0;
}
obs_enter_graphics();
gs_vertexbuffer_destroy(m_vertexbuffer);
obs_leave_graphics();
@ -126,7 +113,7 @@ gs_vertbuffer_t* GS::VertexBuffer::get(bool refreshGPU) {
m_vertexbufferdata.num_tex = m_uvwLayers;
obs_enter_graphics();
gs_vertexbuffer_flush(m_vertexbuffer);
gs_vertexbuffer_flush_direct(m_vertexbuffer, &m_vertexbufferdata);
obs_leave_graphics();
}
return m_vertexbuffer;