mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
remove GFX prefix (#2611)
This commit is contained in:
@@ -35,14 +35,14 @@ Data::Data() :
|
||||
_bytes(nullptr),
|
||||
_size(0)
|
||||
{
|
||||
CC_LOG_INFO("In the empty constructor of Data.");
|
||||
// CC_LOG_INFO("In the empty constructor of Data.");
|
||||
}
|
||||
|
||||
Data::Data(Data&& other) :
|
||||
_bytes(nullptr),
|
||||
_size(0)
|
||||
{
|
||||
CC_LOG_INFO("In the move constructor of Data.");
|
||||
// CC_LOG_INFO("In the move constructor of Data.");
|
||||
move(other);
|
||||
}
|
||||
|
||||
@@ -50,26 +50,26 @@ Data::Data(const Data& other) :
|
||||
_bytes(nullptr),
|
||||
_size(0)
|
||||
{
|
||||
CC_LOG_INFO("In the copy constructor of Data.");
|
||||
// CC_LOG_INFO("In the copy constructor of Data.");
|
||||
copy(other._bytes, other._size);
|
||||
}
|
||||
|
||||
Data::~Data()
|
||||
{
|
||||
CC_LOG_INFO("deallocing Data: %p", this);
|
||||
// CC_LOG_INFO("deallocing Data: %p", this);
|
||||
clear();
|
||||
}
|
||||
|
||||
Data& Data::operator= (const Data& other)
|
||||
{
|
||||
CC_LOG_INFO("In the copy assignment of Data.");
|
||||
// CC_LOG_INFO("In the copy assignment of Data.");
|
||||
copy(other._bytes, other._size);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Data& Data::operator= (Data&& other)
|
||||
{
|
||||
CC_LOG_INFO("In the move assignment of Data.");
|
||||
// CC_LOG_INFO("In the move assignment of Data.");
|
||||
move(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -181,47 +181,47 @@ namespace
|
||||
|
||||
|
||||
// v2
|
||||
typedef const std::map<PVR2TexturePixelFormat, gfx::GFXFormat> _pixel2_formathash;
|
||||
typedef const std::map<PVR2TexturePixelFormat, gfx::Format> _pixel2_formathash;
|
||||
|
||||
static const _pixel2_formathash::value_type v2_pixel_formathash_value[] =
|
||||
{
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::BGRA8888, gfx::GFXFormat::BGRA8),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::RGBA8888, gfx::GFXFormat::RGBA8),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::RGBA4444, gfx::GFXFormat::RGBA4),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::RGBA5551, gfx::GFXFormat::RGB5A1),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::RGB565, gfx::GFXFormat::R5G6B5),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::RGB888, gfx::GFXFormat::RGB8),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::A8, gfx::GFXFormat::A8),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::I8, gfx::GFXFormat::L8),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::AI88, gfx::GFXFormat::LA8),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::BGRA8888, gfx::Format::BGRA8),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::RGBA8888, gfx::Format::RGBA8),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::RGBA4444, gfx::Format::RGBA4),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::RGBA5551, gfx::Format::RGB5A1),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::RGB565, gfx::Format::R5G6B5),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::RGB888, gfx::Format::RGB8),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::A8, gfx::Format::A8),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::I8, gfx::Format::L8),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::AI88, gfx::Format::LA8),
|
||||
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::PVRTC2BPP_RGBA, gfx::GFXFormat::PVRTC_RGBA2),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::PVRTC4BPP_RGBA, gfx::GFXFormat::PVRTC_RGBA4),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::PVRTC2BPP_RGBA, gfx::Format::PVRTC_RGBA2),
|
||||
_pixel2_formathash::value_type(PVR2TexturePixelFormat::PVRTC4BPP_RGBA, gfx::Format::PVRTC_RGBA4),
|
||||
};
|
||||
|
||||
static const int PVR2_MAX_TABLE_ELEMENTS = sizeof(v2_pixel_formathash_value) / sizeof(v2_pixel_formathash_value[0]);
|
||||
static const _pixel2_formathash v2_pixel_formathash(v2_pixel_formathash_value, v2_pixel_formathash_value + PVR2_MAX_TABLE_ELEMENTS);
|
||||
|
||||
// v3
|
||||
typedef const std::map<PVR3TexturePixelFormat, gfx::GFXFormat> _pixel3_formathash;
|
||||
typedef const std::map<PVR3TexturePixelFormat, gfx::Format> _pixel3_formathash;
|
||||
static _pixel3_formathash::value_type v3_pixel_formathash_value[] =
|
||||
{
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::BGRA8888, gfx::GFXFormat::BGRA8),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::RGBA8888, gfx::GFXFormat::RGBA8),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::RGBA4444, gfx::GFXFormat::RGBA4),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::RGBA5551, gfx::GFXFormat::RGB5A1),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::RGB565, gfx::GFXFormat::R5G6B5),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::RGB888, gfx::GFXFormat::RGB8),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::A8, gfx::GFXFormat::A8),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::L8, gfx::GFXFormat::L8),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::LA88, gfx::GFXFormat::LA8),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::BGRA8888, gfx::Format::BGRA8),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::RGBA8888, gfx::Format::RGBA8),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::RGBA4444, gfx::Format::RGBA4),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::RGBA5551, gfx::Format::RGB5A1),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::RGB565, gfx::Format::R5G6B5),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::RGB888, gfx::Format::RGB8),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::A8, gfx::Format::A8),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::L8, gfx::Format::L8),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::LA88, gfx::Format::LA8),
|
||||
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::PVRTC2BPP_RGB, gfx::GFXFormat::PVRTC_RGB2),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::PVRTC2BPP_RGBA, gfx::GFXFormat::PVRTC_RGBA2),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::PVRTC4BPP_RGB, gfx::GFXFormat::PVRTC_RGB4),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::PVRTC4BPP_RGBA, gfx::GFXFormat::PVRTC_RGBA4),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::PVRTC2BPP_RGB, gfx::Format::PVRTC_RGB2),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::PVRTC2BPP_RGBA, gfx::Format::PVRTC_RGBA2),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::PVRTC4BPP_RGB, gfx::Format::PVRTC_RGB4),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::PVRTC4BPP_RGBA, gfx::Format::PVRTC_RGBA4),
|
||||
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::ETC1, gfx::GFXFormat::ETC_RGB8),
|
||||
_pixel3_formathash::value_type(PVR3TexturePixelFormat::ETC1, gfx::Format::ETC_RGB8),
|
||||
};
|
||||
|
||||
static const int PVR3_MAX_TABLE_ELEMENTS = sizeof(v3_pixel_formathash_value) / sizeof(v3_pixel_formathash_value[0]);
|
||||
@@ -303,7 +303,7 @@ namespace
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool Image::PNG_PREMULTIPLIED_ALPHA_ENABLED = false;
|
||||
|
||||
Image::Image(): _renderFormat(gfx::GFXFormat::UNKNOWN)
|
||||
Image::Image(): _renderFormat(gfx::Format::UNKNOWN)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -597,10 +597,10 @@ bool Image::initWithJpgData(const unsigned char * data, ssize_t dataLen)
|
||||
|
||||
// we only support RGB or grayscale
|
||||
if (cinfo.jpeg_color_space == JCS_GRAYSCALE)
|
||||
_renderFormat = gfx::GFXFormat::L8;
|
||||
_renderFormat = gfx::Format::L8;
|
||||
else {
|
||||
cinfo.out_color_space = JCS_RGB;
|
||||
_renderFormat = gfx::GFXFormat::RGB8;
|
||||
_renderFormat = gfx::Format::RGB8;
|
||||
}
|
||||
|
||||
/* Start decompression jpeg here */
|
||||
@@ -723,16 +723,16 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen)
|
||||
switch (color_type)
|
||||
{
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
_renderFormat = gfx::GFXFormat::L8;
|
||||
_renderFormat = gfx::Format::L8;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||
_renderFormat = gfx::GFXFormat::LA8;
|
||||
_renderFormat = gfx::Format::LA8;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
_renderFormat = gfx::GFXFormat::RGB8;
|
||||
_renderFormat = gfx::Format::RGB8;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||
_renderFormat = gfx::GFXFormat::RGBA8;
|
||||
_renderFormat = gfx::Format::RGBA8;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -1037,7 +1037,7 @@ bool Image::initWithETCData(const unsigned char * data, ssize_t dataLen)
|
||||
return false;
|
||||
}
|
||||
|
||||
_renderFormat = gfx::GFXFormat::ETC_RGB8;
|
||||
_renderFormat = gfx::Format::ETC_RGB8;
|
||||
_dataLen = dataLen - ETC_PKM_HEADER_SIZE;
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
memcpy(_data, static_cast<const unsigned char*>(data) + ETC_PKM_HEADER_SIZE, _dataLen);
|
||||
@@ -1064,9 +1064,9 @@ bool Image::initWithETC2Data(const unsigned char * data, ssize_t dataLen)
|
||||
|
||||
etc2_uint32 format = etc2_pkm_get_format(header);
|
||||
if (format == ETC2_RGB_NO_MIPMAPS)
|
||||
_renderFormat = gfx::GFXFormat::ETC2_RGB8;
|
||||
_renderFormat = gfx::Format::ETC2_RGB8;
|
||||
else
|
||||
_renderFormat = gfx::GFXFormat::ETC2_RGBA8;
|
||||
_renderFormat = gfx::Format::ETC2_RGBA8;
|
||||
|
||||
_dataLen = dataLen - ETC2_PKM_HEADER_SIZE;
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
@@ -1093,7 +1093,7 @@ bool Image::initWithWebpData(const unsigned char * data, ssize_t dataLen)
|
||||
if (config.input.width == 0 || config.input.height == 0) break;
|
||||
|
||||
config.output.colorspace = config.input.has_alpha?MODE_rgbA:MODE_RGB;
|
||||
_renderFormat = config.input.has_alpha ? gfx::GFXFormat::RGBA8 : gfx::GFXFormat::RGB8;
|
||||
_renderFormat = config.input.has_alpha ? gfx::Format::RGBA8 : gfx::Format::RGB8;
|
||||
_width = config.input.width;
|
||||
_height = config.input.height;
|
||||
|
||||
@@ -1131,7 +1131,7 @@ bool Image::initWithRawData(const unsigned char * data, ssize_t dataLen, int wid
|
||||
_height = height;
|
||||
_width = width;
|
||||
_hasPremultipliedAlpha = preMulti;
|
||||
_renderFormat = gfx::GFXFormat::RGBA8;
|
||||
_renderFormat = gfx::Format::RGBA8;
|
||||
|
||||
// only RGBA8888 supported
|
||||
int bytesPerComponent = 4;
|
||||
@@ -1151,7 +1151,7 @@ bool Image::initWithRawData(const unsigned char * data, ssize_t dataLen, int wid
|
||||
bool Image::saveToFile(const std::string& filename, bool isToRGB)
|
||||
{
|
||||
//only support for Image::PixelFormat::RGB888 or Image::PixelFormat::RGBA8888 uncompressed data
|
||||
if (isCompressed() || (_renderFormat != gfx::GFXFormat::RGB8 && _renderFormat != gfx::GFXFormat::RGBA8))
|
||||
if (isCompressed() || (_renderFormat != gfx::Format::RGB8 && _renderFormat != gfx::Format::RGBA8))
|
||||
{
|
||||
CC_LOG_DEBUG("saveToFile: Image: saveToFile is only support for Image::PixelFormat::RGB888 or Image::PixelFormat::RGBA8888 uncompressed data for now");
|
||||
return false;
|
||||
@@ -1405,7 +1405,7 @@ bool Image::saveImageToJPG(const std::string& filePath)
|
||||
|
||||
void Image::premultipliedAlpha()
|
||||
{
|
||||
if (PNG_PREMULTIPLIED_ALPHA_ENABLED && _renderFormat == gfx::GFXFormat::RGBA8)
|
||||
if (PNG_PREMULTIPLIED_ALPHA_ENABLED && _renderFormat == gfx::Format::RGBA8)
|
||||
{
|
||||
unsigned int* fourBytes = (unsigned int*)_data;
|
||||
for(int i = 0; i < _width * _height; i++)
|
||||
|
||||
@@ -40,7 +40,7 @@ THE SOFTWARE.
|
||||
namespace cc {
|
||||
|
||||
namespace gfx {
|
||||
enum class GFXFormat : unsigned int;
|
||||
enum class Format : unsigned int;
|
||||
} // namespace gfx
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
bool alpha;
|
||||
};
|
||||
|
||||
typedef std::map<gfx::GFXFormat, const PixelFormatInfo> PixelFormatInfoMap;
|
||||
typedef std::map<gfx::Format, const PixelFormatInfo> PixelFormatInfoMap;
|
||||
|
||||
/**
|
||||
* Enables or disables premultiplied alpha for PNG files.
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
inline unsigned char *getData() const { return _data; }
|
||||
inline ssize_t getDataLen() const { return _dataLen; }
|
||||
inline Format getFileType() const { return _fileType; }
|
||||
inline gfx::GFXFormat getRenderFormat() const { return _renderFormat; }
|
||||
inline gfx::Format getRenderFormat() const { return _renderFormat; }
|
||||
inline int getWidth() const { return _width; }
|
||||
inline int getHeight() const { return _height; }
|
||||
inline int getNumberOfMipmaps() const { return _numberOfMipmaps; }
|
||||
@@ -183,7 +183,7 @@ protected:
|
||||
int _width = 0;
|
||||
int _height = 0;
|
||||
Format _fileType = Format::UNKNOWN;
|
||||
gfx::GFXFormat _renderFormat;
|
||||
gfx::Format _renderFormat;
|
||||
MipmapInfo _mipmaps[MIPMAP_MAX]; // pointer to mipmap images
|
||||
int _numberOfMipmaps = 0;
|
||||
// false if we can't auto detect the image is premultiplied or not.
|
||||
|
||||
@@ -4,58 +4,58 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXBindingLayout::GFXBindingLayout(GFXDevice *device)
|
||||
: GFXObject(GFXObjectType::BINDING_LAYOUT), _device(device) {
|
||||
BindingLayout::BindingLayout(Device *device)
|
||||
: GFXObject(ObjectType::BINDING_LAYOUT), _device(device) {
|
||||
}
|
||||
|
||||
GFXBindingLayout::~GFXBindingLayout() {
|
||||
BindingLayout::~BindingLayout() {
|
||||
}
|
||||
|
||||
void GFXBindingLayout::bindBuffer(uint binding, GFXBuffer *buffer) {
|
||||
void BindingLayout::bindBuffer(uint binding, Buffer *buffer) {
|
||||
for (size_t i = 0; i < _bindingUnits.size(); ++i) {
|
||||
GFXBindingUnit &bindingUnit = _bindingUnits[i];
|
||||
BindingUnit &bindingUnit = _bindingUnits[i];
|
||||
if (bindingUnit.binding == binding) {
|
||||
if (bindingUnit.type == GFXBindingType::UNIFORM_BUFFER) {
|
||||
if (bindingUnit.type == BindingType::UNIFORM_BUFFER) {
|
||||
if (bindingUnit.buffer != buffer) {
|
||||
bindingUnit.buffer = buffer;
|
||||
_isDirty = true;
|
||||
}
|
||||
} else {
|
||||
CCASSERT(false, "Setting binding is not GFXBindingType.UNIFORM_BUFFER.");
|
||||
CCASSERT(false, "Setting binding is not BindingType.UNIFORM_BUFFER.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GFXBindingLayout::bindTexture(uint binding, GFXTexture *texture) {
|
||||
void BindingLayout::bindTexture(uint binding, Texture *texture) {
|
||||
for (size_t i = 0; i < _bindingUnits.size(); ++i) {
|
||||
GFXBindingUnit &bindingUnit = _bindingUnits[i];
|
||||
BindingUnit &bindingUnit = _bindingUnits[i];
|
||||
if (bindingUnit.binding == binding) {
|
||||
if (bindingUnit.type == GFXBindingType::SAMPLER) {
|
||||
if (bindingUnit.type == BindingType::SAMPLER) {
|
||||
if (bindingUnit.texture != texture) {
|
||||
bindingUnit.texture = texture;
|
||||
_isDirty = true;
|
||||
}
|
||||
} else {
|
||||
CCASSERT(false, "Setting binding is not GFXBindingType.SAMPLER.");
|
||||
CCASSERT(false, "Setting binding is not BindingType.SAMPLER.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GFXBindingLayout::bindSampler(uint binding, GFXSampler *sampler) {
|
||||
void BindingLayout::bindSampler(uint binding, Sampler *sampler) {
|
||||
for (size_t i = 0; i < _bindingUnits.size(); ++i) {
|
||||
GFXBindingUnit &bindingUnit = _bindingUnits[i];
|
||||
BindingUnit &bindingUnit = _bindingUnits[i];
|
||||
if (bindingUnit.binding == binding) {
|
||||
if (bindingUnit.type == GFXBindingType::SAMPLER) {
|
||||
if (bindingUnit.type == BindingType::SAMPLER) {
|
||||
if (bindingUnit.sampler != sampler) {
|
||||
bindingUnit.sampler = sampler;
|
||||
_isDirty = true;
|
||||
}
|
||||
} else {
|
||||
CCASSERT(false, "Setting binding is not GFXBindingType.SAMPLER.");
|
||||
CCASSERT(false, "Setting binding is not BindingType.SAMPLER.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,26 +6,26 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXBindingLayout : public GFXObject {
|
||||
class CC_DLL BindingLayout : public GFXObject {
|
||||
public:
|
||||
GFXBindingLayout(GFXDevice *device);
|
||||
virtual ~GFXBindingLayout();
|
||||
BindingLayout(Device *device);
|
||||
virtual ~BindingLayout();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXBindingLayoutInfo &info) = 0;
|
||||
virtual bool initialize(const BindingLayoutInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual void update() = 0;
|
||||
|
||||
void bindBuffer(uint binding, GFXBuffer *buffer);
|
||||
void bindTexture(uint binding, GFXTexture *texView);
|
||||
void bindSampler(uint binding, GFXSampler *sampler);
|
||||
void bindBuffer(uint binding, Buffer *buffer);
|
||||
void bindTexture(uint binding, Texture *texView);
|
||||
void bindSampler(uint binding, Sampler *sampler);
|
||||
|
||||
CC_INLINE GFXDevice *getDevice() const { return _device; }
|
||||
CC_INLINE const GFXBindingUnitList &getBindingUnits() const { return _bindingUnits; }
|
||||
CC_INLINE Device *getDevice() const { return _device; }
|
||||
CC_INLINE const BindingUnitList &getBindingUnits() const { return _bindingUnits; }
|
||||
|
||||
protected:
|
||||
GFXDevice *_device = nullptr;
|
||||
GFXBindingUnitList _bindingUnits;
|
||||
Device *_device = nullptr;
|
||||
BindingUnitList _bindingUnits;
|
||||
bool _isDirty = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXBuffer::GFXBuffer(GFXDevice *device)
|
||||
: GFXObject(GFXObjectType::BUFFER), _device(device) {
|
||||
Buffer::Buffer(Device *device)
|
||||
: GFXObject(ObjectType::BUFFER), _device(device) {
|
||||
}
|
||||
|
||||
GFXBuffer::~GFXBuffer() {
|
||||
Buffer::~Buffer() {
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,34 +6,34 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXBuffer : public GFXObject {
|
||||
class CC_DLL Buffer : public GFXObject {
|
||||
public:
|
||||
GFXBuffer(GFXDevice *device);
|
||||
virtual ~GFXBuffer();
|
||||
Buffer(Device *device);
|
||||
virtual ~Buffer();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXBufferInfo &info) = 0;
|
||||
virtual bool initialize(const BufferInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual void resize(uint size) = 0;
|
||||
virtual void update(void *buffer, uint offset = 0, uint size = 0) = 0;
|
||||
|
||||
CC_INLINE GFXDevice *getDevice() const { return _device; }
|
||||
CC_INLINE GFXBufferUsage getUsage() const { return _usage; }
|
||||
CC_INLINE GFXMemoryUsage getMemUsage() const { return _memUsage; }
|
||||
CC_INLINE Device *getDevice() const { return _device; }
|
||||
CC_INLINE BufferUsage getUsage() const { return _usage; }
|
||||
CC_INLINE MemoryUsage getMemUsage() const { return _memUsage; }
|
||||
CC_INLINE uint getStride() const { return _stride; }
|
||||
CC_INLINE uint getCount() const { return _count; }
|
||||
CC_INLINE uint getSize() const { return _size; }
|
||||
CC_INLINE GFXBufferFlags getFlags() const { return _flags; }
|
||||
CC_INLINE BufferFlags getFlags() const { return _flags; }
|
||||
CC_INLINE uint8_t *getBufferView() const { return _buffer; }
|
||||
|
||||
protected:
|
||||
GFXDevice *_device = nullptr;
|
||||
GFXBufferUsage _usage = GFXBufferUsageBit::NONE;
|
||||
GFXMemoryUsage _memUsage = GFXMemoryUsageBit::NONE;
|
||||
Device *_device = nullptr;
|
||||
BufferUsage _usage = BufferUsageBit::NONE;
|
||||
MemoryUsage _memUsage = MemoryUsageBit::NONE;
|
||||
uint _stride = 0;
|
||||
uint _count = 0;
|
||||
uint _size = 0;
|
||||
GFXBufferFlags _flags = GFXBufferFlagBit::NONE;
|
||||
BufferFlags _flags = BufferFlagBit::NONE;
|
||||
uint8_t *_buffer = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXCommandAllocator::GFXCommandAllocator(GFXDevice *device)
|
||||
: GFXObject(GFXObjectType::COMMAND_ALLOCATOR), _device(device) {
|
||||
CommandAllocator::CommandAllocator(Device *device)
|
||||
: GFXObject(ObjectType::COMMAND_ALLOCATOR), _device(device) {
|
||||
}
|
||||
|
||||
GFXCommandAllocator::~GFXCommandAllocator() {
|
||||
CommandAllocator::~CommandAllocator() {
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXCommandAllocator : public GFXObject {
|
||||
class CC_DLL CommandAllocator : public GFXObject {
|
||||
public:
|
||||
GFXCommandAllocator(GFXDevice *device);
|
||||
virtual ~GFXCommandAllocator();
|
||||
CommandAllocator(Device *device);
|
||||
virtual ~CommandAllocator();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXCommandAllocatorInfo &info) = 0;
|
||||
virtual bool initialize(const CommandAllocatorInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
|
||||
CC_INLINE GFXDevice *getDevice() const { return _device; }
|
||||
CC_INLINE Device *getDevice() const { return _device; }
|
||||
|
||||
protected:
|
||||
GFXDevice *_device = nullptr;
|
||||
Device *_device = nullptr;
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXCommandBuffer::GFXCommandBuffer(GFXDevice *device)
|
||||
: GFXObject(GFXObjectType::COMMAND_BUFFER), _device(device) {
|
||||
CommandBuffer::CommandBuffer(Device *device)
|
||||
: GFXObject(ObjectType::COMMAND_BUFFER), _device(device) {
|
||||
}
|
||||
|
||||
GFXCommandBuffer::~GFXCommandBuffer() {
|
||||
CommandBuffer::~CommandBuffer() {
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,45 +6,45 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXCommandBuffer : public GFXObject {
|
||||
class CC_DLL CommandBuffer : public GFXObject {
|
||||
public:
|
||||
GFXCommandBuffer(GFXDevice *device);
|
||||
virtual ~GFXCommandBuffer();
|
||||
CommandBuffer(Device *device);
|
||||
virtual ~CommandBuffer();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXCommandBufferInfo &info) = 0;
|
||||
virtual bool initialize(const CommandBufferInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual void begin(GFXRenderPass *renderPass = nullptr, uint subpass = 0, GFXFramebuffer *frameBuffer = nullptr) = 0;
|
||||
virtual void begin(RenderPass *renderPass = nullptr, uint subpass = 0, Framebuffer *frameBuffer = nullptr) = 0;
|
||||
virtual void end() = 0;
|
||||
virtual void beginRenderPass(GFXFramebuffer *fbo, const GFXRect &render_area, GFXClearFlags clear_flags, const std::vector<GFXColor> &colors, float depth, int stencil) = 0;
|
||||
virtual void beginRenderPass(Framebuffer *fbo, const Rect &render_area, ClearFlags clear_flags, const std::vector<Color> &colors, float depth, int stencil) = 0;
|
||||
virtual void endRenderPass() = 0;
|
||||
virtual void bindPipelineState(GFXPipelineState *pso) = 0;
|
||||
virtual void bindBindingLayout(GFXBindingLayout *layout) = 0;
|
||||
virtual void bindInputAssembler(GFXInputAssembler *ia) = 0;
|
||||
virtual void setViewport(const GFXViewport &vp) = 0;
|
||||
virtual void setScissor(const GFXRect &rect) = 0;
|
||||
virtual void bindPipelineState(PipelineState *pso) = 0;
|
||||
virtual void bindBindingLayout(BindingLayout *layout) = 0;
|
||||
virtual void bindInputAssembler(InputAssembler *ia) = 0;
|
||||
virtual void setViewport(const Viewport &vp) = 0;
|
||||
virtual void setScissor(const Rect &rect) = 0;
|
||||
virtual void setLineWidth(const float width) = 0;
|
||||
virtual void setDepthBias(float constant, float clamp, float slope) = 0;
|
||||
virtual void setBlendConstants(const GFXColor &constants) = 0;
|
||||
virtual void setBlendConstants(const Color &constants) = 0;
|
||||
virtual void setDepthBound(float min_bounds, float max_bounds) = 0;
|
||||
virtual void setStencilWriteMask(GFXStencilFace face, uint mask) = 0;
|
||||
virtual void setStencilCompareMask(GFXStencilFace face, int ref, uint mask) = 0;
|
||||
virtual void draw(GFXInputAssembler *ia) = 0;
|
||||
virtual void updateBuffer(GFXBuffer *buff, void *data, uint size, uint offset = 0) = 0;
|
||||
virtual void copyBufferToTexture(GFXBuffer *src, GFXTexture *dst, GFXTextureLayout layout, const GFXBufferTextureCopyList ®ions) = 0;
|
||||
virtual void execute(const std::vector<GFXCommandBuffer *> &cmd_buffs, uint32_t count) = 0;
|
||||
virtual void setStencilWriteMask(StencilFace face, uint mask) = 0;
|
||||
virtual void setStencilCompareMask(StencilFace face, int ref, uint mask) = 0;
|
||||
virtual void draw(InputAssembler *ia) = 0;
|
||||
virtual void updateBuffer(Buffer *buff, void *data, uint size, uint offset = 0) = 0;
|
||||
virtual void copyBufferToTexture(Buffer *src, Texture *dst, TextureLayout layout, const BufferTextureCopyList ®ions) = 0;
|
||||
virtual void execute(const std::vector<CommandBuffer *> &cmd_buffs, uint32_t count) = 0;
|
||||
|
||||
CC_INLINE GFXDevice *getDevice() const { return _device; }
|
||||
CC_INLINE GFXCommandAllocator *getAllocator() const { return _allocator; }
|
||||
CC_INLINE GFXCommandBufferType getType() const { return _type; }
|
||||
CC_INLINE Device *getDevice() const { return _device; }
|
||||
CC_INLINE CommandAllocator *getAllocator() const { return _allocator; }
|
||||
CC_INLINE CommandBufferType getType() const { return _type; }
|
||||
CC_INLINE uint getNumDrawCalls() const { return _numDrawCalls; }
|
||||
CC_INLINE uint getNumInstances() const { return _numInstances; }
|
||||
CC_INLINE uint getNumTris() const { return _numTriangles; }
|
||||
|
||||
protected:
|
||||
GFXDevice *_device = nullptr;
|
||||
GFXCommandAllocator *_allocator = nullptr;
|
||||
GFXCommandBufferType _type = GFXCommandBufferType::PRIMARY;
|
||||
Device *_device = nullptr;
|
||||
CommandAllocator *_allocator = nullptr;
|
||||
CommandBufferType _type = CommandBufferType::PRIMARY;
|
||||
uint32_t _numDrawCalls = 0;
|
||||
uint32_t _numInstances = 0;
|
||||
uint32_t _numTriangles = 0;
|
||||
|
||||
@@ -8,9 +8,9 @@ namespace gfx {
|
||||
#define INITIAL_CAPACITY 1
|
||||
|
||||
template <typename T, typename = std::enable_if<std::is_base_of<GFXCmd, T>::value>>
|
||||
class GFXCommandPool {
|
||||
class CommandPool {
|
||||
public:
|
||||
GFXCommandPool() : _freeCmds(INITIAL_CAPACITY) {
|
||||
CommandPool() : _freeCmds(INITIAL_CAPACITY) {
|
||||
_frees = new T *[INITIAL_CAPACITY];
|
||||
_count = INITIAL_CAPACITY;
|
||||
_freeIdx = INITIAL_CAPACITY - 1;
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
~GFXCommandPool() {
|
||||
~CommandPool() {
|
||||
for (uint i = 0; i < _count; ++i) {
|
||||
CC_DELETE(_frees[i]);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXContext::GFXContext(GFXDevice *device)
|
||||
Context::Context(Device *device)
|
||||
: _device(device) {
|
||||
}
|
||||
|
||||
GFXContext::~GFXContext() {
|
||||
Context::~Context() {
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,29 +6,29 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXContext : public Object {
|
||||
class CC_DLL Context : public Object {
|
||||
public:
|
||||
GFXContext(GFXDevice *device);
|
||||
virtual ~GFXContext();
|
||||
Context(Device *device);
|
||||
virtual ~Context();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXContextInfo &info) = 0;
|
||||
virtual bool initialize(const ContextInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual void present() = 0;
|
||||
|
||||
CC_INLINE GFXDevice *getDevice() const { return _device; }
|
||||
CC_INLINE GFXContext *getSharedContext() const { return _sharedContext; }
|
||||
CC_INLINE GFXVsyncMode getVsyncMode() const { return _vsyncMode; }
|
||||
CC_INLINE GFXFormat getColorFormat() const { return _colorFmt; }
|
||||
CC_INLINE GFXFormat getDepthStencilFormat() const { return _depthStencilFmt; }
|
||||
CC_INLINE Device *getDevice() const { return _device; }
|
||||
CC_INLINE Context *getSharedContext() const { return _sharedContext; }
|
||||
CC_INLINE VsyncMode getVsyncMode() const { return _vsyncMode; }
|
||||
CC_INLINE Format getColorFormat() const { return _colorFmt; }
|
||||
CC_INLINE Format getDepthStencilFormat() const { return _depthStencilFmt; }
|
||||
|
||||
protected:
|
||||
GFXDevice *_device = nullptr;
|
||||
Device *_device = nullptr;
|
||||
uintptr_t _windowHandle = 0;
|
||||
GFXContext *_sharedContext = nullptr;
|
||||
GFXVsyncMode _vsyncMode = GFXVsyncMode::OFF;
|
||||
GFXFormat _colorFmt = GFXFormat::UNKNOWN;
|
||||
GFXFormat _depthStencilFmt = GFXFormat::UNKNOWN;
|
||||
Context *_sharedContext = nullptr;
|
||||
VsyncMode _vsyncMode = VsyncMode::OFF;
|
||||
Format _colorFmt = Format::UNKNOWN;
|
||||
Format _depthStencilFmt = Format::UNKNOWN;
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -4,154 +4,154 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
const GFXFormatInfo GFX_FORMAT_INFOS[] = {
|
||||
{"UNKNOWN", 0, 0, GFXFormatType::NONE, false, false, false, false},
|
||||
{"A8", 1, 1, GFXFormatType::UNORM, true, false, false, false},
|
||||
{"L8", 1, 1, GFXFormatType::UNORM, false, false, false, false},
|
||||
{"LA8", 1, 2, GFXFormatType::UNORM, false, false, false, false},
|
||||
const FormatInfo GFX_FORMAT_INFOS[] = {
|
||||
{"UNKNOWN", 0, 0, FormatType::NONE, false, false, false, false},
|
||||
{"A8", 1, 1, FormatType::UNORM, true, false, false, false},
|
||||
{"L8", 1, 1, FormatType::UNORM, false, false, false, false},
|
||||
{"LA8", 1, 2, FormatType::UNORM, false, false, false, false},
|
||||
|
||||
{"R8", 1, 1, GFXFormatType::UNORM, false, false, false, false},
|
||||
{"R8SN", 1, 1, GFXFormatType::SNORM, false, false, false, false},
|
||||
{"R8UI", 1, 1, GFXFormatType::UINT, false, false, false, false},
|
||||
{"R8I", 1, 1, GFXFormatType::INT, false, false, false, false},
|
||||
{"R16F", 2, 1, GFXFormatType::FLOAT, false, false, false, false},
|
||||
{"R16UI", 2, 1, GFXFormatType::UINT, false, false, false, false},
|
||||
{"R16I", 2, 1, GFXFormatType::INT, false, false, false, false},
|
||||
{"R32F", 4, 1, GFXFormatType::FLOAT, false, false, false, false},
|
||||
{"R32UI", 4, 1, GFXFormatType::UINT, false, false, false, false},
|
||||
{"R32I", 4, 1, GFXFormatType::INT, false, false, false, false},
|
||||
{"R8", 1, 1, FormatType::UNORM, false, false, false, false},
|
||||
{"R8SN", 1, 1, FormatType::SNORM, false, false, false, false},
|
||||
{"R8UI", 1, 1, FormatType::UINT, false, false, false, false},
|
||||
{"R8I", 1, 1, FormatType::INT, false, false, false, false},
|
||||
{"R16F", 2, 1, FormatType::FLOAT, false, false, false, false},
|
||||
{"R16UI", 2, 1, FormatType::UINT, false, false, false, false},
|
||||
{"R16I", 2, 1, FormatType::INT, false, false, false, false},
|
||||
{"R32F", 4, 1, FormatType::FLOAT, false, false, false, false},
|
||||
{"R32UI", 4, 1, FormatType::UINT, false, false, false, false},
|
||||
{"R32I", 4, 1, FormatType::INT, false, false, false, false},
|
||||
|
||||
{"RG8", 2, 2, GFXFormatType::UNORM, false, false, false, false},
|
||||
{"RG8SN", 2, 2, GFXFormatType::SNORM, false, false, false, false},
|
||||
{"RG8UI", 2, 2, GFXFormatType::UINT, false, false, false, false},
|
||||
{"RG8I", 2, 2, GFXFormatType::INT, false, false, false, false},
|
||||
{"RG16F", 4, 2, GFXFormatType::FLOAT, false, false, false, false},
|
||||
{"RG16UI", 4, 2, GFXFormatType::UINT, false, false, false, false},
|
||||
{"RG16I", 4, 2, GFXFormatType::INT, false, false, false, false},
|
||||
{"RG32F", 8, 2, GFXFormatType::FLOAT, false, false, false, false},
|
||||
{"RG32UI", 8, 2, GFXFormatType::UINT, false, false, false, false},
|
||||
{"RG32I", 8, 2, GFXFormatType::INT, false, false, false, false},
|
||||
{"RG8", 2, 2, FormatType::UNORM, false, false, false, false},
|
||||
{"RG8SN", 2, 2, FormatType::SNORM, false, false, false, false},
|
||||
{"RG8UI", 2, 2, FormatType::UINT, false, false, false, false},
|
||||
{"RG8I", 2, 2, FormatType::INT, false, false, false, false},
|
||||
{"RG16F", 4, 2, FormatType::FLOAT, false, false, false, false},
|
||||
{"RG16UI", 4, 2, FormatType::UINT, false, false, false, false},
|
||||
{"RG16I", 4, 2, FormatType::INT, false, false, false, false},
|
||||
{"RG32F", 8, 2, FormatType::FLOAT, false, false, false, false},
|
||||
{"RG32UI", 8, 2, FormatType::UINT, false, false, false, false},
|
||||
{"RG32I", 8, 2, FormatType::INT, false, false, false, false},
|
||||
|
||||
{"RGB8", 3, 3, GFXFormatType::UNORM, false, false, false, false},
|
||||
{"SRGB8", 3, 3, GFXFormatType::UNORM, false, false, false, false},
|
||||
{"RGB8SN", 3, 3, GFXFormatType::SNORM, false, false, false, false},
|
||||
{"RGB8UI", 3, 3, GFXFormatType::UINT, false, false, false, false},
|
||||
{"RGB8I", 3, 3, GFXFormatType::INT, false, false, false, false},
|
||||
{"RGB16F", 6, 3, GFXFormatType::FLOAT, false, false, false, false},
|
||||
{"RGB16UI", 6, 3, GFXFormatType::UINT, false, false, false, false},
|
||||
{"RGB16I", 6, 3, GFXFormatType::INT, false, false, false, false},
|
||||
{"RGB32F", 12, 3, GFXFormatType::FLOAT, false, false, false, false},
|
||||
{"RGB32UI", 12, 3, GFXFormatType::UINT, false, false, false, false},
|
||||
{"RGB32I", 12, 3, GFXFormatType::INT, false, false, false, false},
|
||||
{"RGB8", 3, 3, FormatType::UNORM, false, false, false, false},
|
||||
{"SRGB8", 3, 3, FormatType::UNORM, false, false, false, false},
|
||||
{"RGB8SN", 3, 3, FormatType::SNORM, false, false, false, false},
|
||||
{"RGB8UI", 3, 3, FormatType::UINT, false, false, false, false},
|
||||
{"RGB8I", 3, 3, FormatType::INT, false, false, false, false},
|
||||
{"RGB16F", 6, 3, FormatType::FLOAT, false, false, false, false},
|
||||
{"RGB16UI", 6, 3, FormatType::UINT, false, false, false, false},
|
||||
{"RGB16I", 6, 3, FormatType::INT, false, false, false, false},
|
||||
{"RGB32F", 12, 3, FormatType::FLOAT, false, false, false, false},
|
||||
{"RGB32UI", 12, 3, FormatType::UINT, false, false, false, false},
|
||||
{"RGB32I", 12, 3, FormatType::INT, false, false, false, false},
|
||||
|
||||
{"RGBA8", 4, 4, GFXFormatType::UNORM, true, false, false, false},
|
||||
{"BGRA8", 4, 4, GFXFormatType::UNORM, true, false, false, false},
|
||||
{"SRGB8_A8", 4, 4, GFXFormatType::UNORM, true, false, false, false},
|
||||
{"RGBA8SN", 4, 4, GFXFormatType::SNORM, true, false, false, false},
|
||||
{"RGBA8UI", 4, 4, GFXFormatType::UINT, true, false, false, false},
|
||||
{"RGBA8I", 4, 4, GFXFormatType::INT, true, false, false, false},
|
||||
{"RGBA16F", 8, 4, GFXFormatType::FLOAT, true, false, false, false},
|
||||
{"RGBA16UI", 8, 4, GFXFormatType::UINT, true, false, false, false},
|
||||
{"RGBA16I", 8, 4, GFXFormatType::INT, true, false, false, false},
|
||||
{"RGBA32F", 16, 4, GFXFormatType::FLOAT, true, false, false, false},
|
||||
{"RGBA32UI", 16, 4, GFXFormatType::UINT, true, false, false, false},
|
||||
{"RGBA32I", 16, 4, GFXFormatType::INT, true, false, false, false},
|
||||
{"RGBA8", 4, 4, FormatType::UNORM, true, false, false, false},
|
||||
{"BGRA8", 4, 4, FormatType::UNORM, true, false, false, false},
|
||||
{"SRGB8_A8", 4, 4, FormatType::UNORM, true, false, false, false},
|
||||
{"RGBA8SN", 4, 4, FormatType::SNORM, true, false, false, false},
|
||||
{"RGBA8UI", 4, 4, FormatType::UINT, true, false, false, false},
|
||||
{"RGBA8I", 4, 4, FormatType::INT, true, false, false, false},
|
||||
{"RGBA16F", 8, 4, FormatType::FLOAT, true, false, false, false},
|
||||
{"RGBA16UI", 8, 4, FormatType::UINT, true, false, false, false},
|
||||
{"RGBA16I", 8, 4, FormatType::INT, true, false, false, false},
|
||||
{"RGBA32F", 16, 4, FormatType::FLOAT, true, false, false, false},
|
||||
{"RGBA32UI", 16, 4, FormatType::UINT, true, false, false, false},
|
||||
{"RGBA32I", 16, 4, FormatType::INT, true, false, false, false},
|
||||
|
||||
{"R5G6B5", 2, 3, GFXFormatType::UNORM, false, false, false, false},
|
||||
{"R11G11B10F", 4, 3, GFXFormatType::FLOAT, false, false, false, false},
|
||||
{"RGB5A1", 2, 4, GFXFormatType::UNORM, true, false, false, false},
|
||||
{"RGBA4", 2, 4, GFXFormatType::UNORM, true, false, false, false},
|
||||
{"RGB10A2", 2, 4, GFXFormatType::UNORM, true, false, false, false},
|
||||
{"RGB10A2UI", 2, 4, GFXFormatType::UINT, true, false, false, false},
|
||||
{"RGB9E5", 2, 4, GFXFormatType::FLOAT, true, false, false, false},
|
||||
{"R5G6B5", 2, 3, FormatType::UNORM, false, false, false, false},
|
||||
{"R11G11B10F", 4, 3, FormatType::FLOAT, false, false, false, false},
|
||||
{"RGB5A1", 2, 4, FormatType::UNORM, true, false, false, false},
|
||||
{"RGBA4", 2, 4, FormatType::UNORM, true, false, false, false},
|
||||
{"RGB10A2", 2, 4, FormatType::UNORM, true, false, false, false},
|
||||
{"RGB10A2UI", 2, 4, FormatType::UINT, true, false, false, false},
|
||||
{"RGB9E5", 2, 4, FormatType::FLOAT, true, false, false, false},
|
||||
|
||||
{"D16", 2, 1, GFXFormatType::UINT, false, true, false, false},
|
||||
{"D16S8", 3, 1, GFXFormatType::UINT, false, true, true, false},
|
||||
{"D24", 3, 1, GFXFormatType::UINT, false, true, false, false},
|
||||
{"D24S8", 2, 1, GFXFormatType::UINT, false, true, true, false},
|
||||
{"D32F", 4, 1, GFXFormatType::FLOAT, false, true, false, false},
|
||||
{"D32FS8", 5, 2, GFXFormatType::FLOAT, false, true, true, false},
|
||||
{"D16", 2, 1, FormatType::UINT, false, true, false, false},
|
||||
{"D16S8", 3, 1, FormatType::UINT, false, true, true, false},
|
||||
{"D24", 3, 1, FormatType::UINT, false, true, false, false},
|
||||
{"D24S8", 2, 1, FormatType::UINT, false, true, true, false},
|
||||
{"D32F", 4, 1, FormatType::FLOAT, false, true, false, false},
|
||||
{"D32FS8", 5, 2, FormatType::FLOAT, false, true, true, false},
|
||||
|
||||
{"BC1", 1, 3, GFXFormatType::UNORM, false, false, false, true},
|
||||
{"BC1_ALPHA", 1, 4, GFXFormatType::UNORM, true, false, false, true},
|
||||
{"BC1_SRGB", 1, 3, GFXFormatType::UNORM, false, false, false, true},
|
||||
{"BC1_SRGB_ALPHA", 1, 4, GFXFormatType::UNORM, true, false, false, true},
|
||||
{"BC2", 1, 4, GFXFormatType::UNORM, true, false, false, true},
|
||||
{"BC2_SRGB", 1, 4, GFXFormatType::UNORM, true, false, false, true},
|
||||
{"BC3", 1, 4, GFXFormatType::UNORM, true, false, false, true},
|
||||
{"BC3_SRGB", 1, 4, GFXFormatType::UNORM, true, false, false, true},
|
||||
{"BC4", 1, 1, GFXFormatType::UNORM, false, false, false, true},
|
||||
{"BC4_SNORM", 1, 1, GFXFormatType::SNORM, false, false, false, true},
|
||||
{"BC5", 1, 2, GFXFormatType::UNORM, false, false, false, true},
|
||||
{"BC5_SNORM", 1, 2, GFXFormatType::SNORM, false, false, false, true},
|
||||
{"BC6H_UF16", 1, 3, GFXFormatType::UFLOAT, false, false, false, true},
|
||||
{"BC6H_SF16", 1, 3, GFXFormatType::FLOAT, false, false, false, true},
|
||||
{"BC7", 1, 4, GFXFormatType::UNORM, true, false, false, true},
|
||||
{"BC7_SRGB", 1, 4, GFXFormatType::UNORM, true, false, false, true},
|
||||
{"BC1", 1, 3, FormatType::UNORM, false, false, false, true},
|
||||
{"BC1_ALPHA", 1, 4, FormatType::UNORM, true, false, false, true},
|
||||
{"BC1_SRGB", 1, 3, FormatType::UNORM, false, false, false, true},
|
||||
{"BC1_SRGB_ALPHA", 1, 4, FormatType::UNORM, true, false, false, true},
|
||||
{"BC2", 1, 4, FormatType::UNORM, true, false, false, true},
|
||||
{"BC2_SRGB", 1, 4, FormatType::UNORM, true, false, false, true},
|
||||
{"BC3", 1, 4, FormatType::UNORM, true, false, false, true},
|
||||
{"BC3_SRGB", 1, 4, FormatType::UNORM, true, false, false, true},
|
||||
{"BC4", 1, 1, FormatType::UNORM, false, false, false, true},
|
||||
{"BC4_SNORM", 1, 1, FormatType::SNORM, false, false, false, true},
|
||||
{"BC5", 1, 2, FormatType::UNORM, false, false, false, true},
|
||||
{"BC5_SNORM", 1, 2, FormatType::SNORM, false, false, false, true},
|
||||
{"BC6H_UF16", 1, 3, FormatType::UFLOAT, false, false, false, true},
|
||||
{"BC6H_SF16", 1, 3, FormatType::FLOAT, false, false, false, true},
|
||||
{"BC7", 1, 4, FormatType::UNORM, true, false, false, true},
|
||||
{"BC7_SRGB", 1, 4, FormatType::UNORM, true, false, false, true},
|
||||
|
||||
{"ETC_RGB8", 1, 3, GFXFormatType::UNORM, false, false, false, true},
|
||||
{"ETC2_RGB8", 1, 3, GFXFormatType::UNORM, false, false, false, true},
|
||||
{"ETC2_SRGB8", 1, 3, GFXFormatType::UNORM, false, false, false, true},
|
||||
{"ETC2_RGB8_A1", 1, 4, GFXFormatType::UNORM, true, false, false, true},
|
||||
{"ETC2_SRGB8_A1", 1, 4, GFXFormatType::UNORM, true, false, false, true},
|
||||
{"EAC_R11", 1, 1, GFXFormatType::UNORM, false, false, false, true},
|
||||
{"EAC_R11SN", 1, 1, GFXFormatType::SNORM, false, false, false, true},
|
||||
{"EAC_RG11", 2, 2, GFXFormatType::UNORM, false, false, false, true},
|
||||
{"EAC_RG11SN", 2, 2, GFXFormatType::SNORM, false, false, false, true},
|
||||
{"ETC_RGB8", 1, 3, FormatType::UNORM, false, false, false, true},
|
||||
{"ETC2_RGB8", 1, 3, FormatType::UNORM, false, false, false, true},
|
||||
{"ETC2_SRGB8", 1, 3, FormatType::UNORM, false, false, false, true},
|
||||
{"ETC2_RGB8_A1", 1, 4, FormatType::UNORM, true, false, false, true},
|
||||
{"ETC2_SRGB8_A1", 1, 4, FormatType::UNORM, true, false, false, true},
|
||||
{"EAC_R11", 1, 1, FormatType::UNORM, false, false, false, true},
|
||||
{"EAC_R11SN", 1, 1, FormatType::SNORM, false, false, false, true},
|
||||
{"EAC_RG11", 2, 2, FormatType::UNORM, false, false, false, true},
|
||||
{"EAC_RG11SN", 2, 2, FormatType::SNORM, false, false, false, true},
|
||||
|
||||
{"PVRTC_RGB2", 2, 3, GFXFormatType::UNORM, false, false, false, true},
|
||||
{"PVRTC_RGBA2", 2, 4, GFXFormatType::UNORM, true, false, false, true},
|
||||
{"PVRTC_RGB4", 2, 3, GFXFormatType::UNORM, false, false, false, true},
|
||||
{"PVRTC_RGBA4", 2, 4, GFXFormatType::UNORM, true, false, false, true},
|
||||
{"PVRTC2_2BPP", 2, 4, GFXFormatType::UNORM, true, false, false, true},
|
||||
{"PVRTC2_4BPP", 2, 4, GFXFormatType::UNORM, true, false, false, true},
|
||||
{"PVRTC_RGB2", 2, 3, FormatType::UNORM, false, false, false, true},
|
||||
{"PVRTC_RGBA2", 2, 4, FormatType::UNORM, true, false, false, true},
|
||||
{"PVRTC_RGB4", 2, 3, FormatType::UNORM, false, false, false, true},
|
||||
{"PVRTC_RGBA4", 2, 4, FormatType::UNORM, true, false, false, true},
|
||||
{"PVRTC2_2BPP", 2, 4, FormatType::UNORM, true, false, false, true},
|
||||
{"PVRTC2_4BPP", 2, 4, FormatType::UNORM, true, false, false, true},
|
||||
};
|
||||
|
||||
uint GFXFormatSize(GFXFormat format, uint width, uint height, uint depth) {
|
||||
uint FormatSize(Format format, uint width, uint height, uint depth) {
|
||||
|
||||
if (!GFX_FORMAT_INFOS[(uint)format].isCompressed) {
|
||||
return (width * height * depth * GFX_FORMAT_INFOS[(uint)format].size);
|
||||
} else {
|
||||
switch (format) {
|
||||
case GFXFormat::BC1:
|
||||
case GFXFormat::BC1_ALPHA:
|
||||
case GFXFormat::BC1_SRGB:
|
||||
case GFXFormat::BC1_SRGB_ALPHA:
|
||||
case Format::BC1:
|
||||
case Format::BC1_ALPHA:
|
||||
case Format::BC1_SRGB:
|
||||
case Format::BC1_SRGB_ALPHA:
|
||||
return (uint)std::ceil(width / 4) * (uint)std::ceil(height / 4) * 8 * depth;
|
||||
case GFXFormat::BC2:
|
||||
case GFXFormat::BC2_SRGB:
|
||||
case GFXFormat::BC3:
|
||||
case GFXFormat::BC3_SRGB:
|
||||
case GFXFormat::BC4:
|
||||
case GFXFormat::BC4_SNORM:
|
||||
case GFXFormat::BC6H_SF16:
|
||||
case GFXFormat::BC6H_UF16:
|
||||
case GFXFormat::BC7:
|
||||
case GFXFormat::BC7_SRGB:
|
||||
case Format::BC2:
|
||||
case Format::BC2_SRGB:
|
||||
case Format::BC3:
|
||||
case Format::BC3_SRGB:
|
||||
case Format::BC4:
|
||||
case Format::BC4_SNORM:
|
||||
case Format::BC6H_SF16:
|
||||
case Format::BC6H_UF16:
|
||||
case Format::BC7:
|
||||
case Format::BC7_SRGB:
|
||||
return (uint)std::ceil(width / 4) * (uint)std::ceil(height / 4) * 16 * depth;
|
||||
case GFXFormat::BC5:
|
||||
case GFXFormat::BC5_SNORM:
|
||||
case Format::BC5:
|
||||
case Format::BC5_SNORM:
|
||||
return (uint)std::ceil(width / 4) * (uint)std::ceil(height / 4) * 32 * depth;
|
||||
|
||||
case GFXFormat::ETC_RGB8:
|
||||
case GFXFormat::ETC2_RGB8:
|
||||
case GFXFormat::ETC2_SRGB8:
|
||||
case GFXFormat::ETC2_RGB8_A1:
|
||||
case GFXFormat::ETC2_SRGB8_A1:
|
||||
case GFXFormat::EAC_R11:
|
||||
case GFXFormat::EAC_R11SN:
|
||||
case Format::ETC_RGB8:
|
||||
case Format::ETC2_RGB8:
|
||||
case Format::ETC2_SRGB8:
|
||||
case Format::ETC2_RGB8_A1:
|
||||
case Format::ETC2_SRGB8_A1:
|
||||
case Format::EAC_R11:
|
||||
case Format::EAC_R11SN:
|
||||
return (uint)std::ceil(width / 4) * (uint)std::ceil(height / 4) * 8 * depth;
|
||||
case GFXFormat::EAC_RG11:
|
||||
case GFXFormat::EAC_RG11SN:
|
||||
case Format::EAC_RG11:
|
||||
case Format::EAC_RG11SN:
|
||||
return (uint)std::ceil(width / 4) * (uint)std::ceil(height / 4) * 16 * depth;
|
||||
|
||||
case GFXFormat::PVRTC_RGB2:
|
||||
case GFXFormat::PVRTC_RGBA2:
|
||||
case GFXFormat::PVRTC2_2BPP:
|
||||
case Format::PVRTC_RGB2:
|
||||
case Format::PVRTC_RGBA2:
|
||||
case Format::PVRTC2_2BPP:
|
||||
return (uint)std::ceil(std::max(width, 16U) * std::max(height, 8U) / 4) * depth;
|
||||
case GFXFormat::PVRTC_RGB4:
|
||||
case GFXFormat::PVRTC_RGBA4:
|
||||
case GFXFormat::PVRTC2_4BPP:
|
||||
case Format::PVRTC_RGB4:
|
||||
case Format::PVRTC_RGBA4:
|
||||
case Format::PVRTC2_4BPP:
|
||||
return (uint)std::ceil(std::max(width, 16U) * std::max(height, 8U) / 2) * depth;
|
||||
default: {
|
||||
return 0;
|
||||
@@ -195,12 +195,12 @@ const uint GFX_TYPE_SIZES[] = {
|
||||
4, // SAMPLER_CUBE
|
||||
};
|
||||
|
||||
uint GFXFormatSurfaceSize(GFXFormat format, uint width, uint height, uint depth, uint mips) {
|
||||
uint FormatSurfaceSize(Format format, uint width, uint height, uint depth, uint mips) {
|
||||
|
||||
uint size = 0;
|
||||
|
||||
for (uint i = 0; i < mips; ++i) {
|
||||
size += GFXFormatSize(format, width, height, depth);
|
||||
size += FormatSize(format, width, height, depth);
|
||||
width = std::max(width >> 1, 1U);
|
||||
height = std::max(height >> 1, 1U);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,18 +4,18 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXDevice::GFXDevice() {
|
||||
Device::Device() {
|
||||
memset(_features, 0, sizeof(_features));
|
||||
}
|
||||
|
||||
GFXDevice::~GFXDevice() {
|
||||
Device::~Device() {
|
||||
}
|
||||
|
||||
GFXFormat GFXDevice::getColorFormat() const {
|
||||
Format Device::getColorFormat() const {
|
||||
return _context->getColorFormat();
|
||||
}
|
||||
|
||||
GFXFormat GFXDevice::getDepthStencilFormat() const {
|
||||
Format Device::getDepthStencilFormat() const {
|
||||
return _context->getDepthStencilFormat();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,44 +6,44 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXDevice : public Object {
|
||||
class CC_DLL Device : public Object {
|
||||
public:
|
||||
GFXDevice();
|
||||
virtual ~GFXDevice();
|
||||
Device();
|
||||
virtual ~Device();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXDeviceInfo &info) = 0;
|
||||
virtual bool initialize(const DeviceInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual void resize(uint width, uint height) = 0;
|
||||
virtual void acquire() = 0;
|
||||
virtual void present() = 0;
|
||||
virtual GFXFence *createFence(const GFXFenceInfo &info) = 0;
|
||||
virtual GFXQueue *createQueue(const GFXQueueInfo &info) = 0;
|
||||
virtual GFXCommandAllocator *createCommandAllocator(const GFXCommandAllocatorInfo &info) = 0;
|
||||
virtual GFXCommandBuffer *createCommandBuffer(const GFXCommandBufferInfo &info) = 0;
|
||||
virtual GFXBuffer *createBuffer(const GFXBufferInfo &info) = 0;
|
||||
virtual GFXTexture *createTexture(const GFXTextureInfo &info) = 0;
|
||||
virtual GFXTexture *createTexture(const GFXTextureViewInfo &info) = 0;
|
||||
virtual GFXSampler *createSampler(const GFXSamplerInfo &info) = 0;
|
||||
virtual GFXShader *createShader(const GFXShaderInfo &info) = 0;
|
||||
virtual GFXInputAssembler *createInputAssembler(const GFXInputAssemblerInfo &info) = 0;
|
||||
virtual GFXRenderPass *createRenderPass(const GFXRenderPassInfo &info) = 0;
|
||||
virtual GFXFramebuffer *createFramebuffer(const GFXFramebufferInfo &info) = 0;
|
||||
virtual GFXBindingLayout *createBindingLayout(const GFXBindingLayoutInfo &info) = 0;
|
||||
virtual GFXPipelineState *createPipelineState(const GFXPipelineStateInfo &info) = 0;
|
||||
virtual GFXPipelineLayout *createPipelineLayout(const GFXPipelineLayoutInfo &info) = 0;
|
||||
virtual void copyBuffersToTexture(const GFXDataArray &buffers, GFXTexture *dst, const GFXBufferTextureCopyList ®ions) = 0;
|
||||
virtual Fence *createFence(const FenceInfo &info) = 0;
|
||||
virtual Queue *createQueue(const QueueInfo &info) = 0;
|
||||
virtual CommandAllocator *createCommandAllocator(const CommandAllocatorInfo &info) = 0;
|
||||
virtual CommandBuffer *createCommandBuffer(const CommandBufferInfo &info) = 0;
|
||||
virtual Buffer *createBuffer(const BufferInfo &info) = 0;
|
||||
virtual Texture *createTexture(const TextureInfo &info) = 0;
|
||||
virtual Texture *createTexture(const TextureViewInfo &info) = 0;
|
||||
virtual Sampler *createSampler(const SamplerInfo &info) = 0;
|
||||
virtual Shader *createShader(const ShaderInfo &info) = 0;
|
||||
virtual InputAssembler *createInputAssembler(const InputAssemblerInfo &info) = 0;
|
||||
virtual RenderPass *createRenderPass(const RenderPassInfo &info) = 0;
|
||||
virtual Framebuffer *createFramebuffer(const FramebufferInfo &info) = 0;
|
||||
virtual BindingLayout *createBindingLayout(const BindingLayoutInfo &info) = 0;
|
||||
virtual PipelineState *createPipelineState(const PipelineStateInfo &info) = 0;
|
||||
virtual PipelineLayout *createPipelineLayout(const PipelineLayoutInfo &info) = 0;
|
||||
virtual void copyBuffersToTexture(const DataArray &buffers, Texture *dst, const BufferTextureCopyList ®ions) = 0;
|
||||
|
||||
CC_INLINE GFXAPI getGfxAPI() const { return _gfxAPI; }
|
||||
CC_INLINE API getGfxAPI() const { return _API; }
|
||||
CC_INLINE const String &getDeviceName() const { return _deviceName; }
|
||||
CC_INLINE uint getWidth() { return _width; }
|
||||
CC_INLINE uint getHeight() { return _height; }
|
||||
CC_INLINE uint getNativeWidth() { return _nativeWidth; }
|
||||
CC_INLINE uint getNativeHeight() { return _nativeHeight; }
|
||||
CC_INLINE GFXMemoryStatus &getMemoryStatus() { return _memoryStatus; }
|
||||
CC_INLINE GFXContext *getContext() const { return _context; }
|
||||
CC_INLINE GFXQueue *getQueue() const { return _queue; }
|
||||
CC_INLINE GFXCommandAllocator *getCommandAllocator() const { return _cmdAllocator; }
|
||||
CC_INLINE MemoryStatus &getMemoryStatus() { return _memoryStatus; }
|
||||
CC_INLINE Context *getContext() const { return _context; }
|
||||
CC_INLINE Queue *getQueue() const { return _queue; }
|
||||
CC_INLINE CommandAllocator *getCommandAllocator() const { return _cmdAllocator; }
|
||||
CC_INLINE const String &getRenderer() const { return _renderer; }
|
||||
CC_INLINE const String &getVendor() const { return _vendor; }
|
||||
CC_INLINE uint getNumDrawCalls() const { return _numDrawCalls; }
|
||||
@@ -62,30 +62,30 @@ public:
|
||||
CC_INLINE int getStencilBits() const { return _stencilBits; }
|
||||
CC_INLINE uint getShaderIdGen() { return _shaderIdGen++; }
|
||||
CC_INLINE bool getReverseCW() const { return _reverseCW; }
|
||||
GFXFormat getColorFormat() const;
|
||||
GFXFormat getDepthStencilFormat() const;
|
||||
CC_INLINE bool hasFeature(GFXFeature feature) const { return _features[static_cast<uint8_t>(feature)]; }
|
||||
Format getColorFormat() const;
|
||||
Format getDepthStencilFormat() const;
|
||||
CC_INLINE bool hasFeature(Feature feature) const { return _features[static_cast<uint8_t>(feature)]; }
|
||||
CC_INLINE void defineMacro(const String ¯o, const String &value) { _macros[macro] = value; }
|
||||
CC_INLINE void setReverseCW(bool reverseCW) { _reverseCW = reverseCW; }
|
||||
CC_INLINE float getMinClipZ() const { return _minClipZ; }
|
||||
CC_INLINE float getProjectionSignY() const { return _projectionSignY; }
|
||||
|
||||
protected:
|
||||
GFXAPI _gfxAPI = GFXAPI::UNKNOWN;
|
||||
API _API = API::UNKNOWN;
|
||||
String _deviceName;
|
||||
String _renderer;
|
||||
String _vendor;
|
||||
String _version;
|
||||
bool _features[static_cast<uint8_t>(GFXFeature::COUNT)];
|
||||
bool _features[static_cast<uint8_t>(Feature::COUNT)];
|
||||
uint _width = 0;
|
||||
uint _height = 0;
|
||||
uint _nativeWidth = 0;
|
||||
uint _nativeHeight = 0;
|
||||
GFXMemoryStatus _memoryStatus;
|
||||
MemoryStatus _memoryStatus;
|
||||
uintptr_t _windowHandle = 0;
|
||||
GFXContext *_context = nullptr;
|
||||
GFXQueue *_queue = nullptr;
|
||||
GFXCommandAllocator *_cmdAllocator = nullptr;
|
||||
Context *_context = nullptr;
|
||||
Queue *_queue = nullptr;
|
||||
CommandAllocator *_cmdAllocator = nullptr;
|
||||
uint _numDrawCalls = 0;
|
||||
uint _numInstances = 0;
|
||||
uint _numTriangles = 0;
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXFence::GFXFence(GFXDevice *device)
|
||||
: GFXObject(GFXObjectType::FENCE), _device(device) {
|
||||
Fence::Fence(Device *device)
|
||||
: GFXObject(ObjectType::FENCE), _device(device) {
|
||||
}
|
||||
|
||||
GFXFence::~GFXFence() {
|
||||
Fence::~Fence() {
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXFence : public GFXObject {
|
||||
class CC_DLL Fence : public GFXObject {
|
||||
public:
|
||||
GFXFence(GFXDevice *device);
|
||||
virtual ~GFXFence();
|
||||
Fence(Device *device);
|
||||
virtual ~Fence();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXFenceInfo &info) = 0;
|
||||
virtual bool initialize(const FenceInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual void wait() = 0;
|
||||
virtual void reset() = 0;
|
||||
|
||||
protected:
|
||||
GFXDevice *_device = nullptr;
|
||||
Device *_device = nullptr;
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXFramebuffer::GFXFramebuffer(GFXDevice *device)
|
||||
: GFXObject(GFXObjectType::FRAMEBUFFER), _device(device) {
|
||||
Framebuffer::Framebuffer(Device *device)
|
||||
: GFXObject(ObjectType::FRAMEBUFFER), _device(device) {
|
||||
}
|
||||
|
||||
GFXFramebuffer::~GFXFramebuffer() {
|
||||
Framebuffer::~Framebuffer() {
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,26 +6,26 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXFramebuffer : public GFXObject {
|
||||
class CC_DLL Framebuffer : public GFXObject {
|
||||
public:
|
||||
GFXFramebuffer(GFXDevice *device);
|
||||
virtual ~GFXFramebuffer();
|
||||
Framebuffer(Device *device);
|
||||
virtual ~Framebuffer();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXFramebufferInfo &info) = 0;
|
||||
virtual bool initialize(const FramebufferInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
|
||||
CC_INLINE GFXDevice *getDevice() const { return _device; }
|
||||
CC_INLINE GFXRenderPass *getRenderPass() const { return _renderPass; }
|
||||
CC_INLINE const GFXTextureList &getColorTextures() const { return _colorTextures; }
|
||||
CC_INLINE GFXTexture *getDepthStencilTexture() const { return _depthStencilTexture; }
|
||||
CC_INLINE Device *getDevice() const { return _device; }
|
||||
CC_INLINE RenderPass *getRenderPass() const { return _renderPass; }
|
||||
CC_INLINE const TextureList &getColorTextures() const { return _colorTextures; }
|
||||
CC_INLINE Texture *getDepthStencilTexture() const { return _depthStencilTexture; }
|
||||
CC_INLINE bool isOffscreen() const { return _isOffscreen; }
|
||||
|
||||
protected:
|
||||
GFXDevice *_device = nullptr;
|
||||
GFXRenderPass *_renderPass = nullptr;
|
||||
GFXTextureList _colorTextures;
|
||||
GFXTexture *_depthStencilTexture = nullptr;
|
||||
Device *_device = nullptr;
|
||||
RenderPass *_renderPass = nullptr;
|
||||
TextureList _colorTextures;
|
||||
Texture *_depthStencilTexture = nullptr;
|
||||
bool _isOffscreen = true;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXInputAssembler::GFXInputAssembler(GFXDevice *device)
|
||||
: GFXObject(GFXObjectType::INPUT_ASSEMBLER), _device(device) {
|
||||
InputAssembler::InputAssembler(Device *device)
|
||||
: GFXObject(ObjectType::INPUT_ASSEMBLER), _device(device) {
|
||||
}
|
||||
|
||||
GFXInputAssembler::~GFXInputAssembler() {
|
||||
InputAssembler::~InputAssembler() {
|
||||
}
|
||||
|
||||
void GFXInputAssembler::extractDrawInfo(GFXDrawInfo &drawInfo) const {
|
||||
void InputAssembler::extractDrawInfo(DrawInfo &drawInfo) const {
|
||||
drawInfo.vertexCount = _vertexCount;
|
||||
drawInfo.firstVertex = _firstVertex;
|
||||
drawInfo.indexCount = _indexCount;
|
||||
@@ -21,9 +21,9 @@ void GFXInputAssembler::extractDrawInfo(GFXDrawInfo &drawInfo) const {
|
||||
drawInfo.firstInstance = _firstInstance;
|
||||
}
|
||||
|
||||
uint GFXInputAssembler::computeAttributesHash() const {
|
||||
uint InputAssembler::computeAttributesHash() const {
|
||||
// https://stackoverflow.com/questions/20511347/a-good-hash-function-for-a-vector
|
||||
// 6: GFXAttribute has 6 elements.
|
||||
// 6: Attribute has 6 elements.
|
||||
std::size_t seed = _attributes.size() * 6;
|
||||
for (const auto attribute : _attributes) {
|
||||
seed ^= std::hash<std::string>{}(attribute.name) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
|
||||
@@ -6,22 +6,22 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXInputAssembler : public GFXObject {
|
||||
class CC_DLL InputAssembler : public GFXObject {
|
||||
public:
|
||||
GFXInputAssembler(GFXDevice *device);
|
||||
virtual ~GFXInputAssembler();
|
||||
InputAssembler(Device *device);
|
||||
virtual ~InputAssembler();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXInputAssemblerInfo &info) = 0;
|
||||
virtual bool initialize(const InputAssemblerInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
|
||||
void extractDrawInfo(GFXDrawInfo &drawInfo) const;
|
||||
void extractDrawInfo(DrawInfo &drawInfo) const;
|
||||
|
||||
CC_INLINE GFXDevice *getDevice() const { return _device; }
|
||||
CC_INLINE const GFXAttributeList &getAttributes() const { return _attributes; }
|
||||
CC_INLINE const GFXBufferList &getVertexBuffers() const { return _vertexBuffers; }
|
||||
CC_INLINE GFXBuffer *getIndexBuffer() const { return _indexBuffer; }
|
||||
CC_INLINE GFXBuffer *getIndirectBuffer() const { return _indirectBuffer; }
|
||||
CC_INLINE Device *getDevice() const { return _device; }
|
||||
CC_INLINE const AttributeList &getAttributes() const { return _attributes; }
|
||||
CC_INLINE const BufferList &getVertexBuffers() const { return _vertexBuffers; }
|
||||
CC_INLINE Buffer *getIndexBuffer() const { return _indexBuffer; }
|
||||
CC_INLINE Buffer *getIndirectBuffer() const { return _indirectBuffer; }
|
||||
CC_INLINE uint getVertexCount() const { return _vertexCount; }
|
||||
CC_INLINE uint getFirstVertex() const { return _firstVertex; }
|
||||
CC_INLINE uint getIndexCount() const { return _indexCount; }
|
||||
@@ -42,11 +42,11 @@ public:
|
||||
protected:
|
||||
uint computeAttributesHash() const;
|
||||
|
||||
GFXDevice *_device = nullptr;
|
||||
GFXAttributeList _attributes;
|
||||
GFXBufferList _vertexBuffers;
|
||||
GFXBuffer *_indexBuffer = nullptr;
|
||||
GFXBuffer *_indirectBuffer = nullptr;
|
||||
Device *_device = nullptr;
|
||||
AttributeList _attributes;
|
||||
BufferList _vertexBuffers;
|
||||
Buffer *_indexBuffer = nullptr;
|
||||
Buffer *_indirectBuffer = nullptr;
|
||||
uint _vertexCount = 0;
|
||||
uint _firstVertex = 0;
|
||||
uint _indexCount = 0;
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXObject::GFXObject(GFXObjectType gfxType)
|
||||
: _gfxType(gfxType) {}
|
||||
GFXObject::GFXObject(ObjectType Type)
|
||||
: _Type(Type) {}
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace cc
|
||||
|
||||
@@ -7,15 +7,15 @@ namespace gfx {
|
||||
|
||||
class GFXObject : public Object {
|
||||
public:
|
||||
GFXObject(GFXObjectType gfxType);
|
||||
GFXObject(ObjectType Type);
|
||||
virtual ~GFXObject() = default;
|
||||
|
||||
CC_INLINE GFXObjectType getType() const { return _gfxType; }
|
||||
CC_INLINE GFXStatus getStatus() const { return _status; }
|
||||
CC_INLINE ObjectType getType() const { return _Type; }
|
||||
CC_INLINE Status getStatus() const { return _status; }
|
||||
|
||||
protected:
|
||||
GFXObjectType _gfxType = GFXObjectType::UNKNOWN;
|
||||
GFXStatus _status = GFXStatus::UNREADY;
|
||||
ObjectType _Type = ObjectType::UNKNOWN;
|
||||
Status _status = Status::UNREADY;
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXPipelineLayout::GFXPipelineLayout(GFXDevice *device)
|
||||
: GFXObject(GFXObjectType::PIPELINE_LAYOUT), _device(device) {
|
||||
PipelineLayout::PipelineLayout(Device *device)
|
||||
: GFXObject(ObjectType::PIPELINE_LAYOUT), _device(device) {
|
||||
}
|
||||
|
||||
GFXPipelineLayout::~GFXPipelineLayout() {
|
||||
PipelineLayout::~PipelineLayout() {
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,23 +6,23 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXPipelineLayout : public GFXObject {
|
||||
class CC_DLL PipelineLayout : public GFXObject {
|
||||
public:
|
||||
GFXPipelineLayout(GFXDevice *device);
|
||||
virtual ~GFXPipelineLayout();
|
||||
PipelineLayout(Device *device);
|
||||
virtual ~PipelineLayout();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXPipelineLayoutInfo &info) = 0;
|
||||
virtual bool initialize(const PipelineLayoutInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
|
||||
CC_INLINE GFXDevice *getDevice() const { return _device; }
|
||||
CC_INLINE const GFXPushConstantRangeList &getPushConstantsRanges() const { return _pushConstantsRanges; }
|
||||
CC_INLINE const GFXBindingLayoutList &getLayouts() const { return _layouts; }
|
||||
CC_INLINE Device *getDevice() const { return _device; }
|
||||
CC_INLINE const PushConstantRangeList &getPushConstantsRanges() const { return _pushConstantsRanges; }
|
||||
CC_INLINE const BindingLayoutList &getLayouts() const { return _layouts; }
|
||||
|
||||
protected:
|
||||
GFXDevice *_device = nullptr;
|
||||
GFXPushConstantRangeList _pushConstantsRanges;
|
||||
GFXBindingLayoutList _layouts;
|
||||
Device *_device = nullptr;
|
||||
PushConstantRangeList _pushConstantsRanges;
|
||||
BindingLayoutList _layouts;
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXPipelineState::GFXPipelineState(GFXDevice *device)
|
||||
: GFXObject(GFXObjectType::PIPELINE_STATE), _device(device) {
|
||||
PipelineState::PipelineState(Device *device)
|
||||
: GFXObject(ObjectType::PIPELINE_STATE), _device(device) {
|
||||
}
|
||||
|
||||
GFXPipelineState::~GFXPipelineState() {
|
||||
PipelineState::~PipelineState() {
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,37 +6,37 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXPipelineState : public GFXObject {
|
||||
class CC_DLL PipelineState : public GFXObject {
|
||||
public:
|
||||
GFXPipelineState(GFXDevice *device);
|
||||
virtual ~GFXPipelineState();
|
||||
PipelineState(Device *device);
|
||||
virtual ~PipelineState();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXPipelineStateInfo &info) = 0;
|
||||
virtual bool initialize(const PipelineStateInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
|
||||
CC_INLINE GFXDevice *getDevice() const { return _device; }
|
||||
CC_INLINE GFXShader *getShader() const { return _shader; }
|
||||
CC_INLINE GFXPrimitiveMode getPrimitive() const { return _primitive; }
|
||||
CC_INLINE const GFXInputState &getInputState() const { return _inputState; }
|
||||
CC_INLINE const GFXRasterizerState &getRasterizerState() const { return _rasterizerState; }
|
||||
CC_INLINE const GFXDepthStencilState &getDepthStencilState() const { return _depthStencilState; }
|
||||
CC_INLINE const GFXBlendState &getBlendState() const { return _blendState; }
|
||||
CC_INLINE const GFXDynamicStateList &getDynamicStates() const { return _dynamicStates; }
|
||||
CC_INLINE const GFXPipelineLayout *getPipelineLayout() const { return _layout; }
|
||||
CC_INLINE const GFXRenderPass *getRenderPass() const { return _renderPass; }
|
||||
CC_INLINE Device *getDevice() const { return _device; }
|
||||
CC_INLINE Shader *getShader() const { return _shader; }
|
||||
CC_INLINE PrimitiveMode getPrimitive() const { return _primitive; }
|
||||
CC_INLINE const InputState &getInputState() const { return _inputState; }
|
||||
CC_INLINE const RasterizerState &getRasterizerState() const { return _rasterizerState; }
|
||||
CC_INLINE const DepthStencilState &getDepthStencilState() const { return _depthStencilState; }
|
||||
CC_INLINE const BlendState &getBlendState() const { return _blendState; }
|
||||
CC_INLINE const DynamicStateList &getDynamicStates() const { return _dynamicStates; }
|
||||
CC_INLINE const PipelineLayout *getPipelineLayout() const { return _layout; }
|
||||
CC_INLINE const RenderPass *getRenderPass() const { return _renderPass; }
|
||||
|
||||
protected:
|
||||
GFXDevice *_device = nullptr;
|
||||
GFXShader *_shader = nullptr;
|
||||
GFXPrimitiveMode _primitive = GFXPrimitiveMode::TRIANGLE_LIST;
|
||||
GFXInputState _inputState;
|
||||
GFXRasterizerState _rasterizerState;
|
||||
GFXDepthStencilState _depthStencilState;
|
||||
GFXBlendState _blendState;
|
||||
GFXDynamicStateList _dynamicStates;
|
||||
GFXPipelineLayout *_layout = nullptr;
|
||||
GFXRenderPass *_renderPass = nullptr;
|
||||
Device *_device = nullptr;
|
||||
Shader *_shader = nullptr;
|
||||
PrimitiveMode _primitive = PrimitiveMode::TRIANGLE_LIST;
|
||||
InputState _inputState;
|
||||
RasterizerState _rasterizerState;
|
||||
DepthStencilState _depthStencilState;
|
||||
BlendState _blendState;
|
||||
DynamicStateList _dynamicStates;
|
||||
PipelineLayout *_layout = nullptr;
|
||||
RenderPass *_renderPass = nullptr;
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXQueue::GFXQueue(GFXDevice *device)
|
||||
: GFXObject(GFXObjectType::QUEUE), _device(device) {
|
||||
Queue::Queue(Device *device)
|
||||
: GFXObject(ObjectType::QUEUE), _device(device) {
|
||||
}
|
||||
|
||||
GFXQueue::~GFXQueue() {
|
||||
Queue::~Queue() {
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,24 +6,24 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXQueue : public GFXObject {
|
||||
class CC_DLL Queue : public GFXObject {
|
||||
public:
|
||||
GFXQueue(GFXDevice *device);
|
||||
virtual ~GFXQueue();
|
||||
Queue(Device *device);
|
||||
virtual ~Queue();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXQueueInfo &info) = 0;
|
||||
virtual bool initialize(const QueueInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual void submit(const vector<GFXCommandBuffer *> &cmdBuffs, GFXFence *fence) = 0;
|
||||
virtual void submit(const vector<CommandBuffer *> &cmdBuffs, Fence *fence) = 0;
|
||||
|
||||
CC_INLINE void submit(const vector<GFXCommandBuffer *> &cmdBuffs) { submit(cmdBuffs, nullptr); }
|
||||
CC_INLINE GFXDevice *getDevice() const { return _device; }
|
||||
CC_INLINE GFXQueueType getType() const { return _type; }
|
||||
CC_INLINE void submit(const vector<CommandBuffer *> &cmdBuffs) { submit(cmdBuffs, nullptr); }
|
||||
CC_INLINE Device *getDevice() const { return _device; }
|
||||
CC_INLINE QueueType getType() const { return _type; }
|
||||
CC_INLINE bool isAsync() const { return _isAsync; }
|
||||
|
||||
protected:
|
||||
GFXDevice *_device = nullptr;
|
||||
GFXQueueType _type = GFXQueueType::GRAPHICS;
|
||||
Device *_device = nullptr;
|
||||
QueueType _type = QueueType::GRAPHICS;
|
||||
bool _isAsync = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXRenderPass::GFXRenderPass(GFXDevice *device)
|
||||
: GFXObject(GFXObjectType::RENDER_PASS), _device(device) {
|
||||
RenderPass::RenderPass(Device *device)
|
||||
: GFXObject(ObjectType::RENDER_PASS), _device(device) {
|
||||
}
|
||||
|
||||
GFXRenderPass::~GFXRenderPass() {
|
||||
RenderPass::~RenderPass() {
|
||||
}
|
||||
|
||||
uint GFXRenderPass::computeHash() const {
|
||||
uint RenderPass::computeHash() const {
|
||||
// https://stackoverflow.com/questions/20511347/a-good-hash-function-for-a-vector
|
||||
// 6: GFXColorAttament has 6 elements.
|
||||
// 8: GFXDepthStencilAttachment has 8 elements.
|
||||
// 6: ColorAttament has 6 elements.
|
||||
// 8: DepthStencilAttachment has 8 elements.
|
||||
uint seed = _colorAttachments.size() * 6 + 8;
|
||||
for (const auto &colorAttachment : _colorAttachments) {
|
||||
seed ^= (uint)(colorAttachment.format) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
|
||||
@@ -6,28 +6,28 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXRenderPass : public GFXObject {
|
||||
class CC_DLL RenderPass : public GFXObject {
|
||||
public:
|
||||
GFXRenderPass(GFXDevice *device);
|
||||
virtual ~GFXRenderPass();
|
||||
RenderPass(Device *device);
|
||||
virtual ~RenderPass();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXRenderPassInfo &info) = 0;
|
||||
virtual bool initialize(const RenderPassInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
|
||||
CC_INLINE GFXDevice *getDevice() const { return _device; }
|
||||
CC_INLINE const GFXColorAttachmentList &getColorAttachments() const { return _colorAttachments; }
|
||||
CC_INLINE const GFXDepthStencilAttachment &getDepthStencilAttachment() const { return _depthStencilAttachment; }
|
||||
CC_INLINE const GFXSubPassList &getSubPasses() const { return _subPasses; }
|
||||
CC_INLINE Device *getDevice() const { return _device; }
|
||||
CC_INLINE const ColorAttachmentList &getColorAttachments() const { return _colorAttachments; }
|
||||
CC_INLINE const DepthStencilAttachment &getDepthStencilAttachment() const { return _depthStencilAttachment; }
|
||||
CC_INLINE const SubPassList &getSubPasses() const { return _subPasses; }
|
||||
CC_INLINE uint getHash() const { return _hash; }
|
||||
|
||||
protected:
|
||||
uint computeHash() const;
|
||||
|
||||
GFXDevice *_device = nullptr;
|
||||
GFXColorAttachmentList _colorAttachments;
|
||||
GFXDepthStencilAttachment _depthStencilAttachment;
|
||||
GFXSubPassList _subPasses;
|
||||
Device *_device = nullptr;
|
||||
ColorAttachmentList _colorAttachments;
|
||||
DepthStencilAttachment _depthStencilAttachment;
|
||||
SubPassList _subPasses;
|
||||
uint _hash = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXSampler::GFXSampler(GFXDevice *device)
|
||||
: GFXObject(GFXObjectType::SAMPLER), _device(device) {
|
||||
Sampler::Sampler(Device *device)
|
||||
: GFXObject(ObjectType::SAMPLER), _device(device) {
|
||||
_borderColor.r = 0.0f;
|
||||
_borderColor.g = 0.0f;
|
||||
_borderColor.b = 0.0f;
|
||||
_borderColor.a = 0.0f;
|
||||
}
|
||||
|
||||
GFXSampler::~GFXSampler() {
|
||||
Sampler::~Sampler() {
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,42 +6,42 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXSampler : public GFXObject {
|
||||
class CC_DLL Sampler : public GFXObject {
|
||||
public:
|
||||
GFXSampler(GFXDevice *device);
|
||||
virtual ~GFXSampler();
|
||||
Sampler(Device *device);
|
||||
virtual ~Sampler();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXSamplerInfo &info) = 0;
|
||||
virtual bool initialize(const SamplerInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
|
||||
CC_INLINE GFXDevice *getDevice() const { return _device; }
|
||||
CC_INLINE Device *getDevice() const { return _device; }
|
||||
CC_INLINE const String &getName() const { return _name; }
|
||||
CC_INLINE GFXFilter getMinFilter() const { return _minFilter; }
|
||||
CC_INLINE GFXFilter getMagFilter() const { return _magFilter; }
|
||||
CC_INLINE GFXFilter getMipFilter() const { return _mipFilter; }
|
||||
CC_INLINE GFXAddress getAddressU() const { return _addressU; }
|
||||
CC_INLINE GFXAddress getAddressV() const { return _addressV; }
|
||||
CC_INLINE GFXAddress getAddressW() const { return _addressW; }
|
||||
CC_INLINE Filter getMinFilter() const { return _minFilter; }
|
||||
CC_INLINE Filter getMagFilter() const { return _magFilter; }
|
||||
CC_INLINE Filter getMipFilter() const { return _mipFilter; }
|
||||
CC_INLINE Address getAddressU() const { return _addressU; }
|
||||
CC_INLINE Address getAddressV() const { return _addressV; }
|
||||
CC_INLINE Address getAddressW() const { return _addressW; }
|
||||
CC_INLINE uint getMaxAnisotropy() const { return _maxAnisotropy; }
|
||||
CC_INLINE GFXComparisonFunc getCmpFunc() const { return _cmpFunc; }
|
||||
CC_INLINE const GFXColor &getBorderColor() const { return _borderColor; }
|
||||
CC_INLINE ComparisonFunc getCmpFunc() const { return _cmpFunc; }
|
||||
CC_INLINE const Color &getBorderColor() const { return _borderColor; }
|
||||
CC_INLINE uint getMinLOD() const { return _minLOD; }
|
||||
CC_INLINE uint getMaxLOD() const { return _maxLOD; }
|
||||
CC_INLINE float getMipLODBias() const { return _mipLODBias; }
|
||||
|
||||
protected:
|
||||
GFXDevice *_device = nullptr;
|
||||
Device *_device = nullptr;
|
||||
String _name;
|
||||
GFXFilter _minFilter = GFXFilter::NONE;
|
||||
GFXFilter _magFilter = GFXFilter::NONE;
|
||||
GFXFilter _mipFilter = GFXFilter::NONE;
|
||||
GFXAddress _addressU = GFXAddress::WRAP;
|
||||
GFXAddress _addressV = GFXAddress::WRAP;
|
||||
GFXAddress _addressW = GFXAddress::WRAP;
|
||||
Filter _minFilter = Filter::NONE;
|
||||
Filter _magFilter = Filter::NONE;
|
||||
Filter _mipFilter = Filter::NONE;
|
||||
Address _addressU = Address::WRAP;
|
||||
Address _addressV = Address::WRAP;
|
||||
Address _addressW = Address::WRAP;
|
||||
uint _maxAnisotropy = 0;
|
||||
GFXComparisonFunc _cmpFunc = GFXComparisonFunc::ALWAYS;
|
||||
GFXColor _borderColor;
|
||||
ComparisonFunc _cmpFunc = ComparisonFunc::ALWAYS;
|
||||
Color _borderColor;
|
||||
uint _minLOD = 0;
|
||||
uint _maxLOD = 0;
|
||||
float _mipLODBias = 0.0f;
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXShader::GFXShader(GFXDevice *device)
|
||||
: GFXObject(GFXObjectType::SHADER), _device(device) {
|
||||
Shader::Shader(Device *device)
|
||||
: GFXObject(ObjectType::SHADER), _device(device) {
|
||||
}
|
||||
|
||||
GFXShader::~GFXShader() {
|
||||
Shader::~Shader() {
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,32 +6,32 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXShader : public GFXObject {
|
||||
class CC_DLL Shader : public GFXObject {
|
||||
public:
|
||||
GFXShader(GFXDevice *device);
|
||||
virtual ~GFXShader();
|
||||
Shader(Device *device);
|
||||
virtual ~Shader();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXShaderInfo &info) = 0;
|
||||
virtual bool initialize(const ShaderInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
|
||||
CC_INLINE GFXDevice *getDevice() const { return _device; }
|
||||
CC_INLINE Device *getDevice() const { return _device; }
|
||||
// Can not rename to `id` as JS code, because `id` is a keyword in objective-c.
|
||||
CC_INLINE uint getHash() const { return _hash; }
|
||||
CC_INLINE const String &getName() const { return _name; }
|
||||
CC_INLINE const GFXShaderStageList &getStages() const { return _stages; }
|
||||
CC_INLINE const GFXAttributeList &getAttributes() const { return _attributes; }
|
||||
CC_INLINE const GFXUniformBlockList &getBlocks() const { return _blocks; }
|
||||
CC_INLINE const GFXUniformSamplerList &getSamplers() const { return _samplers; }
|
||||
CC_INLINE const ShaderStageList &getStages() const { return _stages; }
|
||||
CC_INLINE const AttributeList &getAttributes() const { return _attributes; }
|
||||
CC_INLINE const UniformBlockList &getBlocks() const { return _blocks; }
|
||||
CC_INLINE const UniformSamplerList &getSamplers() const { return _samplers; }
|
||||
|
||||
protected:
|
||||
GFXDevice *_device = nullptr;
|
||||
Device *_device = nullptr;
|
||||
uint _hash = 0;
|
||||
String _name;
|
||||
GFXShaderStageList _stages;
|
||||
GFXAttributeList _attributes;
|
||||
GFXUniformBlockList _blocks;
|
||||
GFXUniformSamplerList _samplers;
|
||||
ShaderStageList _stages;
|
||||
AttributeList _attributes;
|
||||
UniformBlockList _blocks;
|
||||
UniformSamplerList _samplers;
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GFXTexture::GFXTexture(GFXDevice *device)
|
||||
: GFXObject(GFXObjectType::TEXTURE), _device(device) {
|
||||
Texture::Texture(Device *device)
|
||||
: GFXObject(ObjectType::TEXTURE), _device(device) {
|
||||
}
|
||||
|
||||
GFXTexture::~GFXTexture() {
|
||||
Texture::~Texture() {
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,43 +6,43 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_DLL GFXTexture : public GFXObject {
|
||||
class CC_DLL Texture : public GFXObject {
|
||||
public:
|
||||
GFXTexture(GFXDevice *device);
|
||||
virtual ~GFXTexture();
|
||||
Texture(Device *device);
|
||||
virtual ~Texture();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXTextureInfo &info) = 0;
|
||||
virtual bool initialize(const GFXTextureViewInfo &info) = 0;
|
||||
virtual bool initialize(const TextureInfo &info) = 0;
|
||||
virtual bool initialize(const TextureViewInfo &info) = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual void resize(uint width, uint height) = 0;
|
||||
|
||||
CC_INLINE GFXTextureType getType() const { return _type; }
|
||||
CC_INLINE GFXTextureUsage getUsage() const { return _usage; }
|
||||
CC_INLINE GFXFormat getFormat() const { return _format; }
|
||||
CC_INLINE TextureType getType() const { return _type; }
|
||||
CC_INLINE TextureUsage getUsage() const { return _usage; }
|
||||
CC_INLINE Format getFormat() const { return _format; }
|
||||
CC_INLINE uint getWidth() const { return _width; }
|
||||
CC_INLINE uint getHeight() const { return _height; }
|
||||
CC_INLINE uint getDepth() const { return _depth; }
|
||||
CC_INLINE uint getArrayLayer() const { return _arrayLayer; }
|
||||
CC_INLINE uint getMipLevel() const { return _mipLevel; }
|
||||
CC_INLINE uint getSize() const { return _size; }
|
||||
CC_INLINE GFXSampleCount getSamples() const { return _samples; }
|
||||
CC_INLINE GFXTextureFlags getFlags() const { return _flags; }
|
||||
CC_INLINE SampleCount getSamples() const { return _samples; }
|
||||
CC_INLINE TextureFlags getFlags() const { return _flags; }
|
||||
CC_INLINE uint8_t *getBuffer() const { return _buffer; }
|
||||
|
||||
protected:
|
||||
GFXDevice *_device = nullptr;
|
||||
GFXTextureType _type = GFXTextureType::TEX2D;
|
||||
GFXTextureUsage _usage = GFXTextureUsageBit::NONE;
|
||||
GFXFormat _format = GFXFormat::UNKNOWN;
|
||||
Device *_device = nullptr;
|
||||
TextureType _type = TextureType::TEX2D;
|
||||
TextureUsage _usage = TextureUsageBit::NONE;
|
||||
Format _format = Format::UNKNOWN;
|
||||
uint _width = 0;
|
||||
uint _height = 0;
|
||||
uint _depth = 1;
|
||||
uint _arrayLayer = 1;
|
||||
uint _mipLevel = 1;
|
||||
uint _size = 0;
|
||||
GFXSampleCount _samples = GFXSampleCount::X1;
|
||||
GFXTextureFlags _flags = GFXTextureFlagBit::NONE;
|
||||
SampleCount _samples = SampleCount::X1;
|
||||
TextureFlags _flags = TextureFlagBit::NONE;
|
||||
uint8_t *_buffer = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -8,20 +8,20 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES2BindingLayout::GLES2BindingLayout(GFXDevice *device)
|
||||
: GFXBindingLayout(device) {
|
||||
GLES2BindingLayout::GLES2BindingLayout(Device *device)
|
||||
: BindingLayout(device) {
|
||||
}
|
||||
|
||||
GLES2BindingLayout::~GLES2BindingLayout() {
|
||||
}
|
||||
|
||||
bool GLES2BindingLayout::initialize(const GFXBindingLayoutInfo &info) {
|
||||
bool GLES2BindingLayout::initialize(const BindingLayoutInfo &info) {
|
||||
|
||||
if (info.bindings.size()) {
|
||||
_bindingUnits.resize(info.bindings.size());
|
||||
for (size_t i = 0; i < _bindingUnits.size(); ++i) {
|
||||
GFXBindingUnit &bindingUnit = _bindingUnits[i];
|
||||
const GFXBinding &binding = info.bindings[i];
|
||||
BindingUnit &bindingUnit = _bindingUnits[i];
|
||||
const Binding &binding = info.bindings[i];
|
||||
bindingUnit.shaderStages = binding.shaderStages;
|
||||
bindingUnit.binding = binding.binding;
|
||||
bindingUnit.type = binding.type;
|
||||
@@ -33,13 +33,13 @@ bool GLES2BindingLayout::initialize(const GFXBindingLayoutInfo &info) {
|
||||
_gpuBindingLayout->gpuBindings.resize(_bindingUnits.size());
|
||||
for (size_t i = 0; i < _gpuBindingLayout->gpuBindings.size(); ++i) {
|
||||
GLES2GPUBinding &gpuBinding = _gpuBindingLayout->gpuBindings[i];
|
||||
const GFXBindingUnit &bindingUnit = _bindingUnits[i];
|
||||
const BindingUnit &bindingUnit = _bindingUnits[i];
|
||||
gpuBinding.binding = bindingUnit.binding;
|
||||
gpuBinding.type = bindingUnit.type;
|
||||
gpuBinding.name = bindingUnit.name;
|
||||
}
|
||||
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -49,21 +49,21 @@ void GLES2BindingLayout::destroy() {
|
||||
CC_DELETE(_gpuBindingLayout);
|
||||
_gpuBindingLayout = nullptr;
|
||||
}
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
void GLES2BindingLayout::update() {
|
||||
if (_isDirty && _gpuBindingLayout) {
|
||||
for (size_t i = 0; i < _bindingUnits.size(); ++i) {
|
||||
GFXBindingUnit &bindingUnit = _bindingUnits[i];
|
||||
BindingUnit &bindingUnit = _bindingUnits[i];
|
||||
switch (bindingUnit.type) {
|
||||
case GFXBindingType::UNIFORM_BUFFER: {
|
||||
case BindingType::UNIFORM_BUFFER: {
|
||||
if (bindingUnit.buffer) {
|
||||
_gpuBindingLayout->gpuBindings[i].gpuBuffer = ((GLES2Buffer *)bindingUnit.buffer)->gpuBuffer();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GFXBindingType::SAMPLER: {
|
||||
case BindingType::SAMPLER: {
|
||||
if (bindingUnit.texture) {
|
||||
_gpuBindingLayout->gpuBindings[i].gpuTexture = ((GLES2Texture *)bindingUnit.texture)->gpuTexture();
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace gfx {
|
||||
|
||||
class GLES2GPUBindingLayout;
|
||||
|
||||
class CC_GLES2_API GLES2BindingLayout : public GFXBindingLayout {
|
||||
class CC_GLES2_API GLES2BindingLayout : public BindingLayout {
|
||||
public:
|
||||
GLES2BindingLayout(GFXDevice *device);
|
||||
GLES2BindingLayout(Device *device);
|
||||
~GLES2BindingLayout();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXBindingLayoutInfo &info) override;
|
||||
virtual bool initialize(const BindingLayoutInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
virtual void update() override;
|
||||
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES2Buffer::GLES2Buffer(GFXDevice *device)
|
||||
: GFXBuffer(device) {
|
||||
GLES2Buffer::GLES2Buffer(Device *device)
|
||||
: Buffer(device) {
|
||||
}
|
||||
|
||||
GLES2Buffer::~GLES2Buffer() {
|
||||
}
|
||||
|
||||
bool GLES2Buffer::initialize(const GFXBufferInfo &info) {
|
||||
bool GLES2Buffer::initialize(const BufferInfo &info) {
|
||||
|
||||
_usage = info.usage;
|
||||
_memUsage = info.memUsage;
|
||||
@@ -21,10 +21,10 @@ bool GLES2Buffer::initialize(const GFXBufferInfo &info) {
|
||||
_count = _size / _stride;
|
||||
_flags = info.flags;
|
||||
|
||||
if ((_flags & GFXBufferFlagBit::BAKUP_BUFFER) && _size > 0) {
|
||||
if ((_flags & BufferFlagBit::BAKUP_BUFFER) && _size > 0) {
|
||||
_buffer = (uint8_t *)CC_MALLOC(_size);
|
||||
if (!_buffer) {
|
||||
_status = GFXStatus::FAILED;
|
||||
_status = Status::FAILED;
|
||||
CC_LOG_ERROR("GLES2Buffer: CC_MALLOC backup buffer faild.");
|
||||
return false;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ bool GLES2Buffer::initialize(const GFXBufferInfo &info) {
|
||||
|
||||
_gpuBuffer = CC_NEW(GLES2GPUBuffer);
|
||||
if (!_gpuBuffer) {
|
||||
_status = GFXStatus::FAILED;
|
||||
_status = Status::FAILED;
|
||||
CC_LOG_ERROR("GLES2Buffer: CC_NEW GLES2GPUBuffer failed.");
|
||||
return false;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ bool GLES2Buffer::initialize(const GFXBufferInfo &info) {
|
||||
_gpuBuffer->stride = _stride;
|
||||
_gpuBuffer->count = _count;
|
||||
|
||||
if (_usage & GFXBufferUsageBit::INDIRECT) {
|
||||
if (_usage & BufferUsageBit::INDIRECT) {
|
||||
_gpuBuffer->indirects.resize(_count);
|
||||
} else {
|
||||
_gpuBuffer->buffer = _buffer;
|
||||
@@ -52,7 +52,7 @@ bool GLES2Buffer::initialize(const GFXBufferInfo &info) {
|
||||
GLES2CmdFuncCreateBuffer((GLES2Device *)_device, _gpuBuffer);
|
||||
_device->getMemoryStatus().bufferSize += _size;
|
||||
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ void GLES2Buffer::destroy() {
|
||||
_buffer = nullptr;
|
||||
}
|
||||
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
void GLES2Buffer::resize(uint size) {
|
||||
@@ -80,7 +80,7 @@ void GLES2Buffer::resize(uint size) {
|
||||
_size = size;
|
||||
_count = _size / _stride;
|
||||
|
||||
GFXMemoryStatus &status = _device->getMemoryStatus();
|
||||
MemoryStatus &status = _device->getMemoryStatus();
|
||||
_gpuBuffer->size = _size;
|
||||
_gpuBuffer->count = _count;
|
||||
GLES2CmdFuncResizeBuffer((GLES2Device *)_device, _gpuBuffer);
|
||||
@@ -91,7 +91,7 @@ void GLES2Buffer::resize(uint size) {
|
||||
const uint8_t *oldBuffer = _buffer;
|
||||
uint8_t *buffer = (uint8_t *)CC_MALLOC(_size);
|
||||
if (!buffer) {
|
||||
_status = GFXStatus::FAILED;
|
||||
_status = Status::FAILED;
|
||||
CC_LOG_ERROR("GLES2Buffer: CC_MALLOC backup buffer failed.");
|
||||
return;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ void GLES2Buffer::resize(uint size) {
|
||||
status.bufferSize -= oldSize;
|
||||
status.bufferSize += _size;
|
||||
}
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace gfx {
|
||||
|
||||
class GLES2GPUBuffer;
|
||||
|
||||
class CC_GLES2_API GLES2Buffer : public GFXBuffer {
|
||||
class CC_GLES2_API GLES2Buffer : public Buffer {
|
||||
public:
|
||||
GLES2Buffer(GFXDevice *device);
|
||||
GLES2Buffer(Device *device);
|
||||
~GLES2Buffer();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXBufferInfo &info) override;
|
||||
virtual bool initialize(const BufferInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
virtual void resize(uint size) override;
|
||||
virtual void update(void *buffer, uint offset, uint size) override;
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES2CommandAllocator::GLES2CommandAllocator(GFXDevice *device)
|
||||
: GFXCommandAllocator(device) {
|
||||
GLES2CommandAllocator::GLES2CommandAllocator(Device *device)
|
||||
: CommandAllocator(device) {
|
||||
}
|
||||
|
||||
GLES2CommandAllocator::~GLES2CommandAllocator() {
|
||||
}
|
||||
|
||||
bool GLES2CommandAllocator::initialize(const GFXCommandAllocatorInfo &info) {
|
||||
_status = GFXStatus::SUCCESS;
|
||||
bool GLES2CommandAllocator::initialize(const CommandAllocatorInfo &info) {
|
||||
_status = Status::SUCCESS;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GLES2CommandAllocator::destroy() {
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
void GLES2CommandAllocator::clearCmds(GLES2CmdPackage *cmd_package) {
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_GLES2_API GLES2CommandAllocator : public GFXCommandAllocator {
|
||||
class CC_GLES2_API GLES2CommandAllocator : public CommandAllocator {
|
||||
public:
|
||||
GLES2CommandAllocator(GFXDevice *device);
|
||||
GLES2CommandAllocator(Device *device);
|
||||
~GLES2CommandAllocator();
|
||||
|
||||
GFXCommandPool<GLES2CmdBeginRenderPass> beginRenderPassCmdPool;
|
||||
GFXCommandPool<GLES2CmdBindStates> bindStatesCmdPool;
|
||||
GFXCommandPool<GLES2CmdDraw> drawCmdPool;
|
||||
GFXCommandPool<GLES2CmdUpdateBuffer> updateBufferCmdPool;
|
||||
GFXCommandPool<GLES2CmdCopyBufferToTexture> copyBufferToTextureCmdPool;
|
||||
CommandPool<GLES2CmdBeginRenderPass> beginRenderPassCmdPool;
|
||||
CommandPool<GLES2CmdBindStates> bindStatesCmdPool;
|
||||
CommandPool<GLES2CmdDraw> drawCmdPool;
|
||||
CommandPool<GLES2CmdUpdateBuffer> updateBufferCmdPool;
|
||||
CommandPool<GLES2CmdCopyBufferToTexture> copyBufferToTextureCmdPool;
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXCommandAllocatorInfo &info) override;
|
||||
virtual bool initialize(const CommandAllocatorInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
|
||||
void clearCmds(GLES2CmdPackage *cmd_package);
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES2CommandBuffer::GLES2CommandBuffer(GFXDevice *device)
|
||||
: GFXCommandBuffer(device) {
|
||||
GLES2CommandBuffer::GLES2CommandBuffer(Device *device)
|
||||
: CommandBuffer(device) {
|
||||
}
|
||||
|
||||
GLES2CommandBuffer::~GLES2CommandBuffer() {
|
||||
}
|
||||
|
||||
bool GLES2CommandBuffer::initialize(const GFXCommandBufferInfo &info) {
|
||||
bool GLES2CommandBuffer::initialize(const CommandBufferInfo &info) {
|
||||
|
||||
if (!info.allocator) {
|
||||
return false;
|
||||
@@ -29,7 +29,7 @@ bool GLES2CommandBuffer::initialize(const GFXCommandBufferInfo &info) {
|
||||
_type = info.type;
|
||||
|
||||
_cmdPackage = CC_NEW(GLES2CmdPackage);
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -40,12 +40,12 @@ void GLES2CommandBuffer::destroy() {
|
||||
_gles2Allocator = nullptr;
|
||||
}
|
||||
_allocator = nullptr;
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
|
||||
CC_SAFE_DELETE(_cmdPackage);
|
||||
}
|
||||
|
||||
void GLES2CommandBuffer::begin(GFXRenderPass *renderPass, uint subpass, GFXFramebuffer *frameBuffer) {
|
||||
void GLES2CommandBuffer::begin(RenderPass *renderPass, uint subpass, Framebuffer *frameBuffer) {
|
||||
_gles2Allocator->clearCmds(_cmdPackage);
|
||||
_curGPUPipelineState = nullptr;
|
||||
_curGPUBlendLayout = nullptr;
|
||||
@@ -62,7 +62,7 @@ void GLES2CommandBuffer::end() {
|
||||
_isInRenderPass = false;
|
||||
}
|
||||
|
||||
void GLES2CommandBuffer::beginRenderPass(GFXFramebuffer *fbo, const GFXRect &render_area, GFXClearFlags clear_flags, const std::vector<GFXColor> &colors, float depth, int stencil) {
|
||||
void GLES2CommandBuffer::beginRenderPass(Framebuffer *fbo, const Rect &render_area, ClearFlags clear_flags, const std::vector<Color> &colors, float depth, int stencil) {
|
||||
_isInRenderPass = true;
|
||||
|
||||
GLES2CmdBeginRenderPass *cmd = _gles2Allocator->beginRenderPassCmdPool.alloc();
|
||||
@@ -84,22 +84,22 @@ void GLES2CommandBuffer::endRenderPass() {
|
||||
_cmdPackage->cmds.push(GFXCmdType::END_RENDER_PASS);
|
||||
}
|
||||
|
||||
void GLES2CommandBuffer::bindPipelineState(GFXPipelineState *pso) {
|
||||
void GLES2CommandBuffer::bindPipelineState(PipelineState *pso) {
|
||||
_curGPUPipelineState = ((GLES2PipelineState *)pso)->gpuPipelineState();
|
||||
_isStateInvalid = true;
|
||||
}
|
||||
|
||||
void GLES2CommandBuffer::bindBindingLayout(GFXBindingLayout *layout) {
|
||||
void GLES2CommandBuffer::bindBindingLayout(BindingLayout *layout) {
|
||||
_curGPUBlendLayout = ((GLES2BindingLayout *)layout)->gpuBindingLayout();
|
||||
_isStateInvalid = true;
|
||||
}
|
||||
|
||||
void GLES2CommandBuffer::bindInputAssembler(GFXInputAssembler *ia) {
|
||||
void GLES2CommandBuffer::bindInputAssembler(InputAssembler *ia) {
|
||||
_curGPUInputAssember = ((GLES2InputAssembler *)ia)->gpuInputAssembler();
|
||||
_isStateInvalid = true;
|
||||
}
|
||||
|
||||
void GLES2CommandBuffer::setViewport(const GFXViewport &vp) {
|
||||
void GLES2CommandBuffer::setViewport(const Viewport &vp) {
|
||||
|
||||
if ((_curViewport.left != vp.left) ||
|
||||
(_curViewport.top != vp.top) ||
|
||||
@@ -112,7 +112,7 @@ void GLES2CommandBuffer::setViewport(const GFXViewport &vp) {
|
||||
}
|
||||
}
|
||||
|
||||
void GLES2CommandBuffer::setScissor(const GFXRect &rect) {
|
||||
void GLES2CommandBuffer::setScissor(const Rect &rect) {
|
||||
if ((_curScissor.x != rect.x) ||
|
||||
(_curScissor.y != rect.y) ||
|
||||
(_curScissor.width != rect.width) ||
|
||||
@@ -140,7 +140,7 @@ void GLES2CommandBuffer::setDepthBias(float constant, float clamp, float slope)
|
||||
}
|
||||
}
|
||||
|
||||
void GLES2CommandBuffer::setBlendConstants(const GFXColor &constants) {
|
||||
void GLES2CommandBuffer::setBlendConstants(const Color &constants) {
|
||||
if (math::IsNotEqualF(_curBlendConstants.r, constants.r) ||
|
||||
math::IsNotEqualF(_curBlendConstants.g, constants.g) ||
|
||||
math::IsNotEqualF(_curBlendConstants.b, constants.b) ||
|
||||
@@ -162,7 +162,7 @@ void GLES2CommandBuffer::setDepthBound(float min_bounds, float max_bounds) {
|
||||
}
|
||||
}
|
||||
|
||||
void GLES2CommandBuffer::setStencilWriteMask(GFXStencilFace face, uint mask) {
|
||||
void GLES2CommandBuffer::setStencilWriteMask(StencilFace face, uint mask) {
|
||||
if ((_curStencilWriteMask.face != face) ||
|
||||
(_curStencilWriteMask.write_mask != mask)) {
|
||||
_curStencilWriteMask.face = face;
|
||||
@@ -171,7 +171,7 @@ void GLES2CommandBuffer::setStencilWriteMask(GFXStencilFace face, uint mask) {
|
||||
}
|
||||
}
|
||||
|
||||
void GLES2CommandBuffer::setStencilCompareMask(GFXStencilFace face, int ref, uint mask) {
|
||||
void GLES2CommandBuffer::setStencilCompareMask(StencilFace face, int ref, uint mask) {
|
||||
if ((_curStencilCompareMask.face != face) ||
|
||||
(_curStencilCompareMask.refrence != ref) ||
|
||||
(_curStencilCompareMask.compare_mask != mask)) {
|
||||
@@ -182,9 +182,9 @@ void GLES2CommandBuffer::setStencilCompareMask(GFXStencilFace face, int ref, uin
|
||||
}
|
||||
}
|
||||
|
||||
void GLES2CommandBuffer::draw(GFXInputAssembler *ia) {
|
||||
if ((_type == GFXCommandBufferType::PRIMARY && _isInRenderPass) ||
|
||||
(_type == GFXCommandBufferType::SECONDARY)) {
|
||||
void GLES2CommandBuffer::draw(InputAssembler *ia) {
|
||||
if ((_type == CommandBufferType::PRIMARY && _isInRenderPass) ||
|
||||
(_type == CommandBufferType::SECONDARY)) {
|
||||
if (_isStateInvalid) {
|
||||
BindStates();
|
||||
}
|
||||
@@ -220,9 +220,9 @@ void GLES2CommandBuffer::draw(GFXInputAssembler *ia) {
|
||||
}
|
||||
}
|
||||
|
||||
void GLES2CommandBuffer::updateBuffer(GFXBuffer *buff, void *data, uint size, uint offset) {
|
||||
if ((_type == GFXCommandBufferType::PRIMARY && !_isInRenderPass) ||
|
||||
(_type == GFXCommandBufferType::SECONDARY)) {
|
||||
void GLES2CommandBuffer::updateBuffer(Buffer *buff, void *data, uint size, uint offset) {
|
||||
if ((_type == CommandBufferType::PRIMARY && !_isInRenderPass) ||
|
||||
(_type == CommandBufferType::SECONDARY)) {
|
||||
GLES2GPUBuffer *gpuBuffer = ((GLES2Buffer *)buff)->gpuBuffer();
|
||||
if (gpuBuffer) {
|
||||
GLES2CmdUpdateBuffer *cmd = _gles2Allocator->updateBufferCmdPool.alloc();
|
||||
@@ -239,9 +239,9 @@ void GLES2CommandBuffer::updateBuffer(GFXBuffer *buff, void *data, uint size, ui
|
||||
}
|
||||
}
|
||||
|
||||
void GLES2CommandBuffer::copyBufferToTexture(GFXBuffer *src, GFXTexture *dst, GFXTextureLayout layout, const GFXBufferTextureCopyList ®ions) {
|
||||
if ((_type == GFXCommandBufferType::PRIMARY && !_isInRenderPass) ||
|
||||
(_type == GFXCommandBufferType::SECONDARY)) {
|
||||
void GLES2CommandBuffer::copyBufferToTexture(Buffer *src, Texture *dst, TextureLayout layout, const BufferTextureCopyList ®ions) {
|
||||
if ((_type == CommandBufferType::PRIMARY && !_isInRenderPass) ||
|
||||
(_type == CommandBufferType::SECONDARY)) {
|
||||
GLES2GPUBuffer *gpuBuffer = ((GLES2Buffer *)src)->gpuBuffer();
|
||||
GLES2GPUTexture *gpuTexture = ((GLES2Texture *)dst)->gpuTexture();
|
||||
if (gpuBuffer && gpuTexture) {
|
||||
@@ -262,7 +262,7 @@ void GLES2CommandBuffer::copyBufferToTexture(GFXBuffer *src, GFXTexture *dst, GF
|
||||
}
|
||||
}
|
||||
|
||||
void GLES2CommandBuffer::execute(const std::vector<GFXCommandBuffer *> &cmd_buffs, uint32_t count) {
|
||||
void GLES2CommandBuffer::execute(const std::vector<CommandBuffer *> &cmd_buffs, uint32_t count) {
|
||||
for (uint i = 0; i < count; ++i) {
|
||||
GLES2CommandBuffer *cmd_buff = (GLES2CommandBuffer *)cmd_buffs[i];
|
||||
|
||||
|
||||
@@ -8,36 +8,36 @@ namespace gfx {
|
||||
|
||||
class GLES2CommandAllocator;
|
||||
|
||||
class CC_GLES2_API GLES2CommandBuffer : public GFXCommandBuffer {
|
||||
class CC_GLES2_API GLES2CommandBuffer : public CommandBuffer {
|
||||
public:
|
||||
GLES2CommandBuffer(GFXDevice *device);
|
||||
GLES2CommandBuffer(Device *device);
|
||||
~GLES2CommandBuffer();
|
||||
|
||||
friend class GLES2Queue;
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXCommandBufferInfo &info) override;
|
||||
virtual bool initialize(const CommandBufferInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
|
||||
virtual void begin(GFXRenderPass *renderPass = nullptr, uint subpass = 0, GFXFramebuffer *frameBuffer = nullptr) override;
|
||||
virtual void begin(RenderPass *renderPass = nullptr, uint subpass = 0, Framebuffer *frameBuffer = nullptr) override;
|
||||
virtual void end() override;
|
||||
virtual void beginRenderPass(GFXFramebuffer *fbo, const GFXRect &render_area, GFXClearFlags clear_flags, const std::vector<GFXColor> &colors, float depth, int stencil) override;
|
||||
virtual void beginRenderPass(Framebuffer *fbo, const Rect &render_area, ClearFlags clear_flags, const std::vector<Color> &colors, float depth, int stencil) override;
|
||||
virtual void endRenderPass() override;
|
||||
virtual void bindPipelineState(GFXPipelineState *pso) override;
|
||||
virtual void bindBindingLayout(GFXBindingLayout *layout) override;
|
||||
virtual void bindInputAssembler(GFXInputAssembler *ia) override;
|
||||
virtual void setViewport(const GFXViewport &vp) override;
|
||||
virtual void setScissor(const GFXRect &rect) override;
|
||||
virtual void bindPipelineState(PipelineState *pso) override;
|
||||
virtual void bindBindingLayout(BindingLayout *layout) override;
|
||||
virtual void bindInputAssembler(InputAssembler *ia) override;
|
||||
virtual void setViewport(const Viewport &vp) override;
|
||||
virtual void setScissor(const Rect &rect) override;
|
||||
virtual void setLineWidth(const float width) override;
|
||||
virtual void setDepthBias(float constant, float clamp, float slope) override;
|
||||
virtual void setBlendConstants(const GFXColor &constants) override;
|
||||
virtual void setBlendConstants(const Color &constants) override;
|
||||
virtual void setDepthBound(float min_bounds, float max_bounds) override;
|
||||
virtual void setStencilWriteMask(GFXStencilFace face, uint mask) override;
|
||||
virtual void setStencilCompareMask(GFXStencilFace face, int ref, uint mask) override;
|
||||
virtual void draw(GFXInputAssembler *ia) override;
|
||||
virtual void updateBuffer(GFXBuffer *buff, void *data, uint size, uint offset) override;
|
||||
virtual void copyBufferToTexture(GFXBuffer *src, GFXTexture *dst, GFXTextureLayout layout, const GFXBufferTextureCopyList ®ions) override;
|
||||
virtual void execute(const std::vector<GFXCommandBuffer *> &cmd_buffs, uint32_t count) override;
|
||||
virtual void setStencilWriteMask(StencilFace face, uint mask) override;
|
||||
virtual void setStencilCompareMask(StencilFace face, int ref, uint mask) override;
|
||||
virtual void draw(InputAssembler *ia) override;
|
||||
virtual void updateBuffer(Buffer *buff, void *data, uint size, uint offset) override;
|
||||
virtual void copyBufferToTexture(Buffer *src, Texture *dst, TextureLayout layout, const BufferTextureCopyList ®ions) override;
|
||||
virtual void execute(const std::vector<CommandBuffer *> &cmd_buffs, uint32_t count) override;
|
||||
|
||||
private:
|
||||
void BindStates();
|
||||
@@ -49,11 +49,11 @@ private:
|
||||
GLES2GPUPipelineState *_curGPUPipelineState = nullptr;
|
||||
GLES2GPUBindingLayout *_curGPUBlendLayout = nullptr;
|
||||
GLES2GPUInputAssembler *_curGPUInputAssember = nullptr;
|
||||
GFXViewport _curViewport;
|
||||
GFXRect _curScissor;
|
||||
Viewport _curViewport;
|
||||
Rect _curScissor;
|
||||
float _curLineWidth = 1.0f;
|
||||
GLES2DepthBias _curDepthBias;
|
||||
GFXColor _curBlendConstants;
|
||||
Color _curBlendConstants;
|
||||
GLES2DepthBounds _curDepthBounds;
|
||||
GLES2StencilWriteMask _curStencilWriteMask;
|
||||
GLES2StencilCompareMask _curStencilCompareMask;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,12 +20,12 @@ struct GLES2DepthBounds {
|
||||
};
|
||||
|
||||
struct GLES2StencilWriteMask {
|
||||
GFXStencilFace face = GFXStencilFace::FRONT;
|
||||
StencilFace face = StencilFace::FRONT;
|
||||
uint write_mask = 0;
|
||||
};
|
||||
|
||||
struct GLES2StencilCompareMask {
|
||||
GFXStencilFace face = GFXStencilFace::FRONT;
|
||||
StencilFace face = StencilFace::FRONT;
|
||||
int refrence = 0;
|
||||
uint compare_mask = 0;
|
||||
};
|
||||
@@ -49,10 +49,10 @@ struct GLES2BufferTextureCopy {
|
||||
class GLES2CmdBeginRenderPass : public GFXCmd {
|
||||
public:
|
||||
GLES2GPUFramebuffer *gpuFBO = nullptr;
|
||||
GFXRect render_area;
|
||||
GFXClearFlags clear_flags = GFXClearFlagBit::NONE;
|
||||
Rect render_area;
|
||||
ClearFlags clear_flags = ClearFlagBit::NONE;
|
||||
uint num_clear_colors = 0;
|
||||
GFXColor clear_colors[GFX_MAX_ATTACHMENTS];
|
||||
Color clear_colors[GFX_MAX_ATTACHMENTS];
|
||||
float clear_depth = 1.0f;
|
||||
int clear_stencil = 0;
|
||||
|
||||
@@ -82,12 +82,12 @@ public:
|
||||
GLES2GPUBindingLayout *gpuBindingLayout = nullptr;
|
||||
GLES2GPUInputAssembler *gpuInputAssembler = nullptr;
|
||||
uint8_t state_flags[(int)GLES2State::COUNT] = {0};
|
||||
GFXViewport viewport;
|
||||
GFXRect scissor;
|
||||
Viewport viewport;
|
||||
Rect scissor;
|
||||
float lineWidth = 1.0f;
|
||||
bool depthBiasEnabled = false;
|
||||
GLES2DepthBias depthBias;
|
||||
GFXColor blendConstants;
|
||||
Color blendConstants;
|
||||
GLES2DepthBounds depthBounds;
|
||||
GLES2StencilWriteMask stencilWriteMask;
|
||||
GLES2StencilCompareMask stencilCompareMask;
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
|
||||
class GLES2CmdDraw : public GFXCmd {
|
||||
public:
|
||||
GFXDrawInfo draw_info;
|
||||
DrawInfo draw_info;
|
||||
|
||||
GLES2CmdDraw() : GFXCmd(GFXCmdType::DRAW) {}
|
||||
virtual void clear() override {}
|
||||
@@ -129,8 +129,8 @@ class GLES2CmdCopyBufferToTexture : public GFXCmd {
|
||||
public:
|
||||
GLES2GPUBuffer *gpuBuffer = nullptr;
|
||||
GLES2GPUTexture *gpuTexture = nullptr;
|
||||
GFXTextureLayout dst_layout;
|
||||
GFXBufferTextureCopyList regions;
|
||||
TextureLayout dst_layout;
|
||||
BufferTextureCopyList regions;
|
||||
|
||||
GLES2CmdCopyBufferToTexture() : GFXCmd(GFXCmdType::COPY_BUFFER_TO_TEXTURE) {}
|
||||
|
||||
@@ -167,7 +167,7 @@ CC_GLES2_API void GLES2CmdFuncDestroyInputAssembler(GLES2Device *device, GLES2GP
|
||||
CC_GLES2_API void GLES2CmdFuncCreateFramebuffer(GLES2Device *device, GLES2GPUFramebuffer *gpuFBO);
|
||||
CC_GLES2_API void GLES2CmdFuncDestroyFramebuffer(GLES2Device *device, GLES2GPUFramebuffer *gpuFBO);
|
||||
CC_GLES2_API void GLES2CmdFuncExecuteCmds(GLES2Device *device, GLES2CmdPackage *cmd_package);
|
||||
CC_GLES2_API void GLES2CmdFuncCopyBuffersToTexture(GLES2Device *device, uint8_t *const *buffers, GLES2GPUTexture *gpuTexture, const GFXBufferTextureCopyList ®ions);
|
||||
CC_GLES2_API void GLES2CmdFuncCopyBuffersToTexture(GLES2Device *device, uint8_t *const *buffers, GLES2GPUTexture *gpuTexture, const BufferTextureCopyList ®ions);
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace cc
|
||||
|
||||
@@ -69,8 +69,8 @@ void APIENTRY GLES2EGLDebugProc(GLenum source,
|
||||
|
||||
#endif
|
||||
|
||||
GLES2Context::GLES2Context(GFXDevice *device)
|
||||
: GFXContext(device) {
|
||||
GLES2Context::GLES2Context(Device *device)
|
||||
: Context(device) {
|
||||
}
|
||||
|
||||
GLES2Context::~GLES2Context() {
|
||||
@@ -78,7 +78,7 @@ GLES2Context::~GLES2Context() {
|
||||
|
||||
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS || CC_PLATFORM == CC_PLATFORM_ANDROID || CC_PLATFORM == CC_PLATFORM_MAC_OSX)
|
||||
|
||||
bool GLES2Context::initialize(const GFXContextInfo &info) {
|
||||
bool GLES2Context::initialize(const ContextInfo &info) {
|
||||
|
||||
_vsyncMode = info.vsyncMode;
|
||||
_windowHandle = info.windowHandle;
|
||||
@@ -124,8 +124,8 @@ bool GLES2Context::initialize(const GFXContextInfo &info) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_colorFmt = GFXFormat::RGBA8;
|
||||
_depthStencilFmt = GFXFormat::D24S8;
|
||||
_colorFmt = Format::RGBA8;
|
||||
_depthStencilFmt = Format::D24S8;
|
||||
|
||||
const EGLint attribs[] = {
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
|
||||
@@ -160,17 +160,17 @@ bool GLES2Context::initialize(const GFXContextInfo &info) {
|
||||
CC_LOG_INFO("Setup EGLConfig: depth [%d] stencil [%d]", depth, stencil);
|
||||
|
||||
if (depth == 16 && stencil == 0) {
|
||||
_depthStencilFmt = GFXFormat::D16;
|
||||
_depthStencilFmt = Format::D16;
|
||||
} else if (depth == 16 && stencil == 8) {
|
||||
_depthStencilFmt = GFXFormat::D16S8;
|
||||
_depthStencilFmt = Format::D16S8;
|
||||
} else if (depth == 24 && stencil == 0) {
|
||||
_depthStencilFmt = GFXFormat::D24;
|
||||
_depthStencilFmt = Format::D24;
|
||||
} else if (depth == 24 && stencil == 8) {
|
||||
_depthStencilFmt = GFXFormat::D24S8;
|
||||
_depthStencilFmt = Format::D24S8;
|
||||
} else if (depth == 32 && stencil == 0) {
|
||||
_depthStencilFmt = GFXFormat::D32F;
|
||||
_depthStencilFmt = Format::D32F;
|
||||
} else if (depth == 32 && stencil == 8) {
|
||||
_depthStencilFmt = GFXFormat::D32F_S8;
|
||||
_depthStencilFmt = Format::D32F_S8;
|
||||
} else {
|
||||
CC_LOG_ERROR("Unknown depth stencil format.");
|
||||
return false;
|
||||
@@ -359,7 +359,7 @@ void GLES2Context::destroy() {
|
||||
_isPrimaryContex = false;
|
||||
_windowHandle = 0;
|
||||
_nativeDisplay = 0;
|
||||
_vsyncMode = GFXVsyncMode::OFF;
|
||||
_vsyncMode = VsyncMode::OFF;
|
||||
_isInitialized = false;
|
||||
}
|
||||
|
||||
@@ -381,11 +381,11 @@ bool GLES2Context::MakeCurrent() {
|
||||
// Turn on or off the vertical sync depending on the input bool value.
|
||||
int interval = 1;
|
||||
switch (_vsyncMode) {
|
||||
case GFXVsyncMode::OFF: interval = 0; break;
|
||||
case GFXVsyncMode::ON: interval = 1; break;
|
||||
case GFXVsyncMode::RELAXED: interval = -1; break;
|
||||
case GFXVsyncMode::MAILBOX: interval = 0; break;
|
||||
case GFXVsyncMode::HALF: interval = 2; break;
|
||||
case VsyncMode::OFF: interval = 0; break;
|
||||
case VsyncMode::ON: interval = 1; break;
|
||||
case VsyncMode::RELAXED: interval = -1; break;
|
||||
case VsyncMode::MAILBOX: interval = 0; break;
|
||||
case VsyncMode::HALF: interval = 2; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,13 +31,13 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_GLES2_API GLES2Context : public GFXContext {
|
||||
class CC_GLES2_API GLES2Context : public Context {
|
||||
public:
|
||||
GLES2Context(GFXDevice *device);
|
||||
GLES2Context(Device *device);
|
||||
~GLES2Context();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXContextInfo &info) override;
|
||||
virtual bool initialize(const ContextInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
virtual void present() override;
|
||||
bool MakeCurrent();
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace gfx {
|
||||
|
||||
#if (CC_PLATFORM == CC_PLATFORM_MAC_IOS)
|
||||
|
||||
bool GLES2Context::initialize(const GFXContextInfo &info) {
|
||||
bool GLES2Context::initialize(const ContextInfo &info) {
|
||||
|
||||
_vsyncMode = info.vsyncMode;
|
||||
_windowHandle = info.windowHandle;
|
||||
@@ -49,8 +49,8 @@ bool GLES2Context::initialize(const GFXContextInfo &info) {
|
||||
}
|
||||
}
|
||||
|
||||
_colorFmt = GFXFormat::RGBA8;
|
||||
_depthStencilFmt = GFXFormat::D24S8;
|
||||
_colorFmt = Format::RGBA8;
|
||||
_depthStencilFmt = Format::D24S8;
|
||||
|
||||
if (!MakeCurrent())
|
||||
return false;
|
||||
@@ -169,7 +169,7 @@ void GLES2Context::destroy() {
|
||||
|
||||
_isPrimaryContex = false;
|
||||
_windowHandle = 0;
|
||||
_vsyncMode = GFXVsyncMode::OFF;
|
||||
_vsyncMode = VsyncMode::OFF;
|
||||
_isInitialized = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ GLES2Device::GLES2Device() {
|
||||
GLES2Device::~GLES2Device() {
|
||||
}
|
||||
|
||||
bool GLES2Device::initialize(const GFXDeviceInfo &info) {
|
||||
_gfxAPI = GFXAPI::GLES2;
|
||||
bool GLES2Device::initialize(const DeviceInfo &info) {
|
||||
_API = API::GLES2;
|
||||
_deviceName = "GLES2";
|
||||
_width = info.width;
|
||||
_height = info.height;
|
||||
@@ -38,7 +38,7 @@ bool GLES2Device::initialize(const GFXDeviceInfo &info) {
|
||||
|
||||
stateCache = CC_NEW(GLES2StateCache);
|
||||
|
||||
GFXContextInfo ctx_info;
|
||||
ContextInfo ctx_info;
|
||||
ctx_info.windowHandle = _windowHandle;
|
||||
ctx_info.sharedCtx = info.sharedCtx;
|
||||
|
||||
@@ -51,58 +51,58 @@ bool GLES2Device::initialize(const GFXDeviceInfo &info) {
|
||||
String extStr = (const char *)glGetString(GL_EXTENSIONS);
|
||||
_extensions = StringUtil::Split(extStr, " ");
|
||||
|
||||
_features[(int)GFXFeature::TEXTURE_FLOAT] = true;
|
||||
_features[(int)GFXFeature::TEXTURE_HALF_FLOAT] = true;
|
||||
_features[(int)GFXFeature::FORMAT_R11G11B10F] = true;
|
||||
_features[(int)GFXFeature::FORMAT_D24S8] = true;
|
||||
_features[(int)GFXFeature::MSAA] = true;
|
||||
_features[(int)Feature::TEXTURE_FLOAT] = true;
|
||||
_features[(int)Feature::TEXTURE_HALF_FLOAT] = true;
|
||||
_features[(int)Feature::FORMAT_R11G11B10F] = true;
|
||||
_features[(int)Feature::FORMAT_D24S8] = true;
|
||||
_features[(int)Feature::MSAA] = true;
|
||||
|
||||
if (checkExtension("color_buffer_float"))
|
||||
_features[(int)GFXFeature::COLOR_FLOAT] = true;
|
||||
_features[(int)Feature::COLOR_FLOAT] = true;
|
||||
|
||||
if (checkExtension("color_buffer_half_float"))
|
||||
_features[(int)GFXFeature::COLOR_HALF_FLOAT] = true;
|
||||
_features[(int)Feature::COLOR_HALF_FLOAT] = true;
|
||||
|
||||
if (checkExtension("texture_float_linear"))
|
||||
_features[(int)GFXFeature::TEXTURE_FLOAT_LINEAR] = true;
|
||||
_features[(int)Feature::TEXTURE_FLOAT_LINEAR] = true;
|
||||
|
||||
if (checkExtension("texture_half_float_linear"))
|
||||
_features[(int)GFXFeature::TEXTURE_HALF_FLOAT_LINEAR] = true;
|
||||
_features[(int)Feature::TEXTURE_HALF_FLOAT_LINEAR] = true;
|
||||
|
||||
_useVAO = checkExtension("vertex_array_object");
|
||||
_useDrawInstanced = checkExtension("draw_instanced");
|
||||
_useInstancedArrays = _features[(int)GFXFeature::INSTANCED_ARRAYS] = checkExtension("instanced_arrays");
|
||||
_useInstancedArrays = _features[(int)Feature::INSTANCED_ARRAYS] = checkExtension("instanced_arrays");
|
||||
_useDiscardFramebuffer = checkExtension("discard_framebuffer");
|
||||
|
||||
String compressed_fmts;
|
||||
|
||||
if (checkExtension("compressed_ETC1")) {
|
||||
_features[(int)GFXFeature::FORMAT_ETC1] = true;
|
||||
_features[(int)Feature::FORMAT_ETC1] = true;
|
||||
compressed_fmts += "etc1 ";
|
||||
}
|
||||
|
||||
_features[(int)GFXFeature::FORMAT_ETC2] = true;
|
||||
_features[(int)Feature::FORMAT_ETC2] = true;
|
||||
compressed_fmts += "etc2 ";
|
||||
|
||||
if (checkExtension("texture_compression_pvrtc")) {
|
||||
_features[(int)GFXFeature::FORMAT_PVRTC] = true;
|
||||
_features[(int)Feature::FORMAT_PVRTC] = true;
|
||||
compressed_fmts += "pvrtc ";
|
||||
}
|
||||
|
||||
if (checkExtension("texture_compression_astc")) {
|
||||
_features[(int)GFXFeature::FORMAT_ASTC] = true;
|
||||
_features[(int)Feature::FORMAT_ASTC] = true;
|
||||
compressed_fmts += "astc ";
|
||||
}
|
||||
_features[static_cast<uint>(GFXFeature::DEPTH_BOUNDS)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::LINE_WIDTH)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::STENCIL_COMPARE_MASK)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::STENCIL_WRITE_MASK)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::FORMAT_RGB8)] = true;
|
||||
_features[static_cast<uint>(Feature::DEPTH_BOUNDS)] = true;
|
||||
_features[static_cast<uint>(Feature::LINE_WIDTH)] = true;
|
||||
_features[static_cast<uint>(Feature::STENCIL_COMPARE_MASK)] = true;
|
||||
_features[static_cast<uint>(Feature::STENCIL_WRITE_MASK)] = true;
|
||||
_features[static_cast<uint>(Feature::FORMAT_RGB8)] = true;
|
||||
|
||||
if (checkExtension("depth_texture")) {
|
||||
_features[static_cast<uint>(GFXFeature::FORMAT_D16)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::FORMAT_D24)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::FORMAT_D24S8)] = checkExtension("packed_depth_stencil");
|
||||
_features[static_cast<uint>(Feature::FORMAT_D16)] = true;
|
||||
_features[static_cast<uint>(Feature::FORMAT_D24)] = true;
|
||||
_features[static_cast<uint>(Feature::FORMAT_D24S8)] = checkExtension("packed_depth_stencil");
|
||||
}
|
||||
|
||||
_renderer = (const char *)glGetString(GL_RENDERER);
|
||||
@@ -118,11 +118,11 @@ bool GLES2Device::initialize(const GFXDeviceInfo &info) {
|
||||
CC_LOG_INFO("USE_VAO: %s", _useVAO ? "true" : "false");
|
||||
CC_LOG_INFO("COMPRESSED_FORMATS: %s", compressed_fmts.c_str());
|
||||
|
||||
GFXQueueInfo queue_info;
|
||||
queue_info.type = GFXQueueType::GRAPHICS;
|
||||
QueueInfo queue_info;
|
||||
queue_info.type = QueueType::GRAPHICS;
|
||||
_queue = createQueue(queue_info);
|
||||
|
||||
GFXCommandAllocatorInfo cmd_alloc_info;
|
||||
CommandAllocatorInfo cmd_alloc_info;
|
||||
_cmdAllocator = createCommandAllocator(cmd_alloc_info);
|
||||
|
||||
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, (GLint *)&_maxVertexAttributes);
|
||||
@@ -165,8 +165,8 @@ void GLES2Device::present() {
|
||||
queue->_numTriangles = 0;
|
||||
}
|
||||
|
||||
GFXFence *GLES2Device::createFence(const GFXFenceInfo &info) {
|
||||
GFXFence *fence = CC_NEW(GLES2Fence(this));
|
||||
Fence *GLES2Device::createFence(const FenceInfo &info) {
|
||||
Fence *fence = CC_NEW(GLES2Fence(this));
|
||||
if (fence->initialize(info))
|
||||
return fence;
|
||||
|
||||
@@ -174,8 +174,8 @@ GFXFence *GLES2Device::createFence(const GFXFenceInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXQueue *GLES2Device::createQueue(const GFXQueueInfo &info) {
|
||||
GFXQueue *queue = CC_NEW(GLES2Queue(this));
|
||||
Queue *GLES2Device::createQueue(const QueueInfo &info) {
|
||||
Queue *queue = CC_NEW(GLES2Queue(this));
|
||||
if (queue->initialize(info))
|
||||
return queue;
|
||||
|
||||
@@ -183,8 +183,8 @@ GFXQueue *GLES2Device::createQueue(const GFXQueueInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXCommandAllocator *GLES2Device::createCommandAllocator(const GFXCommandAllocatorInfo &info) {
|
||||
GFXCommandAllocator *cmdAllocator = CC_NEW(GLES2CommandAllocator(this));
|
||||
CommandAllocator *GLES2Device::createCommandAllocator(const CommandAllocatorInfo &info) {
|
||||
CommandAllocator *cmdAllocator = CC_NEW(GLES2CommandAllocator(this));
|
||||
if (cmdAllocator->initialize(info))
|
||||
return cmdAllocator;
|
||||
|
||||
@@ -193,8 +193,8 @@ GFXCommandAllocator *GLES2Device::createCommandAllocator(const GFXCommandAllocat
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXCommandBuffer *GLES2Device::createCommandBuffer(const GFXCommandBufferInfo &info) {
|
||||
GFXCommandBuffer *cmdBuff = CC_NEW(GLES2CommandBuffer(this));
|
||||
CommandBuffer *GLES2Device::createCommandBuffer(const CommandBufferInfo &info) {
|
||||
CommandBuffer *cmdBuff = CC_NEW(GLES2CommandBuffer(this));
|
||||
if (cmdBuff->initialize(info))
|
||||
return cmdBuff;
|
||||
|
||||
@@ -202,8 +202,8 @@ GFXCommandBuffer *GLES2Device::createCommandBuffer(const GFXCommandBufferInfo &i
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXBuffer *GLES2Device::createBuffer(const GFXBufferInfo &info) {
|
||||
GFXBuffer *buffer = CC_NEW(GLES2Buffer(this));
|
||||
Buffer *GLES2Device::createBuffer(const BufferInfo &info) {
|
||||
Buffer *buffer = CC_NEW(GLES2Buffer(this));
|
||||
if (buffer->initialize(info))
|
||||
return buffer;
|
||||
|
||||
@@ -211,8 +211,8 @@ GFXBuffer *GLES2Device::createBuffer(const GFXBufferInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXTexture *GLES2Device::createTexture(const GFXTextureInfo &info) {
|
||||
GFXTexture *texture = CC_NEW(GLES2Texture(this));
|
||||
Texture *GLES2Device::createTexture(const TextureInfo &info) {
|
||||
Texture *texture = CC_NEW(GLES2Texture(this));
|
||||
if (texture->initialize(info))
|
||||
return texture;
|
||||
|
||||
@@ -220,8 +220,8 @@ GFXTexture *GLES2Device::createTexture(const GFXTextureInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXTexture *GLES2Device::createTexture(const GFXTextureViewInfo &info) {
|
||||
GFXTexture *texture = CC_NEW(GLES2Texture(this));
|
||||
Texture *GLES2Device::createTexture(const TextureViewInfo &info) {
|
||||
Texture *texture = CC_NEW(GLES2Texture(this));
|
||||
if (texture->initialize(info))
|
||||
return texture;
|
||||
|
||||
@@ -229,8 +229,8 @@ GFXTexture *GLES2Device::createTexture(const GFXTextureViewInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXSampler *GLES2Device::createSampler(const GFXSamplerInfo &info) {
|
||||
GFXSampler *sampler = CC_NEW(GLES2Sampler(this));
|
||||
Sampler *GLES2Device::createSampler(const SamplerInfo &info) {
|
||||
Sampler *sampler = CC_NEW(GLES2Sampler(this));
|
||||
if (sampler->initialize(info))
|
||||
return sampler;
|
||||
|
||||
@@ -238,8 +238,8 @@ GFXSampler *GLES2Device::createSampler(const GFXSamplerInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXShader *GLES2Device::createShader(const GFXShaderInfo &info) {
|
||||
GFXShader *shader = CC_NEW(GLES2Shader(this));
|
||||
Shader *GLES2Device::createShader(const ShaderInfo &info) {
|
||||
Shader *shader = CC_NEW(GLES2Shader(this));
|
||||
if (shader->initialize(info))
|
||||
return shader;
|
||||
|
||||
@@ -247,8 +247,8 @@ GFXShader *GLES2Device::createShader(const GFXShaderInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXInputAssembler *GLES2Device::createInputAssembler(const GFXInputAssemblerInfo &info) {
|
||||
GFXInputAssembler *inputAssembler = CC_NEW(GLES2InputAssembler(this));
|
||||
InputAssembler *GLES2Device::createInputAssembler(const InputAssemblerInfo &info) {
|
||||
InputAssembler *inputAssembler = CC_NEW(GLES2InputAssembler(this));
|
||||
if (inputAssembler->initialize(info))
|
||||
return inputAssembler;
|
||||
|
||||
@@ -256,8 +256,8 @@ GFXInputAssembler *GLES2Device::createInputAssembler(const GFXInputAssemblerInfo
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXRenderPass *GLES2Device::createRenderPass(const GFXRenderPassInfo &info) {
|
||||
GFXRenderPass *renderPass = CC_NEW(GLES2RenderPass(this));
|
||||
RenderPass *GLES2Device::createRenderPass(const RenderPassInfo &info) {
|
||||
RenderPass *renderPass = CC_NEW(GLES2RenderPass(this));
|
||||
if (renderPass->initialize(info))
|
||||
return renderPass;
|
||||
|
||||
@@ -265,8 +265,8 @@ GFXRenderPass *GLES2Device::createRenderPass(const GFXRenderPassInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXFramebuffer *GLES2Device::createFramebuffer(const GFXFramebufferInfo &info) {
|
||||
GFXFramebuffer *framebuffer = CC_NEW(GLES2Framebuffer(this));
|
||||
Framebuffer *GLES2Device::createFramebuffer(const FramebufferInfo &info) {
|
||||
Framebuffer *framebuffer = CC_NEW(GLES2Framebuffer(this));
|
||||
if (framebuffer->initialize(info))
|
||||
return framebuffer;
|
||||
|
||||
@@ -274,8 +274,8 @@ GFXFramebuffer *GLES2Device::createFramebuffer(const GFXFramebufferInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXBindingLayout *GLES2Device::createBindingLayout(const GFXBindingLayoutInfo &info) {
|
||||
GFXBindingLayout *bindingLayout = CC_NEW(GLES2BindingLayout(this));
|
||||
BindingLayout *GLES2Device::createBindingLayout(const BindingLayoutInfo &info) {
|
||||
BindingLayout *bindingLayout = CC_NEW(GLES2BindingLayout(this));
|
||||
if (bindingLayout->initialize(info))
|
||||
return bindingLayout;
|
||||
|
||||
@@ -283,8 +283,8 @@ GFXBindingLayout *GLES2Device::createBindingLayout(const GFXBindingLayoutInfo &i
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXPipelineState *GLES2Device::createPipelineState(const GFXPipelineStateInfo &info) {
|
||||
GFXPipelineState *pipelineState = CC_NEW(GLES2PipelineState(this));
|
||||
PipelineState *GLES2Device::createPipelineState(const PipelineStateInfo &info) {
|
||||
PipelineState *pipelineState = CC_NEW(GLES2PipelineState(this));
|
||||
if (pipelineState->initialize(info))
|
||||
return pipelineState;
|
||||
|
||||
@@ -292,8 +292,8 @@ GFXPipelineState *GLES2Device::createPipelineState(const GFXPipelineStateInfo &i
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXPipelineLayout *GLES2Device::createPipelineLayout(const GFXPipelineLayoutInfo &info) {
|
||||
GFXPipelineLayout *layout = CC_NEW(GLES2PipelineLayout(this));
|
||||
PipelineLayout *GLES2Device::createPipelineLayout(const PipelineLayoutInfo &info) {
|
||||
PipelineLayout *layout = CC_NEW(GLES2PipelineLayout(this));
|
||||
if (layout->initialize(info))
|
||||
return layout;
|
||||
|
||||
@@ -301,7 +301,7 @@ GFXPipelineLayout *GLES2Device::createPipelineLayout(const GFXPipelineLayoutInfo
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GLES2Device::copyBuffersToTexture(const GFXDataArray &buffers, GFXTexture *dst, const GFXBufferTextureCopyList ®ions) {
|
||||
void GLES2Device::copyBuffersToTexture(const DataArray &buffers, Texture *dst, const BufferTextureCopyList ®ions) {
|
||||
GLES2CmdFuncCopyBuffersToTexture(this, buffers.datas.data(), ((GLES2Texture *)dst)->gpuTexture(), regions);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace gfx {
|
||||
|
||||
class GLES2StateCache;
|
||||
|
||||
class CC_GLES2_API GLES2Device : public GFXDevice {
|
||||
class CC_GLES2_API GLES2Device : public Device {
|
||||
public:
|
||||
GLES2Device();
|
||||
~GLES2Device();
|
||||
@@ -14,27 +14,27 @@ public:
|
||||
GLES2StateCache *stateCache = nullptr;
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXDeviceInfo &info) override;
|
||||
virtual bool initialize(const DeviceInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
virtual void resize(uint width, uint height) override;
|
||||
virtual void acquire() override{};
|
||||
virtual void present() override;
|
||||
virtual GFXFence *createFence(const GFXFenceInfo &info) override;
|
||||
virtual GFXQueue *createQueue(const GFXQueueInfo &info) override;
|
||||
virtual GFXCommandAllocator *createCommandAllocator(const GFXCommandAllocatorInfo &info) override;
|
||||
virtual GFXCommandBuffer *createCommandBuffer(const GFXCommandBufferInfo &info) override;
|
||||
virtual GFXBuffer *createBuffer(const GFXBufferInfo &info) override;
|
||||
virtual GFXTexture *createTexture(const GFXTextureInfo &info) override;
|
||||
virtual GFXTexture *createTexture(const GFXTextureViewInfo &info) override;
|
||||
virtual GFXSampler *createSampler(const GFXSamplerInfo &info) override;
|
||||
virtual GFXShader *createShader(const GFXShaderInfo &info) override;
|
||||
virtual GFXInputAssembler *createInputAssembler(const GFXInputAssemblerInfo &info) override;
|
||||
virtual GFXRenderPass *createRenderPass(const GFXRenderPassInfo &info) override;
|
||||
virtual GFXFramebuffer *createFramebuffer(const GFXFramebufferInfo &info) override;
|
||||
virtual GFXBindingLayout *createBindingLayout(const GFXBindingLayoutInfo &info) override;
|
||||
virtual GFXPipelineState *createPipelineState(const GFXPipelineStateInfo &info) override;
|
||||
virtual GFXPipelineLayout *createPipelineLayout(const GFXPipelineLayoutInfo &info) override;
|
||||
virtual void copyBuffersToTexture(const GFXDataArray &buffers, GFXTexture *dst, const GFXBufferTextureCopyList ®ions) override;
|
||||
virtual Fence *createFence(const FenceInfo &info) override;
|
||||
virtual Queue *createQueue(const QueueInfo &info) override;
|
||||
virtual CommandAllocator *createCommandAllocator(const CommandAllocatorInfo &info) override;
|
||||
virtual CommandBuffer *createCommandBuffer(const CommandBufferInfo &info) override;
|
||||
virtual Buffer *createBuffer(const BufferInfo &info) override;
|
||||
virtual Texture *createTexture(const TextureInfo &info) override;
|
||||
virtual Texture *createTexture(const TextureViewInfo &info) override;
|
||||
virtual Sampler *createSampler(const SamplerInfo &info) override;
|
||||
virtual Shader *createShader(const ShaderInfo &info) override;
|
||||
virtual InputAssembler *createInputAssembler(const InputAssemblerInfo &info) override;
|
||||
virtual RenderPass *createRenderPass(const RenderPassInfo &info) override;
|
||||
virtual Framebuffer *createFramebuffer(const FramebufferInfo &info) override;
|
||||
virtual BindingLayout *createBindingLayout(const BindingLayoutInfo &info) override;
|
||||
virtual PipelineState *createPipelineState(const PipelineStateInfo &info) override;
|
||||
virtual PipelineLayout *createPipelineLayout(const PipelineLayoutInfo &info) override;
|
||||
virtual void copyBuffersToTexture(const DataArray &buffers, Texture *dst, const BufferTextureCopyList ®ions) override;
|
||||
|
||||
CC_INLINE bool useVAO() const { return _useVAO; }
|
||||
CC_INLINE bool useDrawInstanced() const { return _useDrawInstanced; }
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES2Fence::GLES2Fence(GFXDevice *device)
|
||||
: GFXFence(device) {
|
||||
GLES2Fence::GLES2Fence(Device *device)
|
||||
: Fence(device) {
|
||||
}
|
||||
|
||||
GLES2Fence::~GLES2Fence() {
|
||||
}
|
||||
|
||||
bool GLES2Fence::initialize(const GFXFenceInfo &info) {
|
||||
bool GLES2Fence::initialize(const FenceInfo &info) {
|
||||
_gpuFence = CC_NEW(GLES2GPUFence);
|
||||
if (!_gpuFence) {
|
||||
CC_LOG_ERROR("GLES2Fence: CC_NEW GLES2GPUFence failed.");
|
||||
@@ -22,7 +22,7 @@ bool GLES2Fence::initialize(const GFXFenceInfo &info) {
|
||||
|
||||
// TODO
|
||||
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ void GLES2Fence::destroy() {
|
||||
CC_DELETE(_gpuFence);
|
||||
_gpuFence = nullptr;
|
||||
}
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
void GLES2Fence::wait() {
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace gfx {
|
||||
|
||||
class GLES2GPUFence;
|
||||
|
||||
class CC_GLES2_API GLES2Fence : public GFXFence {
|
||||
class CC_GLES2_API GLES2Fence : public Fence {
|
||||
public:
|
||||
GLES2Fence(GFXDevice *device);
|
||||
GLES2Fence(Device *device);
|
||||
~GLES2Fence();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXFenceInfo &info) override;
|
||||
virtual bool initialize(const FenceInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
virtual void wait() override;
|
||||
virtual void reset() override;
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES2Framebuffer::GLES2Framebuffer(GFXDevice *device)
|
||||
: GFXFramebuffer(device) {
|
||||
GLES2Framebuffer::GLES2Framebuffer(Device *device)
|
||||
: Framebuffer(device) {
|
||||
}
|
||||
|
||||
GLES2Framebuffer::~GLES2Framebuffer() {
|
||||
}
|
||||
|
||||
bool GLES2Framebuffer::initialize(const GFXFramebufferInfo &info) {
|
||||
bool GLES2Framebuffer::initialize(const FramebufferInfo &info) {
|
||||
|
||||
_renderPass = info.renderPass;
|
||||
_colorTextures = info.colorTextures;
|
||||
@@ -58,7 +58,7 @@ bool GLES2Framebuffer::initialize(const GFXFramebufferInfo &info) {
|
||||
_gpuFBO->glFramebuffer = static_cast<GLES2Context *>(_device->getContext())->getDefaultFramebuffer();
|
||||
}
|
||||
#endif
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ void GLES2Framebuffer::destroy() {
|
||||
CC_DELETE(_gpuFBO);
|
||||
_gpuFBO = nullptr;
|
||||
}
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace gfx {
|
||||
|
||||
class GLES2GPUFramebuffer;
|
||||
|
||||
class CC_GLES2_API GLES2Framebuffer : public GFXFramebuffer {
|
||||
class CC_GLES2_API GLES2Framebuffer : public Framebuffer {
|
||||
public:
|
||||
GLES2Framebuffer(GFXDevice *device);
|
||||
GLES2Framebuffer(Device *device);
|
||||
~GLES2Framebuffer();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXFramebufferInfo &info) override;
|
||||
virtual bool initialize(const FramebufferInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
|
||||
CC_INLINE GLES2GPUFramebuffer *gpuFBO() const { return _gpuFBO; }
|
||||
|
||||
@@ -8,31 +8,31 @@ namespace gfx {
|
||||
|
||||
class GLES2GPUBuffer : public Object {
|
||||
public:
|
||||
GFXBufferUsage usage = GFXBufferUsage::NONE;
|
||||
GFXMemoryUsage memUsage = GFXMemoryUsage::NONE;
|
||||
BufferUsage usage = BufferUsage::NONE;
|
||||
MemoryUsage memUsage = MemoryUsage::NONE;
|
||||
uint size = 0;
|
||||
uint stride = 0;
|
||||
uint count = 0;
|
||||
GLenum glTarget = 0;
|
||||
GLuint glBuffer = 0;
|
||||
uint8_t *buffer = nullptr;
|
||||
GFXDrawInfoList indirects;
|
||||
DrawInfoList indirects;
|
||||
};
|
||||
typedef vector<GLES2GPUBuffer *> GLES2GPUBufferList;
|
||||
|
||||
class GLES2GPUTexture : public Object {
|
||||
public:
|
||||
GFXTextureType type = GFXTextureType::TEX2D;
|
||||
GFXFormat format = GFXFormat::UNKNOWN;
|
||||
GFXTextureUsage usage = GFXTextureUsageBit::NONE;
|
||||
TextureType type = TextureType::TEX2D;
|
||||
Format format = Format::UNKNOWN;
|
||||
TextureUsage usage = TextureUsageBit::NONE;
|
||||
uint width = 0;
|
||||
uint height = 0;
|
||||
uint depth = 1;
|
||||
uint size = 0;
|
||||
uint arrayLayer = 1;
|
||||
uint mipLevel = 1;
|
||||
GFXSampleCount samples = GFXSampleCount::X1;
|
||||
GFXTextureFlags flags = GFXTextureFlagBit::NONE;
|
||||
SampleCount samples = SampleCount::X1;
|
||||
TextureFlags flags = TextureFlagBit::NONE;
|
||||
bool isPowerOf2 = false;
|
||||
GLenum glTarget = 0;
|
||||
GLenum glInternelFmt = 0;
|
||||
@@ -50,12 +50,12 @@ typedef vector<GLES2GPUTexture *> GLES2GPUTextureList;
|
||||
|
||||
class GLES2GPUSampler : public Object {
|
||||
public:
|
||||
GFXFilter minFilter = GFXFilter::NONE;
|
||||
GFXFilter magFilter = GFXFilter::NONE;
|
||||
GFXFilter mipFilter = GFXFilter::NONE;
|
||||
GFXAddress addressU = GFXAddress::CLAMP;
|
||||
GFXAddress addressV = GFXAddress::CLAMP;
|
||||
GFXAddress addressW = GFXAddress::CLAMP;
|
||||
Filter minFilter = Filter::NONE;
|
||||
Filter magFilter = Filter::NONE;
|
||||
Filter mipFilter = Filter::NONE;
|
||||
Address addressU = Address::CLAMP;
|
||||
Address addressV = Address::CLAMP;
|
||||
Address addressW = Address::CLAMP;
|
||||
uint minLOD = 0;
|
||||
uint maxLOD = 1000;
|
||||
GLenum glMinFilter = 0;
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
struct GLES2GPUInput {
|
||||
uint binding = 0;
|
||||
String name;
|
||||
GFXType type = GFXType::UNKNOWN;
|
||||
Type type = Type::UNKNOWN;
|
||||
uint stride = 0;
|
||||
uint count = 0;
|
||||
uint size = 0;
|
||||
@@ -80,7 +80,7 @@ typedef vector<GLES2GPUInput> GLES2GPUInputList;
|
||||
struct GLES2GPUUniform {
|
||||
uint binding = GFX_INVALID_BINDING;
|
||||
String name;
|
||||
GFXType type = GFXType::UNKNOWN;
|
||||
Type type = Type::UNKNOWN;
|
||||
uint stride = 0;
|
||||
uint count = 0;
|
||||
uint size = 0;
|
||||
@@ -134,7 +134,7 @@ typedef vector<GLES2GPUUniformBlock> GLES2GPUUniformBlockList;
|
||||
struct GLES2GPUUniformSampler {
|
||||
uint binding = 0;
|
||||
String name;
|
||||
GFXType type = GFXType::UNKNOWN;
|
||||
Type type = Type::UNKNOWN;
|
||||
vector<int> units;
|
||||
GLenum glType = 0;
|
||||
GLint glLoc = -1;
|
||||
@@ -142,11 +142,11 @@ struct GLES2GPUUniformSampler {
|
||||
typedef vector<GLES2GPUUniformSampler> GLES2GPUUniformSamplerList;
|
||||
|
||||
struct GLES2GPUShaderStage {
|
||||
GLES2GPUShaderStage(GFXShaderType t, String s, GFXShaderMacroList m, GLuint shader = 0)
|
||||
GLES2GPUShaderStage(ShaderType t, String s, ShaderMacroList m, GLuint shader = 0)
|
||||
: type(t), source(s), macros(m), glShader(shader) {}
|
||||
GFXShaderType type;
|
||||
ShaderType type;
|
||||
String source;
|
||||
GFXShaderMacroList macros;
|
||||
ShaderMacroList macros;
|
||||
GLuint glShader = 0;
|
||||
};
|
||||
typedef vector<GLES2GPUShaderStage> GLES2GPUShaderStageList;
|
||||
@@ -154,8 +154,8 @@ typedef vector<GLES2GPUShaderStage> GLES2GPUShaderStageList;
|
||||
class GLES2GPUShader : public Object {
|
||||
public:
|
||||
String name;
|
||||
GFXUniformBlockList blocks;
|
||||
GFXUniformSamplerList samplers;
|
||||
UniformBlockList blocks;
|
||||
UniformSamplerList samplers;
|
||||
GLuint glProgram = 0;
|
||||
GLES2GPUShaderStageList gpuStages;
|
||||
GLES2GPUInputList glInputs;
|
||||
@@ -179,7 +179,7 @@ typedef vector<GLES2GPUAttribute> GLES2GPUAttributeList;
|
||||
|
||||
class GLES2GPUInputAssembler : public Object {
|
||||
public:
|
||||
GFXAttributeList attributes;
|
||||
AttributeList attributes;
|
||||
GLES2GPUBufferList gpuVertexBuffers;
|
||||
GLES2GPUBuffer *gpuIndexBuffer = nullptr;
|
||||
GLES2GPUBuffer *gpuIndirectBuffer = nullptr;
|
||||
@@ -190,8 +190,8 @@ public:
|
||||
|
||||
class GLES2GPURenderPass : public Object {
|
||||
public:
|
||||
GFXColorAttachmentList colorAttachments;
|
||||
GFXDepthStencilAttachment depthStencilAttachment;
|
||||
ColorAttachmentList colorAttachments;
|
||||
DepthStencilAttachment depthStencilAttachment;
|
||||
};
|
||||
|
||||
class GLES2GPUFramebuffer : public Object {
|
||||
@@ -211,17 +211,17 @@ class GLES2GPUPipelineState : public Object {
|
||||
public:
|
||||
GLenum glPrimitive = GL_TRIANGLES;
|
||||
GLES2GPUShader *gpuShader = nullptr;
|
||||
GFXRasterizerState rs;
|
||||
GFXDepthStencilState dss;
|
||||
GFXBlendState bs;
|
||||
GFXDynamicStateList dynamicStates;
|
||||
RasterizerState rs;
|
||||
DepthStencilState dss;
|
||||
BlendState bs;
|
||||
DynamicStateList dynamicStates;
|
||||
GLES2GPUPipelineLayout *gpuLayout = nullptr;
|
||||
GLES2GPURenderPass *gpuRenderPass = nullptr;
|
||||
};
|
||||
|
||||
struct GLES2GPUBinding {
|
||||
uint binding = GFX_INVALID_BINDING;
|
||||
GFXBindingType type = GFXBindingType::UNKNOWN;
|
||||
BindingType type = BindingType::UNKNOWN;
|
||||
String name;
|
||||
GLES2GPUBuffer *gpuBuffer = nullptr;
|
||||
GLES2GPUTexture *gpuTexture = nullptr;
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES2InputAssembler::GLES2InputAssembler(GFXDevice *device)
|
||||
: GFXInputAssembler(device) {
|
||||
GLES2InputAssembler::GLES2InputAssembler(Device *device)
|
||||
: InputAssembler(device) {
|
||||
}
|
||||
|
||||
GLES2InputAssembler::~GLES2InputAssembler() {
|
||||
}
|
||||
|
||||
bool GLES2InputAssembler::initialize(const GFXInputAssemblerInfo &info) {
|
||||
bool GLES2InputAssembler::initialize(const InputAssemblerInfo &info) {
|
||||
|
||||
_attributes = info.attributes;
|
||||
_vertexBuffers = info.vertexBuffers;
|
||||
@@ -41,7 +41,7 @@ bool GLES2InputAssembler::initialize(const GFXInputAssemblerInfo &info) {
|
||||
|
||||
GLES2CmdFuncCreateInputAssembler((GLES2Device *)_device, _gpuInputAssembler);
|
||||
_attributesHash = computeAttributesHash();
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ void GLES2InputAssembler::destroy() {
|
||||
CC_DELETE(_gpuInputAssembler);
|
||||
_gpuInputAssembler = nullptr;
|
||||
}
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
void GLES2InputAssembler::ExtractCmdDraw(GLES2CmdDraw *cmd) {
|
||||
|
||||
@@ -7,13 +7,13 @@ namespace gfx {
|
||||
class GLES2GPUInputAssembler;
|
||||
class GLES2CmdDraw;
|
||||
|
||||
class CC_GLES2_API GLES2InputAssembler : public GFXInputAssembler {
|
||||
class CC_GLES2_API GLES2InputAssembler : public InputAssembler {
|
||||
public:
|
||||
GLES2InputAssembler(GFXDevice *device);
|
||||
GLES2InputAssembler(Device *device);
|
||||
~GLES2InputAssembler();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXInputAssemblerInfo &info) override;
|
||||
virtual bool initialize(const InputAssemblerInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
|
||||
void ExtractCmdDraw(GLES2CmdDraw *cmd);
|
||||
|
||||
@@ -5,20 +5,20 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES2PipelineLayout::GLES2PipelineLayout(GFXDevice *device)
|
||||
: GFXPipelineLayout(device) {
|
||||
GLES2PipelineLayout::GLES2PipelineLayout(Device *device)
|
||||
: PipelineLayout(device) {
|
||||
}
|
||||
|
||||
GLES2PipelineLayout::~GLES2PipelineLayout() {
|
||||
}
|
||||
|
||||
bool GLES2PipelineLayout::initialize(const GFXPipelineLayoutInfo &info) {
|
||||
bool GLES2PipelineLayout::initialize(const PipelineLayoutInfo &info) {
|
||||
|
||||
_layouts = info.layouts;
|
||||
_pushConstantsRanges = info.pushConstantsRanges;
|
||||
|
||||
_gpuPipelineLayout = CC_NEW(GLES2GPUPipelineLayout);
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ void GLES2PipelineLayout::destroy() {
|
||||
_gpuPipelineLayout = nullptr;
|
||||
}
|
||||
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace gfx {
|
||||
|
||||
class GLES2GPUPipelineLayout;
|
||||
|
||||
class CC_GLES2_API GLES2PipelineLayout : public GFXPipelineLayout {
|
||||
class CC_GLES2_API GLES2PipelineLayout : public PipelineLayout {
|
||||
public:
|
||||
GLES2PipelineLayout(GFXDevice *device);
|
||||
GLES2PipelineLayout(Device *device);
|
||||
~GLES2PipelineLayout();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXPipelineLayoutInfo &info) override;
|
||||
virtual bool initialize(const PipelineLayoutInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
|
||||
CC_INLINE GLES2GPUPipelineLayout *gpuPipelineLayout() const { return _gpuPipelineLayout; }
|
||||
|
||||
@@ -25,14 +25,14 @@ const GLenum GLES2Primitives[] = {
|
||||
GL_NONE,
|
||||
};
|
||||
|
||||
GLES2PipelineState::GLES2PipelineState(GFXDevice *device)
|
||||
: GFXPipelineState(device) {
|
||||
GLES2PipelineState::GLES2PipelineState(Device *device)
|
||||
: PipelineState(device) {
|
||||
}
|
||||
|
||||
GLES2PipelineState::~GLES2PipelineState() {
|
||||
}
|
||||
|
||||
bool GLES2PipelineState::initialize(const GFXPipelineStateInfo &info) {
|
||||
bool GLES2PipelineState::initialize(const PipelineStateInfo &info) {
|
||||
|
||||
_primitive = info.primitive;
|
||||
_shader = info.shader;
|
||||
@@ -54,7 +54,7 @@ bool GLES2PipelineState::initialize(const GFXPipelineStateInfo &info) {
|
||||
_gpuPipelineState->gpuLayout = ((GLES2PipelineLayout *)_layout)->gpuPipelineLayout();
|
||||
_gpuPipelineState->gpuRenderPass = ((GLES2RenderPass *)_renderPass)->gpuRenderPass();
|
||||
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ void GLES2PipelineState::destroy() {
|
||||
_gpuPipelineState = nullptr;
|
||||
}
|
||||
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace gfx {
|
||||
|
||||
class GLES2GPUPipelineState;
|
||||
|
||||
class CC_GLES2_API GLES2PipelineState : public GFXPipelineState {
|
||||
class CC_GLES2_API GLES2PipelineState : public PipelineState {
|
||||
public:
|
||||
GLES2PipelineState(GFXDevice *device);
|
||||
GLES2PipelineState(Device *device);
|
||||
~GLES2PipelineState();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXPipelineStateInfo &info) override;
|
||||
virtual bool initialize(const PipelineStateInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
|
||||
CC_INLINE GLES2GPUPipelineState *gpuPipelineState() const { return _gpuPipelineState; }
|
||||
|
||||
@@ -6,25 +6,25 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES2Queue::GLES2Queue(GFXDevice *device)
|
||||
: GFXQueue(device) {
|
||||
GLES2Queue::GLES2Queue(Device *device)
|
||||
: Queue(device) {
|
||||
}
|
||||
|
||||
GLES2Queue::~GLES2Queue() {
|
||||
}
|
||||
|
||||
bool GLES2Queue::initialize(const GFXQueueInfo &info) {
|
||||
bool GLES2Queue::initialize(const QueueInfo &info) {
|
||||
_type = info.type;
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GLES2Queue::destroy() {
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
void GLES2Queue::submit(const vector<GFXCommandBuffer *> &cmdBuffs, GFXFence *fence) {
|
||||
void GLES2Queue::submit(const vector<CommandBuffer *> &cmdBuffs, Fence *fence) {
|
||||
if (!_isAsync) {
|
||||
uint count = static_cast<uint>(cmdBuffs.size());
|
||||
for (uint i = 0; i < count; ++i) {
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_GLES2_API GLES2Queue : public GFXQueue {
|
||||
class CC_GLES2_API GLES2Queue : public Queue {
|
||||
public:
|
||||
GLES2Queue(GFXDevice *device);
|
||||
GLES2Queue(Device *device);
|
||||
~GLES2Queue();
|
||||
|
||||
friend class GLES2Device;
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXQueueInfo &info) override;
|
||||
virtual bool initialize(const QueueInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
virtual void submit(const vector<GFXCommandBuffer *> &cmdBuffs, GFXFence *fence) override;
|
||||
virtual void submit(const vector<CommandBuffer *> &cmdBuffs, Fence *fence) override;
|
||||
|
||||
private:
|
||||
uint _numDrawCalls = 0;
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES2RenderPass::GLES2RenderPass(GFXDevice *device)
|
||||
: GFXRenderPass(device) {
|
||||
GLES2RenderPass::GLES2RenderPass(Device *device)
|
||||
: RenderPass(device) {
|
||||
}
|
||||
|
||||
GLES2RenderPass::~GLES2RenderPass() {
|
||||
}
|
||||
|
||||
bool GLES2RenderPass::initialize(const GFXRenderPassInfo &info) {
|
||||
bool GLES2RenderPass::initialize(const RenderPassInfo &info) {
|
||||
|
||||
_colorAttachments = info.colorAttachments;
|
||||
_depthStencilAttachment = info.depthStencilAttachment;
|
||||
@@ -22,7 +22,7 @@ bool GLES2RenderPass::initialize(const GFXRenderPassInfo &info) {
|
||||
_gpuRenderPass->depthStencilAttachment = _depthStencilAttachment;
|
||||
|
||||
_hash = computeHash();
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ void GLES2RenderPass::destroy() {
|
||||
_gpuRenderPass = nullptr;
|
||||
}
|
||||
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace gfx {
|
||||
|
||||
class GLES2GPURenderPass;
|
||||
|
||||
class CC_GLES2_API GLES2RenderPass : public GFXRenderPass {
|
||||
class CC_GLES2_API GLES2RenderPass : public RenderPass {
|
||||
public:
|
||||
GLES2RenderPass(GFXDevice *device);
|
||||
GLES2RenderPass(Device *device);
|
||||
~GLES2RenderPass();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXRenderPassInfo &info) override;
|
||||
virtual bool initialize(const RenderPassInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
|
||||
CC_INLINE GLES2GPURenderPass *gpuRenderPass() const { return _gpuRenderPass; }
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES2Sampler::GLES2Sampler(GFXDevice *device)
|
||||
: GFXSampler(device) {
|
||||
GLES2Sampler::GLES2Sampler(Device *device)
|
||||
: Sampler(device) {
|
||||
}
|
||||
|
||||
GLES2Sampler::~GLES2Sampler() {
|
||||
}
|
||||
|
||||
bool GLES2Sampler::initialize(const GFXSamplerInfo &info) {
|
||||
bool GLES2Sampler::initialize(const SamplerInfo &info) {
|
||||
_name = info.name;
|
||||
_minFilter = info.minFilter;
|
||||
_magFilter = info.magFilter;
|
||||
@@ -37,7 +37,7 @@ bool GLES2Sampler::initialize(const GFXSamplerInfo &info) {
|
||||
_gpuSampler->minLOD = _minLOD;
|
||||
_gpuSampler->maxLOD = _maxLOD;
|
||||
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
|
||||
GLES2CmdFuncCreateSampler((GLES2Device *)_device, _gpuSampler);
|
||||
|
||||
@@ -50,7 +50,7 @@ void GLES2Sampler::destroy() {
|
||||
CC_DELETE(_gpuSampler);
|
||||
_gpuSampler = nullptr;
|
||||
}
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace gfx {
|
||||
|
||||
class GLES2GPUSampler;
|
||||
|
||||
class CC_GLES2_API GLES2Sampler : public GFXSampler {
|
||||
class CC_GLES2_API GLES2Sampler : public Sampler {
|
||||
public:
|
||||
GLES2Sampler(GFXDevice *device);
|
||||
GLES2Sampler(Device *device);
|
||||
~GLES2Sampler();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXSamplerInfo &info) override;
|
||||
virtual bool initialize(const SamplerInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
|
||||
CC_INLINE GLES2GPUSampler *gpuSampler() const { return _gpuSampler; }
|
||||
@@ -20,15 +20,15 @@ public:
|
||||
private:
|
||||
GLES2GPUSampler *_gpuSampler = nullptr;
|
||||
String _name;
|
||||
GFXFilter _minFilter = GFXFilter::LINEAR;
|
||||
GFXFilter _magFilter = GFXFilter::LINEAR;
|
||||
GFXFilter _mipFilter = GFXFilter::NONE;
|
||||
GFXAddress _addressU = GFXAddress::WRAP;
|
||||
GFXAddress _addressV = GFXAddress::WRAP;
|
||||
GFXAddress _addressW = GFXAddress::WRAP;
|
||||
Filter _minFilter = Filter::LINEAR;
|
||||
Filter _magFilter = Filter::LINEAR;
|
||||
Filter _mipFilter = Filter::NONE;
|
||||
Address _addressU = Address::WRAP;
|
||||
Address _addressV = Address::WRAP;
|
||||
Address _addressW = Address::WRAP;
|
||||
uint _maxAnisotropy = 16;
|
||||
GFXComparisonFunc _cmpFunc = GFXComparisonFunc::NEVER;
|
||||
GFXColor _borderColor;
|
||||
ComparisonFunc _cmpFunc = ComparisonFunc::NEVER;
|
||||
Color _borderColor;
|
||||
uint _minLOD = 0;
|
||||
uint _maxLOD = 1000;
|
||||
float _mipLODBias = 0.0f;
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES2Shader::GLES2Shader(GFXDevice *device)
|
||||
: GFXShader(device) {
|
||||
GLES2Shader::GLES2Shader(Device *device)
|
||||
: Shader(device) {
|
||||
}
|
||||
|
||||
GLES2Shader::~GLES2Shader() {
|
||||
}
|
||||
|
||||
bool GLES2Shader::initialize(const GFXShaderInfo &info) {
|
||||
bool GLES2Shader::initialize(const ShaderInfo &info) {
|
||||
_name = info.name;
|
||||
_stages = info.stages;
|
||||
_attributes = info.attributes;
|
||||
@@ -30,7 +30,7 @@ bool GLES2Shader::initialize(const GFXShaderInfo &info) {
|
||||
|
||||
GLES2CmdFuncCreateShader((GLES2Device *)_device, _gpuShader);
|
||||
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ void GLES2Shader::destroy() {
|
||||
CC_DELETE(_gpuShader);
|
||||
_gpuShader = nullptr;
|
||||
}
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace gfx {
|
||||
|
||||
class GLES2GPUShader;
|
||||
|
||||
class CC_GLES2_API GLES2Shader : public GFXShader {
|
||||
class CC_GLES2_API GLES2Shader : public Shader {
|
||||
public:
|
||||
GLES2Shader(GFXDevice *device);
|
||||
GLES2Shader(Device *device);
|
||||
~GLES2Shader();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXShaderInfo &info) override;
|
||||
virtual bool initialize(const ShaderInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
|
||||
CC_INLINE GLES2GPUShader *gpuShader() const { return _gpuShader; }
|
||||
|
||||
@@ -21,11 +21,11 @@ public:
|
||||
bool glCurrentAttribLocs[GFX_MAX_VERTEX_ATTRIBUTES] = {false};
|
||||
GLuint glFramebuffer = 0;
|
||||
GLuint glReadFBO = 0;
|
||||
GFXViewport viewport;
|
||||
GFXRect scissor;
|
||||
GFXRasterizerState rs;
|
||||
GFXDepthStencilState dss;
|
||||
GFXBlendState bs;
|
||||
Viewport viewport;
|
||||
Rect scissor;
|
||||
RasterizerState rs;
|
||||
DepthStencilState dss;
|
||||
BlendState bs;
|
||||
bool isCullFaceEnabled = true;
|
||||
bool isStencilTestEnabled = false;
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES2Texture::GLES2Texture(GFXDevice *device)
|
||||
: GFXTexture(device) {
|
||||
GLES2Texture::GLES2Texture(Device *device)
|
||||
: Texture(device) {
|
||||
}
|
||||
|
||||
GLES2Texture::~GLES2Texture() {
|
||||
}
|
||||
|
||||
bool GLES2Texture::initialize(const GFXTextureInfo &info) {
|
||||
bool GLES2Texture::initialize(const TextureInfo &info) {
|
||||
|
||||
_type = info.type;
|
||||
_usage = info.usage;
|
||||
@@ -25,45 +25,45 @@ bool GLES2Texture::initialize(const GFXTextureInfo &info) {
|
||||
_mipLevel = info.mipLevel;
|
||||
_samples = info.samples;
|
||||
_flags = info.flags;
|
||||
_size = GFXFormatSize(_format, _width, _height, _depth);
|
||||
_size = FormatSize(_format, _width, _height, _depth);
|
||||
|
||||
#if COCOS2D_DEBUG > 0
|
||||
switch (_format) { // device feature validation
|
||||
case GFXFormat::D16:
|
||||
if (_device->hasFeature(GFXFeature::FORMAT_D16)) break;
|
||||
case Format::D16:
|
||||
if (_device->hasFeature(Feature::FORMAT_D16)) break;
|
||||
CC_LOG_ERROR("D16 texture format is not supported on this backend");
|
||||
return false;
|
||||
case GFXFormat::D16S8:
|
||||
if (_device->hasFeature(GFXFeature::FORMAT_D16S8)) break;
|
||||
case Format::D16S8:
|
||||
if (_device->hasFeature(Feature::FORMAT_D16S8)) break;
|
||||
CC_LOG_WARNING("D16S8 texture format is not supported on this backend");
|
||||
return false;
|
||||
case GFXFormat::D24:
|
||||
if (_device->hasFeature(GFXFeature::FORMAT_D24)) break;
|
||||
case Format::D24:
|
||||
if (_device->hasFeature(Feature::FORMAT_D24)) break;
|
||||
CC_LOG_WARNING("D24 texture format is not supported on this backend");
|
||||
return false;
|
||||
case GFXFormat::D24S8:
|
||||
if (_device->hasFeature(GFXFeature::FORMAT_D24S8)) break;
|
||||
case Format::D24S8:
|
||||
if (_device->hasFeature(Feature::FORMAT_D24S8)) break;
|
||||
CC_LOG_WARNING("D24S8 texture format is not supported on this backend");
|
||||
return false;
|
||||
case GFXFormat::D32F:
|
||||
if (_device->hasFeature(GFXFeature::FORMAT_D32F)) break;
|
||||
case Format::D32F:
|
||||
if (_device->hasFeature(Feature::FORMAT_D32F)) break;
|
||||
CC_LOG_WARNING("D32F texture format is not supported on this backend");
|
||||
return false;
|
||||
case GFXFormat::D32F_S8:
|
||||
if (_device->hasFeature(GFXFeature::FORMAT_D32FS8)) break;
|
||||
case Format::D32F_S8:
|
||||
if (_device->hasFeature(Feature::FORMAT_D32FS8)) break;
|
||||
CC_LOG_WARNING("D32FS8 texture format is not supported on this backend");
|
||||
return false;
|
||||
case GFXFormat::RGB8:
|
||||
if (_device->hasFeature(GFXFeature::FORMAT_RGB8)) break;
|
||||
case Format::RGB8:
|
||||
if (_device->hasFeature(Feature::FORMAT_RGB8)) break;
|
||||
CC_LOG_WARNING("RGB8 texture format is not supported on this backend");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (_flags & GFXTextureFlags::BAKUP_BUFFER) {
|
||||
if (_flags & TextureFlags::BAKUP_BUFFER) {
|
||||
_buffer = (uint8_t *)CC_MALLOC(_size);
|
||||
if (!_buffer) {
|
||||
_status = GFXStatus::FAILED;
|
||||
_status = Status::FAILED;
|
||||
CC_LOG_ERROR("GLES2Texture: CC_MALLOC backup buffer failed.");
|
||||
return false;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ bool GLES2Texture::initialize(const GFXTextureInfo &info) {
|
||||
|
||||
_gpuTexture = CC_NEW(GLES2GPUTexture);
|
||||
if (!_gpuTexture) {
|
||||
_status = GFXStatus::FAILED;
|
||||
_status = Status::FAILED;
|
||||
CC_LOG_ERROR("GLES2Texture: CC_NEW GLES2GPUTexture failed.");
|
||||
return false;
|
||||
}
|
||||
@@ -91,13 +91,13 @@ bool GLES2Texture::initialize(const GFXTextureInfo &info) {
|
||||
|
||||
GLES2CmdFuncCreateTexture((GLES2Device *)_device, _gpuTexture);
|
||||
_device->getMemoryStatus().textureSize += _size;
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GLES2Texture::initialize(const GFXTextureViewInfo &info) {
|
||||
bool GLES2Texture::initialize(const TextureViewInfo &info) {
|
||||
CC_LOG_ERROR("GLES2 doesn't support texture view");
|
||||
_status = GFXStatus::FAILED;
|
||||
_status = Status::FAILED;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -115,18 +115,18 @@ void GLES2Texture::destroy() {
|
||||
_buffer = nullptr;
|
||||
}
|
||||
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
void GLES2Texture::resize(uint width, uint height) {
|
||||
uint size = GFXFormatSize(_format, width, height, _depth);
|
||||
uint size = FormatSize(_format, width, height, _depth);
|
||||
if (_size != size) {
|
||||
const uint oldSize = _size;
|
||||
_width = width;
|
||||
_height = height;
|
||||
_size = size;
|
||||
|
||||
GFXMemoryStatus &status = _device->getMemoryStatus();
|
||||
MemoryStatus &status = _device->getMemoryStatus();
|
||||
_gpuTexture->width = _width;
|
||||
_gpuTexture->height = _height;
|
||||
_gpuTexture->size = _size;
|
||||
@@ -138,7 +138,7 @@ void GLES2Texture::resize(uint width, uint height) {
|
||||
const uint8_t *oldBuffer = _buffer;
|
||||
uint8_t *buffer = (uint8_t *)CC_MALLOC(_size);
|
||||
if (!buffer) {
|
||||
_status = GFXStatus::FAILED;
|
||||
_status = Status::FAILED;
|
||||
CC_LOG_ERROR("GLES2Texture: CC_MALLOC backup buffer failed when resize the texture.");
|
||||
return;
|
||||
}
|
||||
@@ -148,7 +148,7 @@ void GLES2Texture::resize(uint width, uint height) {
|
||||
status.bufferSize -= oldSize;
|
||||
status.bufferSize += _size;
|
||||
}
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ namespace gfx {
|
||||
|
||||
class GLES2GPUTexture;
|
||||
|
||||
class CC_GLES2_API GLES2Texture : public GFXTexture {
|
||||
class CC_GLES2_API GLES2Texture : public Texture {
|
||||
public:
|
||||
GLES2Texture(GFXDevice *device);
|
||||
GLES2Texture(Device *device);
|
||||
~GLES2Texture();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXTextureInfo &info) override;
|
||||
virtual bool initialize(const GFXTextureViewInfo &info) override;
|
||||
virtual bool initialize(const TextureInfo &info) override;
|
||||
virtual bool initialize(const TextureViewInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
virtual void resize(uint width, uint height) override;
|
||||
|
||||
|
||||
@@ -8,20 +8,20 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES3BindingLayout::GLES3BindingLayout(GFXDevice *device)
|
||||
: GFXBindingLayout(device) {
|
||||
GLES3BindingLayout::GLES3BindingLayout(Device *device)
|
||||
: BindingLayout(device) {
|
||||
}
|
||||
|
||||
GLES3BindingLayout::~GLES3BindingLayout() {
|
||||
}
|
||||
|
||||
bool GLES3BindingLayout::initialize(const GFXBindingLayoutInfo &info) {
|
||||
bool GLES3BindingLayout::initialize(const BindingLayoutInfo &info) {
|
||||
if (info.bindings.size()) {
|
||||
_bindingUnits.resize(info.bindings.size());
|
||||
|
||||
for (size_t i = 0; i < _bindingUnits.size(); ++i) {
|
||||
GFXBindingUnit &bindingUnit = _bindingUnits[i];
|
||||
const GFXBinding &binding = info.bindings[i];
|
||||
BindingUnit &bindingUnit = _bindingUnits[i];
|
||||
const Binding &binding = info.bindings[i];
|
||||
bindingUnit.shaderStages = binding.shaderStages;
|
||||
bindingUnit.binding = binding.binding;
|
||||
bindingUnit.type = binding.type;
|
||||
@@ -33,13 +33,13 @@ bool GLES3BindingLayout::initialize(const GFXBindingLayoutInfo &info) {
|
||||
_gpuBindingLayout->gpuBindings.resize(_bindingUnits.size());
|
||||
for (size_t i = 0; i < _gpuBindingLayout->gpuBindings.size(); ++i) {
|
||||
GLES3GPUBinding &gpuBinding = _gpuBindingLayout->gpuBindings[i];
|
||||
const GFXBindingUnit &bindingUnit = _bindingUnits[i];
|
||||
const BindingUnit &bindingUnit = _bindingUnits[i];
|
||||
gpuBinding.binding = bindingUnit.binding;
|
||||
gpuBinding.type = bindingUnit.type;
|
||||
gpuBinding.name = bindingUnit.name;
|
||||
}
|
||||
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -50,21 +50,21 @@ void GLES3BindingLayout::destroy() {
|
||||
_gpuBindingLayout = nullptr;
|
||||
}
|
||||
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
void GLES3BindingLayout::update() {
|
||||
if (_isDirty && _gpuBindingLayout) {
|
||||
for (size_t i = 0; i < _bindingUnits.size(); ++i) {
|
||||
GFXBindingUnit &bindingUnit = _bindingUnits[i];
|
||||
BindingUnit &bindingUnit = _bindingUnits[i];
|
||||
switch (bindingUnit.type) {
|
||||
case GFXBindingType::UNIFORM_BUFFER: {
|
||||
case BindingType::UNIFORM_BUFFER: {
|
||||
if (bindingUnit.buffer) {
|
||||
_gpuBindingLayout->gpuBindings[i].gpuBuffer = ((GLES3Buffer *)bindingUnit.buffer)->gpuBuffer();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GFXBindingType::SAMPLER: {
|
||||
case BindingType::SAMPLER: {
|
||||
if (bindingUnit.texture) {
|
||||
_gpuBindingLayout->gpuBindings[i].gpuTexture = ((GLES3Texture *)bindingUnit.texture)->gpuTexture();
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace gfx {
|
||||
|
||||
class GLES3GPUBindingLayout;
|
||||
|
||||
class CC_GLES3_API GLES3BindingLayout : public GFXBindingLayout {
|
||||
class CC_GLES3_API GLES3BindingLayout : public BindingLayout {
|
||||
public:
|
||||
GLES3BindingLayout(GFXDevice *device);
|
||||
GLES3BindingLayout(Device *device);
|
||||
~GLES3BindingLayout();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXBindingLayoutInfo &info) override;
|
||||
virtual bool initialize(const BindingLayoutInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
virtual void update() override;
|
||||
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES3Buffer::GLES3Buffer(GFXDevice *device)
|
||||
: GFXBuffer(device) {
|
||||
GLES3Buffer::GLES3Buffer(Device *device)
|
||||
: Buffer(device) {
|
||||
}
|
||||
|
||||
GLES3Buffer::~GLES3Buffer() {
|
||||
}
|
||||
|
||||
bool GLES3Buffer::initialize(const GFXBufferInfo &info) {
|
||||
bool GLES3Buffer::initialize(const BufferInfo &info) {
|
||||
_usage = info.usage;
|
||||
_memUsage = info.memUsage;
|
||||
_size = info.size;
|
||||
@@ -20,10 +20,10 @@ bool GLES3Buffer::initialize(const GFXBufferInfo &info) {
|
||||
_count = _size / _stride;
|
||||
_flags = info.flags;
|
||||
|
||||
if ((_flags & GFXBufferFlagBit::BAKUP_BUFFER) && _size > 0) {
|
||||
if ((_flags & BufferFlagBit::BAKUP_BUFFER) && _size > 0) {
|
||||
_buffer = (uint8_t *)CC_MALLOC(_size);
|
||||
if (!_buffer) {
|
||||
_status = GFXStatus::FAILED;
|
||||
_status = Status::FAILED;
|
||||
CC_LOG_ERROR("GLES3Buffer: CC_MALLOC backup buffer failed.");
|
||||
return false;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ bool GLES3Buffer::initialize(const GFXBufferInfo &info) {
|
||||
|
||||
_gpuBuffer = CC_NEW(GLES3GPUBuffer);
|
||||
if (!_gpuBuffer) {
|
||||
_status = GFXStatus::FAILED;
|
||||
_status = Status::FAILED;
|
||||
CC_LOG_ERROR("GLES3Buffer: CC_NEW GLES3GPUBuffer failed.");
|
||||
return false;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ bool GLES3Buffer::initialize(const GFXBufferInfo &info) {
|
||||
_gpuBuffer->stride = _stride;
|
||||
_gpuBuffer->count = _count;
|
||||
|
||||
if (_usage & GFXBufferUsageBit::INDIRECT) {
|
||||
if (_usage & BufferUsageBit::INDIRECT) {
|
||||
_gpuBuffer->indirects.resize(_count);
|
||||
} else {
|
||||
_gpuBuffer->buffer = _buffer;
|
||||
@@ -50,7 +50,7 @@ bool GLES3Buffer::initialize(const GFXBufferInfo &info) {
|
||||
|
||||
GLES3CmdFuncCreateBuffer((GLES3Device *)_device, _gpuBuffer);
|
||||
_device->getMemoryStatus().bufferSize += _size;
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ void GLES3Buffer::destroy() {
|
||||
_device->getMemoryStatus().bufferSize -= _size;
|
||||
_buffer = nullptr;
|
||||
}
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
void GLES3Buffer::resize(uint size) {
|
||||
@@ -76,7 +76,7 @@ void GLES3Buffer::resize(uint size) {
|
||||
_size = size;
|
||||
_count = _size / _stride;
|
||||
|
||||
GFXMemoryStatus &status = _device->getMemoryStatus();
|
||||
MemoryStatus &status = _device->getMemoryStatus();
|
||||
_gpuBuffer->size = _size;
|
||||
_gpuBuffer->count = _count;
|
||||
GLES3CmdFuncResizeBuffer((GLES3Device *)_device, _gpuBuffer);
|
||||
@@ -87,7 +87,7 @@ void GLES3Buffer::resize(uint size) {
|
||||
const uint8_t *oldBuffer = _buffer;
|
||||
uint8_t *buffer = (uint8_t *)CC_MALLOC(_size);
|
||||
if (!buffer) {
|
||||
_status = GFXStatus::FAILED;
|
||||
_status = Status::FAILED;
|
||||
CC_LOG_ERROR("GLES3Buffer: CC_MALLOC resize backup buffer failed.");
|
||||
return;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ void GLES3Buffer::resize(uint size) {
|
||||
status.bufferSize -= oldSize;
|
||||
status.bufferSize += _size;
|
||||
}
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace gfx {
|
||||
|
||||
class GLES3GPUBuffer;
|
||||
|
||||
class CC_GLES3_API GLES3Buffer : public GFXBuffer {
|
||||
class CC_GLES3_API GLES3Buffer : public Buffer {
|
||||
public:
|
||||
GLES3Buffer(GFXDevice *device);
|
||||
GLES3Buffer(Device *device);
|
||||
~GLES3Buffer();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXBufferInfo &info) override;
|
||||
virtual bool initialize(const BufferInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
virtual void resize(uint size) override;
|
||||
virtual void update(void *buffer, uint offset, uint size) override;
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES3CommandAllocator::GLES3CommandAllocator(GFXDevice *device)
|
||||
: GFXCommandAllocator(device) {
|
||||
GLES3CommandAllocator::GLES3CommandAllocator(Device *device)
|
||||
: CommandAllocator(device) {
|
||||
}
|
||||
|
||||
GLES3CommandAllocator::~GLES3CommandAllocator() {
|
||||
}
|
||||
|
||||
bool GLES3CommandAllocator::initialize(const GFXCommandAllocatorInfo &info) {
|
||||
_status = GFXStatus::SUCCESS;
|
||||
bool GLES3CommandAllocator::initialize(const CommandAllocatorInfo &info) {
|
||||
_status = Status::SUCCESS;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GLES3CommandAllocator::destroy() {
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
void GLES3CommandAllocator::clearCmds(GLES3CmdPackage *cmd_package) {
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_GLES3_API GLES3CommandAllocator : public GFXCommandAllocator {
|
||||
class CC_GLES3_API GLES3CommandAllocator : public CommandAllocator {
|
||||
public:
|
||||
GLES3CommandAllocator(GFXDevice *device);
|
||||
GLES3CommandAllocator(Device *device);
|
||||
~GLES3CommandAllocator();
|
||||
|
||||
GFXCommandPool<GLES3CmdBeginRenderPass> beginRenderPassCmdPool;
|
||||
GFXCommandPool<GLES3CmdBindStates> bindStatesCmdPool;
|
||||
GFXCommandPool<GLES3CmdDraw> drawCmdPool;
|
||||
GFXCommandPool<GLES3CmdUpdateBuffer> updateBufferCmdPool;
|
||||
GFXCommandPool<GLES3CmdCopyBufferToTexture> copyBufferToTextureCmdPool;
|
||||
CommandPool<GLES3CmdBeginRenderPass> beginRenderPassCmdPool;
|
||||
CommandPool<GLES3CmdBindStates> bindStatesCmdPool;
|
||||
CommandPool<GLES3CmdDraw> drawCmdPool;
|
||||
CommandPool<GLES3CmdUpdateBuffer> updateBufferCmdPool;
|
||||
CommandPool<GLES3CmdCopyBufferToTexture> copyBufferToTextureCmdPool;
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXCommandAllocatorInfo &info) override;
|
||||
virtual bool initialize(const CommandAllocatorInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
|
||||
void clearCmds(GLES3CmdPackage *cmd_package);
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES3CommandBuffer::GLES3CommandBuffer(GFXDevice *device)
|
||||
: GFXCommandBuffer(device) {
|
||||
GLES3CommandBuffer::GLES3CommandBuffer(Device *device)
|
||||
: CommandBuffer(device) {
|
||||
}
|
||||
|
||||
GLES3CommandBuffer::~GLES3CommandBuffer() {
|
||||
}
|
||||
|
||||
bool GLES3CommandBuffer::initialize(const GFXCommandBufferInfo &info) {
|
||||
bool GLES3CommandBuffer::initialize(const CommandBufferInfo &info) {
|
||||
if (!info.allocator) {
|
||||
return false;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ bool GLES3CommandBuffer::initialize(const GFXCommandBufferInfo &info) {
|
||||
_type = info.type;
|
||||
|
||||
_cmdPackage = CC_NEW(GLES3CmdPackage);
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -39,12 +39,12 @@ void GLES3CommandBuffer::destroy() {
|
||||
_gles3Allocator = nullptr;
|
||||
}
|
||||
_allocator = nullptr;
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
|
||||
CC_SAFE_DELETE(_cmdPackage);
|
||||
}
|
||||
|
||||
void GLES3CommandBuffer::begin(GFXRenderPass *renderPass, uint subpass, GFXFramebuffer *frameBuffer) {
|
||||
void GLES3CommandBuffer::begin(RenderPass *renderPass, uint subpass, Framebuffer *frameBuffer) {
|
||||
_gles3Allocator->clearCmds(_cmdPackage);
|
||||
_curGPUPipelineState = nullptr;
|
||||
_curGPUBlendLayout = nullptr;
|
||||
@@ -61,7 +61,7 @@ void GLES3CommandBuffer::end() {
|
||||
_isInRenderPass = false;
|
||||
}
|
||||
|
||||
void GLES3CommandBuffer::beginRenderPass(GFXFramebuffer *fbo, const GFXRect &render_area, GFXClearFlags clear_flags, const std::vector<GFXColor> &colors, float depth, int stencil) {
|
||||
void GLES3CommandBuffer::beginRenderPass(Framebuffer *fbo, const Rect &render_area, ClearFlags clear_flags, const std::vector<Color> &colors, float depth, int stencil) {
|
||||
_isInRenderPass = true;
|
||||
|
||||
GLES3CmdBeginRenderPass *cmd = _gles3Allocator->beginRenderPassCmdPool.alloc();
|
||||
@@ -83,22 +83,22 @@ void GLES3CommandBuffer::endRenderPass() {
|
||||
_cmdPackage->cmds.push(GFXCmdType::END_RENDER_PASS);
|
||||
}
|
||||
|
||||
void GLES3CommandBuffer::bindPipelineState(GFXPipelineState *pso) {
|
||||
void GLES3CommandBuffer::bindPipelineState(PipelineState *pso) {
|
||||
_curGPUPipelineState = ((GLES3PipelineState *)pso)->gpuPipelineState();
|
||||
_isStateInvalid = true;
|
||||
}
|
||||
|
||||
void GLES3CommandBuffer::bindBindingLayout(GFXBindingLayout *layout) {
|
||||
void GLES3CommandBuffer::bindBindingLayout(BindingLayout *layout) {
|
||||
_curGPUBlendLayout = ((GLES3BindingLayout *)layout)->gpuBindingLayout();
|
||||
_isStateInvalid = true;
|
||||
}
|
||||
|
||||
void GLES3CommandBuffer::bindInputAssembler(GFXInputAssembler *ia) {
|
||||
void GLES3CommandBuffer::bindInputAssembler(InputAssembler *ia) {
|
||||
_curGPUInputAssember = ((GLES3InputAssembler *)ia)->gpuInputAssembler();
|
||||
_isStateInvalid = true;
|
||||
}
|
||||
|
||||
void GLES3CommandBuffer::setViewport(const GFXViewport &vp) {
|
||||
void GLES3CommandBuffer::setViewport(const Viewport &vp) {
|
||||
|
||||
if ((_curViewport.left != vp.left) ||
|
||||
(_curViewport.top != vp.top) ||
|
||||
@@ -112,7 +112,7 @@ void GLES3CommandBuffer::setViewport(const GFXViewport &vp) {
|
||||
}
|
||||
}
|
||||
|
||||
void GLES3CommandBuffer::setScissor(const GFXRect &rect) {
|
||||
void GLES3CommandBuffer::setScissor(const Rect &rect) {
|
||||
if ((_curScissor.x != rect.x) ||
|
||||
(_curScissor.y != rect.y) ||
|
||||
(_curScissor.width != rect.width) ||
|
||||
@@ -142,7 +142,7 @@ void GLES3CommandBuffer::setDepthBias(float constant, float clamp, float slope)
|
||||
}
|
||||
}
|
||||
|
||||
void GLES3CommandBuffer::setBlendConstants(const GFXColor &constants) {
|
||||
void GLES3CommandBuffer::setBlendConstants(const Color &constants) {
|
||||
if (math::IsNotEqualF(_curBlendConstants.r, constants.r) ||
|
||||
math::IsNotEqualF(_curBlendConstants.g, constants.g) ||
|
||||
math::IsNotEqualF(_curBlendConstants.b, constants.b) ||
|
||||
@@ -166,7 +166,7 @@ void GLES3CommandBuffer::setDepthBound(float min_bounds, float max_bounds) {
|
||||
}
|
||||
}
|
||||
|
||||
void GLES3CommandBuffer::setStencilWriteMask(GFXStencilFace face, uint mask) {
|
||||
void GLES3CommandBuffer::setStencilWriteMask(StencilFace face, uint mask) {
|
||||
if ((_curStencilWriteMask.face != face) ||
|
||||
(_curStencilWriteMask.write_mask != mask)) {
|
||||
|
||||
@@ -176,7 +176,7 @@ void GLES3CommandBuffer::setStencilWriteMask(GFXStencilFace face, uint mask) {
|
||||
}
|
||||
}
|
||||
|
||||
void GLES3CommandBuffer::setStencilCompareMask(GFXStencilFace face, int ref, uint mask) {
|
||||
void GLES3CommandBuffer::setStencilCompareMask(StencilFace face, int ref, uint mask) {
|
||||
if ((_curStencilCompareMask.face != face) ||
|
||||
(_curStencilCompareMask.refrence != ref) ||
|
||||
(_curStencilCompareMask.compare_mask != mask)) {
|
||||
@@ -188,9 +188,9 @@ void GLES3CommandBuffer::setStencilCompareMask(GFXStencilFace face, int ref, uin
|
||||
}
|
||||
}
|
||||
|
||||
void GLES3CommandBuffer::draw(GFXInputAssembler *ia) {
|
||||
if ((_type == GFXCommandBufferType::PRIMARY && _isInRenderPass) ||
|
||||
(_type == GFXCommandBufferType::SECONDARY)) {
|
||||
void GLES3CommandBuffer::draw(InputAssembler *ia) {
|
||||
if ((_type == CommandBufferType::PRIMARY && _isInRenderPass) ||
|
||||
(_type == CommandBufferType::SECONDARY)) {
|
||||
|
||||
if (_isStateInvalid) {
|
||||
BindStates();
|
||||
@@ -223,9 +223,9 @@ void GLES3CommandBuffer::draw(GFXInputAssembler *ia) {
|
||||
}
|
||||
}
|
||||
|
||||
void GLES3CommandBuffer::updateBuffer(GFXBuffer *buff, void *data, uint size, uint offset) {
|
||||
if ((_type == GFXCommandBufferType::PRIMARY && !_isInRenderPass) ||
|
||||
(_type == GFXCommandBufferType::SECONDARY)) {
|
||||
void GLES3CommandBuffer::updateBuffer(Buffer *buff, void *data, uint size, uint offset) {
|
||||
if ((_type == CommandBufferType::PRIMARY && !_isInRenderPass) ||
|
||||
(_type == CommandBufferType::SECONDARY)) {
|
||||
|
||||
GLES3GPUBuffer *gpuBuffer = ((GLES3Buffer *)buff)->gpuBuffer();
|
||||
if (gpuBuffer) {
|
||||
@@ -243,9 +243,9 @@ void GLES3CommandBuffer::updateBuffer(GFXBuffer *buff, void *data, uint size, ui
|
||||
}
|
||||
}
|
||||
|
||||
void GLES3CommandBuffer::copyBufferToTexture(GFXBuffer *src, GFXTexture *dst, GFXTextureLayout layout, const GFXBufferTextureCopyList ®ions) {
|
||||
if ((_type == GFXCommandBufferType::PRIMARY && !_isInRenderPass) ||
|
||||
(_type == GFXCommandBufferType::SECONDARY)) {
|
||||
void GLES3CommandBuffer::copyBufferToTexture(Buffer *src, Texture *dst, TextureLayout layout, const BufferTextureCopyList ®ions) {
|
||||
if ((_type == CommandBufferType::PRIMARY && !_isInRenderPass) ||
|
||||
(_type == CommandBufferType::SECONDARY)) {
|
||||
|
||||
GLES3GPUBuffer *gpuBuffer = ((GLES3Buffer *)src)->gpuBuffer();
|
||||
GLES3GPUTexture *gpuTexture = ((GLES3Texture *)dst)->gpuTexture();
|
||||
@@ -267,7 +267,7 @@ void GLES3CommandBuffer::copyBufferToTexture(GFXBuffer *src, GFXTexture *dst, GF
|
||||
}
|
||||
}
|
||||
|
||||
void GLES3CommandBuffer::execute(const std::vector<GFXCommandBuffer *> &cmd_buffs, uint32_t count) {
|
||||
void GLES3CommandBuffer::execute(const std::vector<CommandBuffer *> &cmd_buffs, uint32_t count) {
|
||||
for (uint i = 0; i < count; ++i) {
|
||||
GLES3CommandBuffer *cmd_buff = (GLES3CommandBuffer *)cmd_buffs[i];
|
||||
|
||||
|
||||
@@ -8,36 +8,36 @@ namespace gfx {
|
||||
|
||||
class GLES3CommandAllocator;
|
||||
|
||||
class CC_GLES3_API GLES3CommandBuffer : public GFXCommandBuffer {
|
||||
class CC_GLES3_API GLES3CommandBuffer : public CommandBuffer {
|
||||
friend class GLES3Queue;
|
||||
|
||||
public:
|
||||
GLES3CommandBuffer(GFXDevice *device);
|
||||
GLES3CommandBuffer(Device *device);
|
||||
~GLES3CommandBuffer();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXCommandBufferInfo &info) override;
|
||||
virtual bool initialize(const CommandBufferInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
|
||||
virtual void begin(GFXRenderPass *renderPass = nullptr, uint subpass = 0, GFXFramebuffer *frameBuffer = nullptr) override;
|
||||
virtual void begin(RenderPass *renderPass = nullptr, uint subpass = 0, Framebuffer *frameBuffer = nullptr) override;
|
||||
virtual void end() override;
|
||||
virtual void beginRenderPass(GFXFramebuffer *fbo, const GFXRect &render_area, GFXClearFlags clear_flags, const std::vector<GFXColor> &colors, float depth, int stencil) override;
|
||||
virtual void beginRenderPass(Framebuffer *fbo, const Rect &render_area, ClearFlags clear_flags, const std::vector<Color> &colors, float depth, int stencil) override;
|
||||
virtual void endRenderPass() override;
|
||||
virtual void bindPipelineState(GFXPipelineState *pso) override;
|
||||
virtual void bindBindingLayout(GFXBindingLayout *layout) override;
|
||||
virtual void bindInputAssembler(GFXInputAssembler *ia) override;
|
||||
virtual void setViewport(const GFXViewport &vp) override;
|
||||
virtual void setScissor(const GFXRect &rect) override;
|
||||
virtual void bindPipelineState(PipelineState *pso) override;
|
||||
virtual void bindBindingLayout(BindingLayout *layout) override;
|
||||
virtual void bindInputAssembler(InputAssembler *ia) override;
|
||||
virtual void setViewport(const Viewport &vp) override;
|
||||
virtual void setScissor(const Rect &rect) override;
|
||||
virtual void setLineWidth(const float width) override;
|
||||
virtual void setDepthBias(float constant, float clamp, float slope) override;
|
||||
virtual void setBlendConstants(const GFXColor &constants) override;
|
||||
virtual void setBlendConstants(const Color &constants) override;
|
||||
virtual void setDepthBound(float min_bounds, float max_bounds) override;
|
||||
virtual void setStencilWriteMask(GFXStencilFace face, uint mask) override;
|
||||
virtual void setStencilCompareMask(GFXStencilFace face, int ref, uint mask) override;
|
||||
virtual void draw(GFXInputAssembler *ia) override;
|
||||
virtual void updateBuffer(GFXBuffer *buff, void *data, uint size, uint offset) override;
|
||||
virtual void copyBufferToTexture(GFXBuffer *src, GFXTexture *dst, GFXTextureLayout layout, const GFXBufferTextureCopyList ®ions) override;
|
||||
virtual void execute(const std::vector<GFXCommandBuffer *> &cmd_buffs, uint32_t count) override;
|
||||
virtual void setStencilWriteMask(StencilFace face, uint mask) override;
|
||||
virtual void setStencilCompareMask(StencilFace face, int ref, uint mask) override;
|
||||
virtual void draw(InputAssembler *ia) override;
|
||||
virtual void updateBuffer(Buffer *buff, void *data, uint size, uint offset) override;
|
||||
virtual void copyBufferToTexture(Buffer *src, Texture *dst, TextureLayout layout, const BufferTextureCopyList ®ions) override;
|
||||
virtual void execute(const std::vector<CommandBuffer *> &cmd_buffs, uint32_t count) override;
|
||||
|
||||
private:
|
||||
void BindStates();
|
||||
@@ -49,11 +49,11 @@ private:
|
||||
GLES3GPUPipelineState *_curGPUPipelineState = nullptr;
|
||||
GLES3GPUBindingLayout *_curGPUBlendLayout = nullptr;
|
||||
GLES3GPUInputAssembler *_curGPUInputAssember = nullptr;
|
||||
GFXViewport _curViewport;
|
||||
GFXRect _curScissor;
|
||||
Viewport _curViewport;
|
||||
Rect _curScissor;
|
||||
float _curLineWidth = 1.0f;
|
||||
GLES3DepthBias _curDepthBias;
|
||||
GFXColor _curBlendConstants;
|
||||
Color _curBlendConstants;
|
||||
GLES3DepthBounds _curDepthBounds;
|
||||
GLES3StencilWriteMask _curStencilWriteMask;
|
||||
GLES3StencilCompareMask _curStencilCompareMask;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,12 +20,12 @@ struct GLES3DepthBounds {
|
||||
};
|
||||
|
||||
struct GLES3StencilWriteMask {
|
||||
GFXStencilFace face = GFXStencilFace::FRONT;
|
||||
StencilFace face = StencilFace::FRONT;
|
||||
uint write_mask = 0;
|
||||
};
|
||||
|
||||
struct GLES3StencilCompareMask {
|
||||
GFXStencilFace face = GFXStencilFace::FRONT;
|
||||
StencilFace face = StencilFace::FRONT;
|
||||
int refrence = 0;
|
||||
uint compare_mask = 0;
|
||||
};
|
||||
@@ -49,10 +49,10 @@ struct GLES3BufferTextureCopy {
|
||||
class GLES3CmdBeginRenderPass : public GFXCmd {
|
||||
public:
|
||||
GLES3GPUFramebuffer *gpuFBO = nullptr;
|
||||
GFXRect render_area;
|
||||
GFXClearFlags clear_flags = GFXClearFlagBit::NONE;
|
||||
Rect render_area;
|
||||
ClearFlags clear_flags = ClearFlagBit::NONE;
|
||||
uint num_clear_colors = 0;
|
||||
GFXColor clear_colors[GFX_MAX_ATTACHMENTS];
|
||||
Color clear_colors[GFX_MAX_ATTACHMENTS];
|
||||
float clear_depth = 1.0f;
|
||||
int clear_stencil = 0;
|
||||
|
||||
@@ -82,12 +82,12 @@ public:
|
||||
GLES3GPUBindingLayout *gpuBindingLayout = nullptr;
|
||||
GLES3GPUInputAssembler *gpuInputAssembler = nullptr;
|
||||
uint8_t state_flags[(int)GLES3State::COUNT] = {0};
|
||||
GFXViewport viewport;
|
||||
GFXRect scissor;
|
||||
Viewport viewport;
|
||||
Rect scissor;
|
||||
float lineWidth = 1.0f;
|
||||
bool depthBiasEnabled = false;
|
||||
GLES3DepthBias depthBias;
|
||||
GFXColor blendConstants;
|
||||
Color blendConstants;
|
||||
GLES3DepthBounds depthBounds;
|
||||
GLES3StencilWriteMask stencilWriteMask;
|
||||
GLES3StencilCompareMask stencilCompareMask;
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
|
||||
class GLES3CmdDraw : public GFXCmd {
|
||||
public:
|
||||
GFXDrawInfo draw_info;
|
||||
DrawInfo draw_info;
|
||||
|
||||
GLES3CmdDraw() : GFXCmd(GFXCmdType::DRAW) {}
|
||||
virtual void clear() override {}
|
||||
@@ -129,8 +129,8 @@ class GLES3CmdCopyBufferToTexture : public GFXCmd {
|
||||
public:
|
||||
GLES3GPUBuffer *gpuBuffer = nullptr;
|
||||
GLES3GPUTexture *gpuTexture = nullptr;
|
||||
GFXTextureLayout dst_layout;
|
||||
GFXBufferTextureCopyList regions;
|
||||
TextureLayout dst_layout;
|
||||
BufferTextureCopyList regions;
|
||||
|
||||
GLES3CmdCopyBufferToTexture() : GFXCmd(GFXCmdType::COPY_BUFFER_TO_TEXTURE) {}
|
||||
|
||||
@@ -167,7 +167,7 @@ CC_GLES3_API void GLES3CmdFuncDestroyInputAssembler(GLES3Device *device, GLES3GP
|
||||
CC_GLES3_API void GLES3CmdFuncCreateFramebuffer(GLES3Device *device, GLES3GPUFramebuffer *gpuFBO);
|
||||
CC_GLES3_API void GLES3CmdFuncDestroyFramebuffer(GLES3Device *device, GLES3GPUFramebuffer *gpuFBO);
|
||||
CC_GLES3_API void GLES3CmdFuncExecuteCmds(GLES3Device *device, GLES3CmdPackage *cmd_package);
|
||||
CC_GLES3_API void GLES3CmdFuncCopyBuffersToTexture(GLES3Device *device, uint8_t *const *buffers, GLES3GPUTexture *gpuTexture, const GFXBufferTextureCopyList ®ions);
|
||||
CC_GLES3_API void GLES3CmdFuncCopyBuffersToTexture(GLES3Device *device, uint8_t *const *buffers, GLES3GPUTexture *gpuTexture, const BufferTextureCopyList ®ions);
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace cc
|
||||
|
||||
@@ -64,8 +64,8 @@ void APIENTRY GLES3EGLDebugProc(GLenum source, GLenum type, GLuint id, GLenum se
|
||||
|
||||
#endif
|
||||
|
||||
GLES3Context::GLES3Context(GFXDevice *device)
|
||||
: GFXContext(device) {
|
||||
GLES3Context::GLES3Context(Device *device)
|
||||
: Context(device) {
|
||||
}
|
||||
|
||||
GLES3Context::~GLES3Context() {
|
||||
@@ -73,7 +73,7 @@ GLES3Context::~GLES3Context() {
|
||||
|
||||
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS || CC_PLATFORM == CC_PLATFORM_ANDROID || CC_PLATFORM == CC_PLATFORM_MAC_OSX)
|
||||
|
||||
bool GLES3Context::initialize(const GFXContextInfo &info) {
|
||||
bool GLES3Context::initialize(const ContextInfo &info) {
|
||||
|
||||
_vsyncMode = info.vsyncMode;
|
||||
_windowHandle = info.windowHandle;
|
||||
@@ -119,8 +119,8 @@ bool GLES3Context::initialize(const GFXContextInfo &info) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_colorFmt = GFXFormat::RGBA8;
|
||||
_depthStencilFmt = GFXFormat::D24S8;
|
||||
_colorFmt = Format::RGBA8;
|
||||
_depthStencilFmt = Format::D24S8;
|
||||
|
||||
const EGLint attribs[] = {
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
|
||||
@@ -154,17 +154,17 @@ bool GLES3Context::initialize(const GFXContextInfo &info) {
|
||||
CC_LOG_INFO("Setup EGLConfig: depth [%d] stencil [%d]", depth, stencil);
|
||||
|
||||
if (depth == 16 && stencil == 0) {
|
||||
_depthStencilFmt = GFXFormat::D16;
|
||||
_depthStencilFmt = Format::D16;
|
||||
} else if (depth == 16 && stencil == 8) {
|
||||
_depthStencilFmt = GFXFormat::D16S8;
|
||||
_depthStencilFmt = Format::D16S8;
|
||||
} else if (depth == 24 && stencil == 0) {
|
||||
_depthStencilFmt = GFXFormat::D24;
|
||||
_depthStencilFmt = Format::D24;
|
||||
} else if (depth == 24 && stencil == 8) {
|
||||
_depthStencilFmt = GFXFormat::D24S8;
|
||||
_depthStencilFmt = Format::D24S8;
|
||||
} else if (depth == 32 && stencil == 0) {
|
||||
_depthStencilFmt = GFXFormat::D32F;
|
||||
_depthStencilFmt = Format::D32F;
|
||||
} else if (depth == 32 && stencil == 8) {
|
||||
_depthStencilFmt = GFXFormat::D32F_S8;
|
||||
_depthStencilFmt = Format::D32F_S8;
|
||||
} else {
|
||||
CC_LOG_ERROR("Unknown depth stencil format.");
|
||||
return false;
|
||||
@@ -363,7 +363,7 @@ void GLES3Context::destroy() {
|
||||
_isPrimaryContex = false;
|
||||
_windowHandle = 0;
|
||||
_nativeDisplay = 0;
|
||||
_vsyncMode = GFXVsyncMode::OFF;
|
||||
_vsyncMode = VsyncMode::OFF;
|
||||
_isInitialized = false;
|
||||
}
|
||||
|
||||
@@ -384,11 +384,11 @@ bool GLES3Context::MakeCurrent() {
|
||||
// Turn on or off the vertical sync depending on the input bool value.
|
||||
int interval = 1;
|
||||
switch (_vsyncMode) {
|
||||
case GFXVsyncMode::OFF: interval = 0; break;
|
||||
case GFXVsyncMode::ON: interval = 1; break;
|
||||
case GFXVsyncMode::RELAXED: interval = -1; break;
|
||||
case GFXVsyncMode::MAILBOX: interval = 0; break;
|
||||
case GFXVsyncMode::HALF: interval = 2; break;
|
||||
case VsyncMode::OFF: interval = 0; break;
|
||||
case VsyncMode::ON: interval = 1; break;
|
||||
case VsyncMode::RELAXED: interval = -1; break;
|
||||
case VsyncMode::MAILBOX: interval = 0; break;
|
||||
case VsyncMode::HALF: interval = 2; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,13 +31,13 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
class CC_GLES3_API GLES3Context : public GFXContext {
|
||||
class CC_GLES3_API GLES3Context : public Context {
|
||||
public:
|
||||
GLES3Context(GFXDevice *device);
|
||||
GLES3Context(Device *device);
|
||||
~GLES3Context();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXContextInfo &info) override;
|
||||
virtual bool initialize(const ContextInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
virtual void present() override;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
bool GLES3Context::initialize(const GFXContextInfo &info)
|
||||
bool GLES3Context::initialize(const ContextInfo &info)
|
||||
{
|
||||
|
||||
_vsyncMode = info.vsyncMode;
|
||||
@@ -55,8 +55,8 @@ bool GLES3Context::initialize(const GFXContextInfo &info)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_colorFmt = GFXFormat::RGBA8;
|
||||
_depthStencilFmt = GFXFormat::D24S8;
|
||||
_colorFmt = Format::RGBA8;
|
||||
_depthStencilFmt = Format::D24S8;
|
||||
|
||||
if (!MakeCurrent())
|
||||
return false;
|
||||
@@ -176,7 +176,7 @@ void GLES3Context::destroy()
|
||||
|
||||
_isPrimaryContex = false;
|
||||
_windowHandle = 0;
|
||||
_vsyncMode = GFXVsyncMode::OFF;
|
||||
_vsyncMode = VsyncMode::OFF;
|
||||
_isInitialized = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ GLES3Device::GLES3Device() {
|
||||
GLES3Device::~GLES3Device() {
|
||||
}
|
||||
|
||||
bool GLES3Device::initialize(const GFXDeviceInfo &info) {
|
||||
_gfxAPI = GFXAPI::GLES3;
|
||||
bool GLES3Device::initialize(const DeviceInfo &info) {
|
||||
_API = API::GLES3;
|
||||
_deviceName = "GLES3";
|
||||
_width = info.width;
|
||||
_height = info.height;
|
||||
@@ -38,7 +38,7 @@ bool GLES3Device::initialize(const GFXDeviceInfo &info) {
|
||||
|
||||
stateCache = CC_NEW(GLES3StateCache);
|
||||
|
||||
GFXContextInfo ctx_info;
|
||||
ContextInfo ctx_info;
|
||||
ctx_info.windowHandle = _windowHandle;
|
||||
ctx_info.sharedCtx = info.sharedCtx;
|
||||
|
||||
@@ -51,54 +51,54 @@ bool GLES3Device::initialize(const GFXDeviceInfo &info) {
|
||||
String extStr = (const char *)glGetString(GL_EXTENSIONS);
|
||||
_extensions = StringUtil::Split(extStr, " ");
|
||||
|
||||
_features[(int)GFXFeature::TEXTURE_FLOAT] = true;
|
||||
_features[(int)GFXFeature::TEXTURE_HALF_FLOAT] = true;
|
||||
_features[(int)GFXFeature::FORMAT_R11G11B10F] = true;
|
||||
_features[(int)GFXFeature::FORMAT_D24S8] = true;
|
||||
_features[(int)GFXFeature::MSAA] = true;
|
||||
_features[(int)GFXFeature::INSTANCED_ARRAYS] = true;
|
||||
_features[(int)Feature::TEXTURE_FLOAT] = true;
|
||||
_features[(int)Feature::TEXTURE_HALF_FLOAT] = true;
|
||||
_features[(int)Feature::FORMAT_R11G11B10F] = true;
|
||||
_features[(int)Feature::FORMAT_D24S8] = true;
|
||||
_features[(int)Feature::MSAA] = true;
|
||||
_features[(int)Feature::INSTANCED_ARRAYS] = true;
|
||||
|
||||
if (checkExtension("color_buffer_float"))
|
||||
_features[(int)GFXFeature::COLOR_FLOAT] = true;
|
||||
_features[(int)Feature::COLOR_FLOAT] = true;
|
||||
|
||||
if (checkExtension("color_buffer_half_float"))
|
||||
_features[(int)GFXFeature::COLOR_HALF_FLOAT] = true;
|
||||
_features[(int)Feature::COLOR_HALF_FLOAT] = true;
|
||||
|
||||
if (checkExtension("texture_float_linear"))
|
||||
_features[(int)GFXFeature::TEXTURE_FLOAT_LINEAR] = true;
|
||||
_features[(int)Feature::TEXTURE_FLOAT_LINEAR] = true;
|
||||
|
||||
if (checkExtension("texture_half_float_linear"))
|
||||
_features[(int)GFXFeature::TEXTURE_HALF_FLOAT_LINEAR] = true;
|
||||
_features[(int)Feature::TEXTURE_HALF_FLOAT_LINEAR] = true;
|
||||
|
||||
String compressed_fmts;
|
||||
|
||||
if (checkExtension("compressed_ETC1")) {
|
||||
_features[(int)GFXFeature::FORMAT_ETC1] = true;
|
||||
_features[(int)Feature::FORMAT_ETC1] = true;
|
||||
compressed_fmts += "etc1 ";
|
||||
}
|
||||
|
||||
_features[(int)GFXFeature::FORMAT_ETC2] = true;
|
||||
_features[(int)Feature::FORMAT_ETC2] = true;
|
||||
compressed_fmts += "etc2 ";
|
||||
|
||||
if (checkExtension("texture_compression_pvrtc")) {
|
||||
_features[(int)GFXFeature::FORMAT_PVRTC] = true;
|
||||
_features[(int)Feature::FORMAT_PVRTC] = true;
|
||||
compressed_fmts += "pvrtc ";
|
||||
}
|
||||
|
||||
if (checkExtension("texture_compression_astc")) {
|
||||
_features[(int)GFXFeature::FORMAT_ASTC] = true;
|
||||
_features[(int)Feature::FORMAT_ASTC] = true;
|
||||
compressed_fmts += "astc ";
|
||||
}
|
||||
_features[static_cast<uint>(GFXFeature::DEPTH_BOUNDS)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::LINE_WIDTH)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::STENCIL_COMPARE_MASK)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::STENCIL_WRITE_MASK)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::FORMAT_RGB8)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::FORMAT_D16)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::FORMAT_D24)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::FORMAT_D32F)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::FORMAT_D24S8)] = true;
|
||||
_features[static_cast<uint>(GFXFeature::FORMAT_D32FS8)] = true;
|
||||
_features[static_cast<uint>(Feature::DEPTH_BOUNDS)] = true;
|
||||
_features[static_cast<uint>(Feature::LINE_WIDTH)] = true;
|
||||
_features[static_cast<uint>(Feature::STENCIL_COMPARE_MASK)] = true;
|
||||
_features[static_cast<uint>(Feature::STENCIL_WRITE_MASK)] = true;
|
||||
_features[static_cast<uint>(Feature::FORMAT_RGB8)] = true;
|
||||
_features[static_cast<uint>(Feature::FORMAT_D16)] = true;
|
||||
_features[static_cast<uint>(Feature::FORMAT_D24)] = true;
|
||||
_features[static_cast<uint>(Feature::FORMAT_D32F)] = true;
|
||||
_features[static_cast<uint>(Feature::FORMAT_D24S8)] = true;
|
||||
_features[static_cast<uint>(Feature::FORMAT_D32FS8)] = true;
|
||||
|
||||
_renderer = (const char *)glGetString(GL_RENDERER);
|
||||
_vendor = (const char *)glGetString(GL_VENDOR);
|
||||
@@ -113,11 +113,11 @@ bool GLES3Device::initialize(const GFXDeviceInfo &info) {
|
||||
CC_LOG_INFO("USE_VAO: %s", _useVAO ? "true" : "false");
|
||||
CC_LOG_INFO("COMPRESSED_FORMATS: %s", compressed_fmts.c_str());
|
||||
|
||||
GFXQueueInfo queue_info;
|
||||
queue_info.type = GFXQueueType::GRAPHICS;
|
||||
QueueInfo queue_info;
|
||||
queue_info.type = QueueType::GRAPHICS;
|
||||
_queue = createQueue(queue_info);
|
||||
|
||||
GFXCommandAllocatorInfo cmd_alloc_info;
|
||||
CommandAllocatorInfo cmd_alloc_info;
|
||||
_cmdAllocator = createCommandAllocator(cmd_alloc_info);
|
||||
|
||||
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, (GLint *)&_maxVertexAttributes);
|
||||
@@ -162,8 +162,8 @@ void GLES3Device::present() {
|
||||
queue->_numTriangles = 0;
|
||||
}
|
||||
|
||||
GFXFence *GLES3Device::createFence(const GFXFenceInfo &info) {
|
||||
GFXFence *fence = CC_NEW(GLES3Fence(this));
|
||||
Fence *GLES3Device::createFence(const FenceInfo &info) {
|
||||
Fence *fence = CC_NEW(GLES3Fence(this));
|
||||
if (fence->initialize(info))
|
||||
return fence;
|
||||
|
||||
@@ -171,8 +171,8 @@ GFXFence *GLES3Device::createFence(const GFXFenceInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXQueue *GLES3Device::createQueue(const GFXQueueInfo &info) {
|
||||
GFXQueue *queue = CC_NEW(GLES3Queue(this));
|
||||
Queue *GLES3Device::createQueue(const QueueInfo &info) {
|
||||
Queue *queue = CC_NEW(GLES3Queue(this));
|
||||
if (queue->initialize(info))
|
||||
return queue;
|
||||
|
||||
@@ -180,8 +180,8 @@ GFXQueue *GLES3Device::createQueue(const GFXQueueInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXCommandAllocator *GLES3Device::createCommandAllocator(const GFXCommandAllocatorInfo &info) {
|
||||
GFXCommandAllocator *cmdAllocator = CC_NEW(GLES3CommandAllocator(this));
|
||||
CommandAllocator *GLES3Device::createCommandAllocator(const CommandAllocatorInfo &info) {
|
||||
CommandAllocator *cmdAllocator = CC_NEW(GLES3CommandAllocator(this));
|
||||
if (cmdAllocator->initialize(info))
|
||||
return cmdAllocator;
|
||||
|
||||
@@ -189,8 +189,8 @@ GFXCommandAllocator *GLES3Device::createCommandAllocator(const GFXCommandAllocat
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXCommandBuffer *GLES3Device::createCommandBuffer(const GFXCommandBufferInfo &info) {
|
||||
GFXCommandBuffer *cmd_buff = CC_NEW(GLES3CommandBuffer(this));
|
||||
CommandBuffer *GLES3Device::createCommandBuffer(const CommandBufferInfo &info) {
|
||||
CommandBuffer *cmd_buff = CC_NEW(GLES3CommandBuffer(this));
|
||||
if (cmd_buff->initialize(info))
|
||||
return cmd_buff;
|
||||
|
||||
@@ -198,8 +198,8 @@ GFXCommandBuffer *GLES3Device::createCommandBuffer(const GFXCommandBufferInfo &i
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXBuffer *GLES3Device::createBuffer(const GFXBufferInfo &info) {
|
||||
GFXBuffer *buffer = CC_NEW(GLES3Buffer(this));
|
||||
Buffer *GLES3Device::createBuffer(const BufferInfo &info) {
|
||||
Buffer *buffer = CC_NEW(GLES3Buffer(this));
|
||||
if (buffer->initialize(info))
|
||||
return buffer;
|
||||
|
||||
@@ -207,8 +207,8 @@ GFXBuffer *GLES3Device::createBuffer(const GFXBufferInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXTexture *GLES3Device::createTexture(const GFXTextureInfo &info) {
|
||||
GFXTexture *texture = CC_NEW(GLES3Texture(this));
|
||||
Texture *GLES3Device::createTexture(const TextureInfo &info) {
|
||||
Texture *texture = CC_NEW(GLES3Texture(this));
|
||||
if (texture->initialize(info))
|
||||
return texture;
|
||||
|
||||
@@ -216,8 +216,8 @@ GFXTexture *GLES3Device::createTexture(const GFXTextureInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXTexture *GLES3Device::createTexture(const GFXTextureViewInfo &info) {
|
||||
GFXTexture *texture = CC_NEW(GLES3Texture(this));
|
||||
Texture *GLES3Device::createTexture(const TextureViewInfo &info) {
|
||||
Texture *texture = CC_NEW(GLES3Texture(this));
|
||||
if (texture->initialize(info))
|
||||
return texture;
|
||||
|
||||
@@ -225,8 +225,8 @@ GFXTexture *GLES3Device::createTexture(const GFXTextureViewInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXSampler *GLES3Device::createSampler(const GFXSamplerInfo &info) {
|
||||
GFXSampler *sampler = CC_NEW(GLES3Sampler(this));
|
||||
Sampler *GLES3Device::createSampler(const SamplerInfo &info) {
|
||||
Sampler *sampler = CC_NEW(GLES3Sampler(this));
|
||||
if (sampler->initialize(info))
|
||||
return sampler;
|
||||
|
||||
@@ -234,8 +234,8 @@ GFXSampler *GLES3Device::createSampler(const GFXSamplerInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXShader *GLES3Device::createShader(const GFXShaderInfo &info) {
|
||||
GFXShader *shader = CC_NEW(GLES3Shader(this));
|
||||
Shader *GLES3Device::createShader(const ShaderInfo &info) {
|
||||
Shader *shader = CC_NEW(GLES3Shader(this));
|
||||
if (shader->initialize(info))
|
||||
return shader;
|
||||
|
||||
@@ -243,8 +243,8 @@ GFXShader *GLES3Device::createShader(const GFXShaderInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXInputAssembler *GLES3Device::createInputAssembler(const GFXInputAssemblerInfo &info) {
|
||||
GFXInputAssembler *inputAssembler = CC_NEW(GLES3InputAssembler(this));
|
||||
InputAssembler *GLES3Device::createInputAssembler(const InputAssemblerInfo &info) {
|
||||
InputAssembler *inputAssembler = CC_NEW(GLES3InputAssembler(this));
|
||||
if (inputAssembler->initialize(info))
|
||||
return inputAssembler;
|
||||
|
||||
@@ -252,8 +252,8 @@ GFXInputAssembler *GLES3Device::createInputAssembler(const GFXInputAssemblerInfo
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXRenderPass *GLES3Device::createRenderPass(const GFXRenderPassInfo &info) {
|
||||
GFXRenderPass *renderPass = CC_NEW(GLES3RenderPass(this));
|
||||
RenderPass *GLES3Device::createRenderPass(const RenderPassInfo &info) {
|
||||
RenderPass *renderPass = CC_NEW(GLES3RenderPass(this));
|
||||
if (renderPass->initialize(info))
|
||||
return renderPass;
|
||||
|
||||
@@ -261,8 +261,8 @@ GFXRenderPass *GLES3Device::createRenderPass(const GFXRenderPassInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXFramebuffer *GLES3Device::createFramebuffer(const GFXFramebufferInfo &info) {
|
||||
GFXFramebuffer *framebuffer = CC_NEW(GLES3Framebuffer(this));
|
||||
Framebuffer *GLES3Device::createFramebuffer(const FramebufferInfo &info) {
|
||||
Framebuffer *framebuffer = CC_NEW(GLES3Framebuffer(this));
|
||||
if (framebuffer->initialize(info))
|
||||
return framebuffer;
|
||||
|
||||
@@ -270,8 +270,8 @@ GFXFramebuffer *GLES3Device::createFramebuffer(const GFXFramebufferInfo &info) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXBindingLayout *GLES3Device::createBindingLayout(const GFXBindingLayoutInfo &info) {
|
||||
GFXBindingLayout *bindingLayout = CC_NEW(GLES3BindingLayout(this));
|
||||
BindingLayout *GLES3Device::createBindingLayout(const BindingLayoutInfo &info) {
|
||||
BindingLayout *bindingLayout = CC_NEW(GLES3BindingLayout(this));
|
||||
if (bindingLayout->initialize(info))
|
||||
return bindingLayout;
|
||||
|
||||
@@ -279,8 +279,8 @@ GFXBindingLayout *GLES3Device::createBindingLayout(const GFXBindingLayoutInfo &i
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXPipelineState *GLES3Device::createPipelineState(const GFXPipelineStateInfo &info) {
|
||||
GFXPipelineState *pipelineState = CC_NEW(GLES3PipelineState(this));
|
||||
PipelineState *GLES3Device::createPipelineState(const PipelineStateInfo &info) {
|
||||
PipelineState *pipelineState = CC_NEW(GLES3PipelineState(this));
|
||||
if (pipelineState->initialize(info))
|
||||
return pipelineState;
|
||||
|
||||
@@ -288,8 +288,8 @@ GFXPipelineState *GLES3Device::createPipelineState(const GFXPipelineStateInfo &i
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GFXPipelineLayout *GLES3Device::createPipelineLayout(const GFXPipelineLayoutInfo &info) {
|
||||
GFXPipelineLayout *layout = CC_NEW(GLES3PipelineLayout(this));
|
||||
PipelineLayout *GLES3Device::createPipelineLayout(const PipelineLayoutInfo &info) {
|
||||
PipelineLayout *layout = CC_NEW(GLES3PipelineLayout(this));
|
||||
if (layout->initialize(info))
|
||||
return layout;
|
||||
|
||||
@@ -297,7 +297,7 @@ GFXPipelineLayout *GLES3Device::createPipelineLayout(const GFXPipelineLayoutInfo
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GLES3Device::copyBuffersToTexture(const GFXDataArray &buffers, GFXTexture *dst, const GFXBufferTextureCopyList ®ions) {
|
||||
void GLES3Device::copyBuffersToTexture(const DataArray &buffers, Texture *dst, const BufferTextureCopyList ®ions) {
|
||||
|
||||
GLES3CmdFuncCopyBuffersToTexture(this, buffers.datas.data(), ((GLES3Texture *)dst)->gpuTexture(), regions);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace gfx {
|
||||
|
||||
class GLES3StateCache;
|
||||
|
||||
class CC_GLES3_API GLES3Device : public GFXDevice {
|
||||
class CC_GLES3_API GLES3Device : public Device {
|
||||
public:
|
||||
GLES3Device();
|
||||
~GLES3Device();
|
||||
@@ -14,27 +14,27 @@ public:
|
||||
GLES3StateCache *stateCache = nullptr;
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXDeviceInfo &info) override;
|
||||
virtual bool initialize(const DeviceInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
virtual void resize(uint width, uint height) override;
|
||||
virtual void acquire() override {}
|
||||
virtual void present() override;
|
||||
virtual GFXFence *createFence(const GFXFenceInfo &info) override;
|
||||
virtual GFXQueue *createQueue(const GFXQueueInfo &info) override;
|
||||
virtual GFXCommandAllocator *createCommandAllocator(const GFXCommandAllocatorInfo &info) override;
|
||||
virtual GFXCommandBuffer *createCommandBuffer(const GFXCommandBufferInfo &info) override;
|
||||
virtual GFXBuffer *createBuffer(const GFXBufferInfo &info) override;
|
||||
virtual GFXTexture *createTexture(const GFXTextureInfo &info) override;
|
||||
virtual GFXTexture *createTexture(const GFXTextureViewInfo &info) override;
|
||||
virtual GFXSampler *createSampler(const GFXSamplerInfo &info) override;
|
||||
virtual GFXShader *createShader(const GFXShaderInfo &info) override;
|
||||
virtual GFXInputAssembler *createInputAssembler(const GFXInputAssemblerInfo &info) override;
|
||||
virtual GFXRenderPass *createRenderPass(const GFXRenderPassInfo &info) override;
|
||||
virtual GFXFramebuffer *createFramebuffer(const GFXFramebufferInfo &info) override;
|
||||
virtual GFXBindingLayout *createBindingLayout(const GFXBindingLayoutInfo &info) override;
|
||||
virtual GFXPipelineState *createPipelineState(const GFXPipelineStateInfo &info) override;
|
||||
virtual GFXPipelineLayout *createPipelineLayout(const GFXPipelineLayoutInfo &info) override;
|
||||
virtual void copyBuffersToTexture(const GFXDataArray &buffers, GFXTexture *dst, const GFXBufferTextureCopyList ®ions) override;
|
||||
virtual Fence *createFence(const FenceInfo &info) override;
|
||||
virtual Queue *createQueue(const QueueInfo &info) override;
|
||||
virtual CommandAllocator *createCommandAllocator(const CommandAllocatorInfo &info) override;
|
||||
virtual CommandBuffer *createCommandBuffer(const CommandBufferInfo &info) override;
|
||||
virtual Buffer *createBuffer(const BufferInfo &info) override;
|
||||
virtual Texture *createTexture(const TextureInfo &info) override;
|
||||
virtual Texture *createTexture(const TextureViewInfo &info) override;
|
||||
virtual Sampler *createSampler(const SamplerInfo &info) override;
|
||||
virtual Shader *createShader(const ShaderInfo &info) override;
|
||||
virtual InputAssembler *createInputAssembler(const InputAssemblerInfo &info) override;
|
||||
virtual RenderPass *createRenderPass(const RenderPassInfo &info) override;
|
||||
virtual Framebuffer *createFramebuffer(const FramebufferInfo &info) override;
|
||||
virtual BindingLayout *createBindingLayout(const BindingLayoutInfo &info) override;
|
||||
virtual PipelineState *createPipelineState(const PipelineStateInfo &info) override;
|
||||
virtual PipelineLayout *createPipelineLayout(const PipelineLayoutInfo &info) override;
|
||||
virtual void copyBuffersToTexture(const DataArray &buffers, Texture *dst, const BufferTextureCopyList ®ions) override;
|
||||
|
||||
CC_INLINE bool useVAO() const { return _useVAO; }
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES3Fence::GLES3Fence(GFXDevice *device)
|
||||
: GFXFence(device) {
|
||||
GLES3Fence::GLES3Fence(Device *device)
|
||||
: Fence(device) {
|
||||
}
|
||||
|
||||
GLES3Fence::~GLES3Fence() {
|
||||
}
|
||||
|
||||
bool GLES3Fence::initialize(const GFXFenceInfo &info) {
|
||||
bool GLES3Fence::initialize(const FenceInfo &info) {
|
||||
_gpuFence = CC_NEW(GLES3GPUFence);
|
||||
if (!_gpuFence) {
|
||||
CC_LOG_ERROR("GLES2Fence: CC_NEW GLES3GPUFence failed.");
|
||||
@@ -22,7 +22,7 @@ bool GLES3Fence::initialize(const GFXFenceInfo &info) {
|
||||
|
||||
// TODO
|
||||
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ void GLES3Fence::destroy() {
|
||||
CC_DELETE(_gpuFence);
|
||||
_gpuFence = nullptr;
|
||||
}
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
void GLES3Fence::wait() {
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace gfx {
|
||||
|
||||
class GLES3GPUFence;
|
||||
|
||||
class CC_GLES3_API GLES3Fence : public GFXFence {
|
||||
class CC_GLES3_API GLES3Fence : public Fence {
|
||||
public:
|
||||
GLES3Fence(GFXDevice *device);
|
||||
GLES3Fence(Device *device);
|
||||
~GLES3Fence();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXFenceInfo &info) override;
|
||||
virtual bool initialize(const FenceInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
virtual void wait() override;
|
||||
virtual void reset() override;
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES3Framebuffer::GLES3Framebuffer(GFXDevice *device)
|
||||
: GFXFramebuffer(device) {
|
||||
GLES3Framebuffer::GLES3Framebuffer(Device *device)
|
||||
: Framebuffer(device) {
|
||||
}
|
||||
|
||||
GLES3Framebuffer::~GLES3Framebuffer() {
|
||||
}
|
||||
|
||||
bool GLES3Framebuffer::initialize(const GFXFramebufferInfo &info) {
|
||||
bool GLES3Framebuffer::initialize(const FramebufferInfo &info) {
|
||||
|
||||
_renderPass = info.renderPass;
|
||||
_colorTextures = info.colorTextures;
|
||||
@@ -48,7 +48,7 @@ bool GLES3Framebuffer::initialize(const GFXFramebufferInfo &info) {
|
||||
}
|
||||
#endif
|
||||
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ void GLES3Framebuffer::destroy() {
|
||||
CC_DELETE(_gpuFBO);
|
||||
_gpuFBO = nullptr;
|
||||
}
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace gfx {
|
||||
|
||||
class GLES3GPUFramebuffer;
|
||||
|
||||
class CC_GLES3_API GLES3Framebuffer : public GFXFramebuffer {
|
||||
class CC_GLES3_API GLES3Framebuffer : public Framebuffer {
|
||||
public:
|
||||
GLES3Framebuffer(GFXDevice *device);
|
||||
GLES3Framebuffer(Device *device);
|
||||
~GLES3Framebuffer();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXFramebufferInfo &info) override;
|
||||
virtual bool initialize(const FramebufferInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
|
||||
CC_INLINE GLES3GPUFramebuffer *gpuFBO() const { return _gpuFBO; }
|
||||
|
||||
@@ -8,31 +8,31 @@ namespace gfx {
|
||||
|
||||
class GLES3GPUBuffer : public Object {
|
||||
public:
|
||||
GFXBufferUsage usage = GFXBufferUsage::NONE;
|
||||
GFXMemoryUsage memUsage = GFXMemoryUsage::NONE;
|
||||
BufferUsage usage = BufferUsage::NONE;
|
||||
MemoryUsage memUsage = MemoryUsage::NONE;
|
||||
uint size = 0;
|
||||
uint stride = 0;
|
||||
uint count = 0;
|
||||
GLenum glTarget = 0;
|
||||
GLuint glBuffer = 0;
|
||||
uint8_t *buffer = nullptr;
|
||||
GFXDrawInfoList indirects;
|
||||
DrawInfoList indirects;
|
||||
};
|
||||
typedef vector<GLES3GPUBuffer *> GLES3GPUBufferList;
|
||||
|
||||
class GLES3GPUTexture : public Object {
|
||||
public:
|
||||
GFXTextureType type = GFXTextureType::TEX2D;
|
||||
GFXFormat format = GFXFormat::UNKNOWN;
|
||||
GFXTextureUsage usage = GFXTextureUsageBit::NONE;
|
||||
TextureType type = TextureType::TEX2D;
|
||||
Format format = Format::UNKNOWN;
|
||||
TextureUsage usage = TextureUsageBit::NONE;
|
||||
uint width = 0;
|
||||
uint height = 0;
|
||||
uint depth = 1;
|
||||
uint size = 0;
|
||||
uint arrayLayer = 1;
|
||||
uint mipLevel = 1;
|
||||
GFXSampleCount samples = GFXSampleCount::X1;
|
||||
GFXTextureFlags flags = GFXTextureFlagBit::NONE;
|
||||
SampleCount samples = SampleCount::X1;
|
||||
TextureFlags flags = TextureFlagBit::NONE;
|
||||
bool isPowerOf2 = false;
|
||||
GLenum glTarget = 0;
|
||||
GLenum glInternelFmt = 0;
|
||||
@@ -50,12 +50,12 @@ typedef vector<GLES3GPUTexture *> GLES3GPUTextureList;
|
||||
|
||||
class GLES3GPUSampler : public Object {
|
||||
public:
|
||||
GFXFilter minFilter = GFXFilter::NONE;
|
||||
GFXFilter magFilter = GFXFilter::NONE;
|
||||
GFXFilter mipFilter = GFXFilter::NONE;
|
||||
GFXAddress addressU = GFXAddress::CLAMP;
|
||||
GFXAddress addressV = GFXAddress::CLAMP;
|
||||
GFXAddress addressW = GFXAddress::CLAMP;
|
||||
Filter minFilter = Filter::NONE;
|
||||
Filter magFilter = Filter::NONE;
|
||||
Filter mipFilter = Filter::NONE;
|
||||
Address addressU = Address::CLAMP;
|
||||
Address addressV = Address::CLAMP;
|
||||
Address addressW = Address::CLAMP;
|
||||
uint minLOD = 0;
|
||||
uint maxLOD = 1000;
|
||||
GLuint gl_sampler = 0;
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
struct GLES3GPUInput {
|
||||
uint binding = 0;
|
||||
String name;
|
||||
GFXType type = GFXType::UNKNOWN;
|
||||
Type type = Type::UNKNOWN;
|
||||
uint stride = 0;
|
||||
uint count = 0;
|
||||
uint size = 0;
|
||||
@@ -81,7 +81,7 @@ typedef vector<GLES3GPUInput> GLES3GPUInputList;
|
||||
struct GLES3GPUUniform {
|
||||
uint binding = GFX_INVALID_BINDING;
|
||||
String name;
|
||||
GFXType type = GFXType::UNKNOWN;
|
||||
Type type = Type::UNKNOWN;
|
||||
uint stride = 0;
|
||||
uint count = 0;
|
||||
uint size = 0;
|
||||
@@ -104,7 +104,7 @@ typedef vector<GLES3GPUUniformBlock> GLES3GPUUniformBlockList;
|
||||
struct GLES3GPUUniformSampler {
|
||||
uint binding = 0;
|
||||
String name;
|
||||
GFXType type = GFXType::UNKNOWN;
|
||||
Type type = Type::UNKNOWN;
|
||||
vector<int> units;
|
||||
GLenum glType = 0;
|
||||
GLint glLoc = -1;
|
||||
@@ -112,11 +112,11 @@ struct GLES3GPUUniformSampler {
|
||||
typedef vector<GLES3GPUUniformSampler> GLES3GPUUniformSamplerList;
|
||||
|
||||
struct GLES3GPUShaderStage {
|
||||
GLES3GPUShaderStage(GFXShaderType t, String s, GFXShaderMacroList m, GLuint shader = 0)
|
||||
GLES3GPUShaderStage(ShaderType t, String s, ShaderMacroList m, GLuint shader = 0)
|
||||
: type(t), source(s), macros(m), glShader(shader) {}
|
||||
GFXShaderType type;
|
||||
ShaderType type;
|
||||
String source;
|
||||
GFXShaderMacroList macros;
|
||||
ShaderMacroList macros;
|
||||
GLuint glShader = 0;
|
||||
};
|
||||
typedef vector<GLES3GPUShaderStage> GLES3GPUShaderStageList;
|
||||
@@ -124,8 +124,8 @@ typedef vector<GLES3GPUShaderStage> GLES3GPUShaderStageList;
|
||||
class GLES3GPUShader : public Object {
|
||||
public:
|
||||
String name;
|
||||
GFXUniformBlockList blocks;
|
||||
GFXUniformSamplerList samplers;
|
||||
UniformBlockList blocks;
|
||||
UniformSamplerList samplers;
|
||||
GLuint glProgram = 0;
|
||||
GLES3GPUShaderStageList gpuStages;
|
||||
GLES3GPUInputList glInputs;
|
||||
@@ -149,7 +149,7 @@ typedef vector<GLES3GPUAttribute> GLES3GPUAttributeList;
|
||||
|
||||
class GLES3GPUInputAssembler : public Object {
|
||||
public:
|
||||
GFXAttributeList attributes;
|
||||
AttributeList attributes;
|
||||
GLES3GPUBufferList gpuVertexBuffers;
|
||||
GLES3GPUBuffer *gpuIndexBuffer = nullptr;
|
||||
GLES3GPUBuffer *gpuIndirectBuffer = nullptr;
|
||||
@@ -160,8 +160,8 @@ public:
|
||||
|
||||
class GLES3GPURenderPass : public Object {
|
||||
public:
|
||||
GFXColorAttachmentList colorAttachments;
|
||||
GFXDepthStencilAttachment depthStencilAttachment;
|
||||
ColorAttachmentList colorAttachments;
|
||||
DepthStencilAttachment depthStencilAttachment;
|
||||
};
|
||||
|
||||
class GLES3GPUFramebuffer : public Object {
|
||||
@@ -183,17 +183,17 @@ class GLES3GPUPipelineState : public Object {
|
||||
public:
|
||||
GLenum glPrimitive = GL_TRIANGLES;
|
||||
GLES3GPUShader *gpuShader = nullptr;
|
||||
GFXRasterizerState rs;
|
||||
GFXDepthStencilState dss;
|
||||
GFXBlendState bs;
|
||||
GFXDynamicStateList dynamicStates;
|
||||
RasterizerState rs;
|
||||
DepthStencilState dss;
|
||||
BlendState bs;
|
||||
DynamicStateList dynamicStates;
|
||||
GLES3GPUPipelineLayout *gpuLayout = nullptr;
|
||||
GLES3GPURenderPass *gpuRenderPass = nullptr;
|
||||
};
|
||||
|
||||
struct GLES3GPUBinding {
|
||||
uint binding = GFX_INVALID_BINDING;
|
||||
GFXBindingType type = GFXBindingType::UNKNOWN;
|
||||
BindingType type = BindingType::UNKNOWN;
|
||||
String name;
|
||||
GLES3GPUBuffer *gpuBuffer = nullptr;
|
||||
GLES3GPUTexture *gpuTexture = nullptr;
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES3InputAssembler::GLES3InputAssembler(GFXDevice *device)
|
||||
: GFXInputAssembler(device) {
|
||||
GLES3InputAssembler::GLES3InputAssembler(Device *device)
|
||||
: InputAssembler(device) {
|
||||
}
|
||||
|
||||
GLES3InputAssembler::~GLES3InputAssembler() {
|
||||
}
|
||||
|
||||
bool GLES3InputAssembler::initialize(const GFXInputAssemblerInfo &info) {
|
||||
bool GLES3InputAssembler::initialize(const InputAssemblerInfo &info) {
|
||||
|
||||
_attributes = info.attributes;
|
||||
_vertexBuffers = info.vertexBuffers;
|
||||
@@ -41,7 +41,7 @@ bool GLES3InputAssembler::initialize(const GFXInputAssemblerInfo &info) {
|
||||
|
||||
GLES3CmdFuncCreateInputAssembler((GLES3Device *)_device, _gpuInputAssembler);
|
||||
_attributesHash = computeAttributesHash();
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ void GLES3InputAssembler::destroy() {
|
||||
CC_DELETE(_gpuInputAssembler);
|
||||
_gpuInputAssembler = nullptr;
|
||||
}
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
void GLES3InputAssembler::ExtractCmdDraw(GLES3CmdDraw *cmd) {
|
||||
|
||||
@@ -7,13 +7,13 @@ namespace gfx {
|
||||
class GLES3GPUInputAssembler;
|
||||
class GLES3CmdDraw;
|
||||
|
||||
class CC_GLES3_API GLES3InputAssembler : public GFXInputAssembler {
|
||||
class CC_GLES3_API GLES3InputAssembler : public InputAssembler {
|
||||
public:
|
||||
GLES3InputAssembler(GFXDevice *device);
|
||||
GLES3InputAssembler(Device *device);
|
||||
~GLES3InputAssembler();
|
||||
|
||||
public:
|
||||
virtual bool initialize(const GFXInputAssemblerInfo &info) override;
|
||||
virtual bool initialize(const InputAssemblerInfo &info) override;
|
||||
virtual void destroy() override;
|
||||
|
||||
void ExtractCmdDraw(GLES3CmdDraw *cmd);
|
||||
|
||||
@@ -5,20 +5,20 @@
|
||||
namespace cc {
|
||||
namespace gfx {
|
||||
|
||||
GLES3PipelineLayout::GLES3PipelineLayout(GFXDevice *device)
|
||||
: GFXPipelineLayout(device) {
|
||||
GLES3PipelineLayout::GLES3PipelineLayout(Device *device)
|
||||
: PipelineLayout(device) {
|
||||
}
|
||||
|
||||
GLES3PipelineLayout::~GLES3PipelineLayout() {
|
||||
}
|
||||
|
||||
bool GLES3PipelineLayout::initialize(const GFXPipelineLayoutInfo &info) {
|
||||
bool GLES3PipelineLayout::initialize(const PipelineLayoutInfo &info) {
|
||||
|
||||
_layouts = info.layouts;
|
||||
_pushConstantsRanges = info.pushConstantsRanges;
|
||||
|
||||
_gpuPipelineLayout = CC_NEW(GLES3GPUPipelineLayout);
|
||||
_status = GFXStatus::SUCCESS;
|
||||
_status = Status::SUCCESS;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ void GLES3PipelineLayout::destroy() {
|
||||
CC_DELETE(_gpuPipelineLayout);
|
||||
_gpuPipelineLayout = nullptr;
|
||||
}
|
||||
_status = GFXStatus::UNREADY;
|
||||
_status = Status::UNREADY;
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user