Merge branch 'master' of cane:bkaradzic/bgfx
This commit is contained in:
commit
cf93acf0bf
@ -1673,11 +1673,13 @@ namespace bgfx
|
||||
/// @param[in] _handle Texture handle.
|
||||
/// @param[in] _data Destination buffer.
|
||||
///
|
||||
/// @returns Frame number when the result will be available. See: `bgfx::frame`.
|
||||
///
|
||||
/// @attention Texture must be created with `BGFX_TEXTURE_READ_BACK` flag.
|
||||
/// @attention Availability depends on: `BGFX_CAPS_TEXTURE_READ_BACK`.
|
||||
/// @attention C99 equivalent is `bgfx_read_texture`.
|
||||
///
|
||||
void readTexture(TextureHandle _handle, void* _data);
|
||||
uint32_t readTexture(TextureHandle _handle, void* _data);
|
||||
|
||||
/// Read back texture content.
|
||||
///
|
||||
@ -1685,11 +1687,13 @@ namespace bgfx
|
||||
/// @param[in] _attachment Frame buffer attachment index.
|
||||
/// @param[in] _data Destination buffer.
|
||||
///
|
||||
/// @returns Frame number when the result will be available. See: `bgfx::frame`.
|
||||
///
|
||||
/// @attention Texture must be created with `BGFX_TEXTURE_READ_BACK` flag.
|
||||
/// @attention Availability depends on: `BGFX_CAPS_TEXTURE_READ_BACK`.
|
||||
/// @attention C99 equivalent is `bgfx_read_frame_buffer`.
|
||||
///
|
||||
void readTexture(FrameBufferHandle _handle, uint8_t _attachment, void* _data);
|
||||
uint32_t readTexture(FrameBufferHandle _handle, uint8_t _attachment, void* _data);
|
||||
|
||||
/// Destroy texture.
|
||||
///
|
||||
@ -1711,6 +1715,8 @@ namespace bgfx
|
||||
/// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
|
||||
/// sampling.
|
||||
///
|
||||
/// @returns Handle to frame buffer object.
|
||||
///
|
||||
/// @attention C99 equivalent is `bgfx_create_frame_buffer`.
|
||||
///
|
||||
FrameBufferHandle createFrameBuffer(
|
||||
@ -1733,6 +1739,8 @@ namespace bgfx
|
||||
/// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
|
||||
/// sampling.
|
||||
///
|
||||
/// @returns Handle to frame buffer object.
|
||||
///
|
||||
/// @attention C99 equivalent is `bgfx_create_frame_buffer_scaled`.
|
||||
///
|
||||
FrameBufferHandle createFrameBuffer(
|
||||
@ -1748,6 +1756,8 @@ namespace bgfx
|
||||
/// @param[in] _destroyTextures If true, textures will be destroyed when
|
||||
/// frame buffer is destroyed.
|
||||
///
|
||||
/// @returns Handle to frame buffer object.
|
||||
///
|
||||
/// @attention C99 equivalent is `bgfx_create_frame_buffer_from_handles`.
|
||||
///
|
||||
FrameBufferHandle createFrameBuffer(
|
||||
@ -1763,6 +1773,8 @@ namespace bgfx
|
||||
/// @param[in] _destroyTextures If true, textures will be destroyed when
|
||||
/// frame buffer is destroyed.
|
||||
///
|
||||
/// @returns Handle to frame buffer object.
|
||||
///
|
||||
/// @attention C99 equivalent is `bgfx_create_frame_buffer_from_handles`.
|
||||
///
|
||||
FrameBufferHandle createFrameBuffer(
|
||||
|
@ -6,7 +6,7 @@
|
||||
#ifndef BGFX_DEFINES_H_HEADER_GUARD
|
||||
#define BGFX_DEFINES_H_HEADER_GUARD
|
||||
|
||||
#define BGFX_API_VERSION UINT32_C(15)
|
||||
#define BGFX_API_VERSION UINT32_C(16)
|
||||
|
||||
///
|
||||
#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000000000001) //!< Enable RGB write.
|
||||
|
@ -238,11 +238,11 @@ typedef enum bgfx_topology_convert
|
||||
#define BGFX_HANDLE_T(_name) \
|
||||
typedef struct _name { uint16_t idx; } _name##_t
|
||||
|
||||
BGFX_HANDLE_T(bgfx_indirect_buffer_handle);
|
||||
BGFX_HANDLE_T(bgfx_dynamic_index_buffer_handle);
|
||||
BGFX_HANDLE_T(bgfx_dynamic_vertex_buffer_handle);
|
||||
BGFX_HANDLE_T(bgfx_frame_buffer_handle);
|
||||
BGFX_HANDLE_T(bgfx_index_buffer_handle);
|
||||
BGFX_HANDLE_T(bgfx_indirect_buffer_handle);
|
||||
BGFX_HANDLE_T(bgfx_occlusion_query_handle);
|
||||
BGFX_HANDLE_T(bgfx_program_handle);
|
||||
BGFX_HANDLE_T(bgfx_shader_handle);
|
||||
@ -655,10 +655,10 @@ BGFX_C_API void bgfx_update_texture_3d(bgfx_texture_handle_t _handle, uint8_t _m
|
||||
BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
|
||||
|
||||
/**/
|
||||
BGFX_C_API void bgfx_read_texture(bgfx_texture_handle_t _handle, void* _data);
|
||||
BGFX_C_API uint32_t bgfx_read_texture(bgfx_texture_handle_t _handle, void* _data);
|
||||
|
||||
/**/
|
||||
BGFX_C_API void bgfx_read_frame_buffer(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, void* _data);
|
||||
BGFX_C_API uint32_t bgfx_read_frame_buffer(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, void* _data);
|
||||
|
||||
/**/
|
||||
BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle);
|
||||
|
16
src/bgfx.cpp
16
src/bgfx.cpp
@ -3116,20 +3116,20 @@ namespace bgfx
|
||||
}
|
||||
}
|
||||
|
||||
void readTexture(TextureHandle _handle, void* _data)
|
||||
uint32_t readTexture(TextureHandle _handle, void* _data)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
BX_CHECK(NULL != _data, "_data can't be NULL");
|
||||
BGFX_CHECK_CAPS(BGFX_CAPS_TEXTURE_READ_BACK, "Texture read-back is not supported!");
|
||||
s_ctx->readTexture(_handle, _data);
|
||||
return s_ctx->readTexture(_handle, _data);
|
||||
}
|
||||
|
||||
void readTexture(FrameBufferHandle _handle, uint8_t _attachment, void* _data)
|
||||
uint32_t readTexture(FrameBufferHandle _handle, uint8_t _attachment, void* _data)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
BX_CHECK(NULL != _data, "_data can't be NULL");
|
||||
BGFX_CHECK_CAPS(BGFX_CAPS_TEXTURE_READ_BACK, "Texture read-back is not supported!");
|
||||
s_ctx->readTexture(_handle, _attachment, _data);
|
||||
return s_ctx->readTexture(_handle, _attachment, _data);
|
||||
}
|
||||
|
||||
FrameBufferHandle createFrameBuffer(uint16_t _width, uint16_t _height, TextureFormat::Enum _format, uint32_t _textureFlags)
|
||||
@ -4169,16 +4169,16 @@ BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint8_t
|
||||
bgfx::updateTextureCube(handle.cpp, _side, _mip, _x, _y, _width, _height, (const bgfx::Memory*)_mem, _pitch);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_read_texture(bgfx_texture_handle_t _handle, void* _data)
|
||||
BGFX_C_API uint32_t bgfx_read_texture(bgfx_texture_handle_t _handle, void* _data)
|
||||
{
|
||||
union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
|
||||
bgfx::readTexture(handle.cpp, _data);
|
||||
return bgfx::readTexture(handle.cpp, _data);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_read_frame_buffer(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, void* _data)
|
||||
BGFX_C_API uint32_t bgfx_read_frame_buffer(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, void* _data)
|
||||
{
|
||||
union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
|
||||
bgfx::readTexture(handle.cpp, _attachment, _data);
|
||||
return bgfx::readTexture(handle.cpp, _attachment, _data);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle)
|
||||
|
@ -3129,20 +3129,21 @@ namespace bgfx
|
||||
textureDecRef(_handle);
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void readTexture(TextureHandle _handle, void* _data) )
|
||||
BGFX_API_FUNC(uint32_t readTexture(TextureHandle _handle, void* _data) )
|
||||
{
|
||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::ReadTexture);
|
||||
cmdbuf.write(_handle);
|
||||
cmdbuf.write(_data);
|
||||
return m_frames + 2;
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void readTexture(FrameBufferHandle _handle, uint8_t _attachment, void* _data) )
|
||||
BGFX_API_FUNC(uint32_t readTexture(FrameBufferHandle _handle, uint8_t _attachment, void* _data) )
|
||||
{
|
||||
const FrameBufferRef& ref = m_frameBufferRef[_handle.idx];
|
||||
BX_CHECK(!ref.m_window, "Can't sample window frame buffer.");
|
||||
TextureHandle textureHandle = ref.un.m_th[_attachment];
|
||||
BX_CHECK(isValid(textureHandle), "Frame buffer texture %d is invalid.", _attachment);
|
||||
readTexture(textureHandle, _data);
|
||||
return readTexture(textureHandle, _data);
|
||||
}
|
||||
|
||||
void resizeTexture(TextureHandle _handle, uint16_t _width, uint16_t _height)
|
||||
|
Loading…
x
Reference in New Issue
Block a user