2013-04-18 06:29:41 +03:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2013-02-01 00:11:53 +02:00
|
|
|
|
|
|
|
#ifndef STREAMBUFFER_H
|
|
|
|
#define STREAMBUFFER_H
|
|
|
|
|
|
|
|
#include "VideoCommon.h"
|
|
|
|
#include "FramebufferManager.h"
|
2013-02-01 16:15:25 +02:00
|
|
|
#include "GLUtil.h"
|
2013-02-01 00:11:53 +02:00
|
|
|
|
2013-03-04 13:40:23 +02:00
|
|
|
// glew < 1.8 doesn't support pinned memory
|
|
|
|
#ifndef GLEW_AMD_pinned_memory
|
|
|
|
#define GLEW_AMD_pinned_memory glewIsSupported("GL_AMD_pinned_memory")
|
|
|
|
#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160
|
|
|
|
#endif
|
|
|
|
|
2013-02-01 00:11:53 +02:00
|
|
|
namespace OGL
|
|
|
|
{
|
|
|
|
enum StreamType {
|
2013-12-27 18:56:03 +02:00
|
|
|
DETECT_MASK = 0xFF,
|
2013-03-23 22:37:01 +02:00
|
|
|
STREAM_DETECT = (1 << 0),
|
|
|
|
MAP_AND_ORPHAN = (1 << 1),
|
|
|
|
MAP_AND_SYNC = (1 << 2),
|
|
|
|
MAP_AND_RISK = (1 << 3),
|
|
|
|
PINNED_MEMORY = (1 << 4),
|
2013-07-27 03:40:16 +03:00
|
|
|
BUFFERSUBDATA = (1 << 5),
|
2013-12-27 18:56:03 +02:00
|
|
|
BUFFERDATA = (1 << 6),
|
|
|
|
BUFFERSTORAGE = (1 << 7),
|
2013-02-01 00:11:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class StreamBuffer {
|
|
|
|
|
|
|
|
public:
|
2013-03-23 22:37:01 +02:00
|
|
|
StreamBuffer(u32 type, size_t size, StreamType uploadType = DETECT_MASK);
|
2013-02-01 00:11:53 +02:00
|
|
|
~StreamBuffer();
|
2013-10-29 07:23:17 +02:00
|
|
|
|
2013-02-01 16:15:25 +02:00
|
|
|
void Alloc(size_t size, u32 stride = 0);
|
2013-02-01 00:11:53 +02:00
|
|
|
size_t Upload(u8 *data, size_t size);
|
2013-10-29 07:23:17 +02:00
|
|
|
|
2013-02-01 00:11:53 +02:00
|
|
|
u32 getBuffer() { return m_buffer; }
|
2013-10-29 07:23:17 +02:00
|
|
|
|
2013-02-01 00:11:53 +02:00
|
|
|
private:
|
|
|
|
void Init();
|
|
|
|
void Shutdown();
|
2013-08-29 22:03:48 +03:00
|
|
|
void DeleteFences();
|
2013-10-29 07:23:17 +02:00
|
|
|
|
2013-02-01 00:11:53 +02:00
|
|
|
StreamType m_uploadtype;
|
|
|
|
u32 m_buffer;
|
|
|
|
u32 m_buffertype;
|
|
|
|
size_t m_size;
|
|
|
|
u8 *pointer;
|
|
|
|
size_t m_iterator;
|
2013-02-01 17:43:08 +02:00
|
|
|
size_t m_used_iterator;
|
|
|
|
size_t m_free_iterator;
|
2013-02-01 16:15:25 +02:00
|
|
|
GLsync *fences;
|
2013-02-01 00:11:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // STREAMBUFFER_H
|