mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-18 04:53:06 +01:00
discard flags
This commit is contained in:
committed by
Бранимир Караџић
parent
8ec25d96c7
commit
4b83e0f5bc
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2019 Branimir Karadzic. All rights reserved.
|
||||
* Copyright 2011-2020 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -201,6 +201,38 @@ public static partial class bgfx
|
||||
CullCcw = 0x0000002000000000,
|
||||
CullShift = 36,
|
||||
CullMask = 0x0000003000000000,
|
||||
|
||||
/// <summary>
|
||||
/// Discard only Index Buffer
|
||||
/// </summary>
|
||||
DiscardIndexBuffer = 0x0000000000000001,
|
||||
|
||||
/// <summary>
|
||||
/// Discard only Vertex Streams
|
||||
/// </summary>
|
||||
DiscardVertexStreams = 0x0000000000000002,
|
||||
|
||||
/// <summary>
|
||||
/// Discard only texture samplers
|
||||
/// </summary>
|
||||
DiscardTextureSamplers = 0x0000000000000003,
|
||||
|
||||
/// <summary>
|
||||
/// Discard only Compute shader related state
|
||||
/// </summary>
|
||||
DiscardCompute = 0x0000000000000004,
|
||||
|
||||
/// <summary>
|
||||
/// Discard only state
|
||||
/// </summary>
|
||||
DiscardState = 0x0000000000000005,
|
||||
|
||||
/// <summary>
|
||||
/// Discard every rendering states
|
||||
/// </summary>
|
||||
DiscardAll = 0xffffffffffffffff,
|
||||
DiscardShift = 0,
|
||||
DiscardMask = 0x0000000000000007,
|
||||
AlphaRefShift = 40,
|
||||
AlphaRefMask = 0x0000ff0000000000,
|
||||
|
||||
@@ -3787,11 +3819,13 @@ public static partial class bgfx
|
||||
public static extern unsafe void encoder_dispatch_indirect(Encoder* _this, ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, ushort _start, ushort _num);
|
||||
|
||||
/// <summary>
|
||||
/// Discard all previously set state for draw or compute call.
|
||||
/// Discard previously set state for draw or compute call.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="_flags">rendering states to discard</param>
|
||||
///
|
||||
[DllImport(DllName, EntryPoint="bgfx_encoder_discard", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern unsafe void encoder_discard(Encoder* _this);
|
||||
public static extern unsafe void encoder_discard(Encoder* _this, ulong _flags);
|
||||
|
||||
/// <summary>
|
||||
/// Blit 2D texture region between two 2D textures.
|
||||
@@ -4300,11 +4334,13 @@ public static partial class bgfx
|
||||
public static extern unsafe void dispatch_indirect(ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, ushort _start, ushort _num);
|
||||
|
||||
/// <summary>
|
||||
/// Discard all previously set state for draw or compute call.
|
||||
/// Discard previously set state for draw or compute call.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="_flags">rendering states to discard</param>
|
||||
///
|
||||
[DllImport(DllName, EntryPoint="bgfx_discard", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern unsafe void discard();
|
||||
public static extern unsafe void discard(ulong _flags);
|
||||
|
||||
/// <summary>
|
||||
/// Blit 2D texture region between two 2D textures.
|
||||
|
||||
@@ -1571,9 +1571,11 @@ version(BindBgfx_Static)
|
||||
void bgfx_encoder_dispatch_indirect(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, ushort _start, ushort _num);
|
||||
|
||||
/**
|
||||
* Discard all previously set state for draw or compute call.
|
||||
* Discard previously set state for draw or compute call.
|
||||
* Params:
|
||||
* _flags = rendering states to discard
|
||||
*/
|
||||
void bgfx_encoder_discard(bgfx_encoder_t* _this);
|
||||
void bgfx_encoder_discard(bgfx_encoder_t* _this, ulong _flags);
|
||||
|
||||
/**
|
||||
* Blit 2D texture region between two 2D textures.
|
||||
@@ -2028,9 +2030,11 @@ version(BindBgfx_Static)
|
||||
void bgfx_dispatch_indirect(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, ushort _start, ushort _num);
|
||||
|
||||
/**
|
||||
* Discard all previously set state for draw or compute call.
|
||||
* Discard previously set state for draw or compute call.
|
||||
* Params:
|
||||
* _flags = rendering states to discard
|
||||
*/
|
||||
void bgfx_discard();
|
||||
void bgfx_discard(ulong _flags);
|
||||
|
||||
/**
|
||||
* Blit 2D texture region between two 2D textures.
|
||||
@@ -3763,9 +3767,11 @@ else
|
||||
da_bgfx_encoder_dispatch_indirect bgfx_encoder_dispatch_indirect;
|
||||
|
||||
/**
|
||||
* Discard all previously set state for draw or compute call.
|
||||
* Discard previously set state for draw or compute call.
|
||||
* Params:
|
||||
* _flags = rendering states to discard
|
||||
*/
|
||||
alias da_bgfx_encoder_discard = void function(bgfx_encoder_t* _this);
|
||||
alias da_bgfx_encoder_discard = void function(bgfx_encoder_t* _this, ulong _flags);
|
||||
da_bgfx_encoder_discard bgfx_encoder_discard;
|
||||
|
||||
/**
|
||||
@@ -4262,9 +4268,11 @@ else
|
||||
da_bgfx_dispatch_indirect bgfx_dispatch_indirect;
|
||||
|
||||
/**
|
||||
* Discard all previously set state for draw or compute call.
|
||||
* Discard previously set state for draw or compute call.
|
||||
* Params:
|
||||
* _flags = rendering states to discard
|
||||
*/
|
||||
alias da_bgfx_discard = void function();
|
||||
alias da_bgfx_discard = void function(ulong _flags);
|
||||
da_bgfx_discard bgfx_discard;
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,6 +75,16 @@ enum ulong BGFX_STATE_CULL_CCW = 0x0000002000000000; /// Cull counter-clockwise
|
||||
enum ulong BGFX_STATE_CULL_SHIFT = 36; /// Culling mode bit shift
|
||||
enum ulong BGFX_STATE_CULL_MASK = 0x0000003000000000; /// Culling mode bit mask
|
||||
|
||||
/// Rendering state discard. When state is preserved in submit, rendering states can be discarded on a finer grain.
|
||||
enum ulong BGFX_STATE_DISCARD_INDEX_BUFFER = 0x0000000000000001; /// Discard only Index Buffer
|
||||
enum ulong BGFX_STATE_DISCARD_VERTEX_STREAMS = 0x0000000000000002; /// Discard only Vertex Streams
|
||||
enum ulong BGFX_STATE_DISCARD_TEXTURE_SAMPLERS = 0x0000000000000003; /// Discard only texture samplers
|
||||
enum ulong BGFX_STATE_DISCARD_COMPUTE = 0x0000000000000004; /// Discard only Compute shader related state
|
||||
enum ulong BGFX_STATE_DISCARD_STATE = 0x0000000000000005; /// Discard only state
|
||||
enum ulong BGFX_STATE_DISCARD_ALL = 0xffffffffffffffff; /// Discard every rendering states
|
||||
enum ulong BGFX_STATE_DISCARD_SHIFT = 0; /// Discard flags bit shift
|
||||
enum ulong BGFX_STATE_DISCARD_MASK = 0x0000000000000007; /// Discard flags bit mask
|
||||
|
||||
/// Alpha reference value.
|
||||
enum ulong BGFX_STATE_ALPHA_REF_SHIFT = 40; /// Alpha reference bit shift
|
||||
enum ulong BGFX_STATE_ALPHA_REF_MASK = 0x0000ff0000000000; /// Alpha reference bit mask
|
||||
|
||||
@@ -272,7 +272,7 @@ void VectorDisplay::endFrame()
|
||||
}
|
||||
}
|
||||
|
||||
bgfx::discard();
|
||||
bgfx::discard(BGFX_STATE_DISCARD_ALL);
|
||||
|
||||
//now do last pass, combination of blur and normal buffer to screen
|
||||
bgfx::setViewTransform(viewCounter, NULL, proj);
|
||||
|
||||
@@ -1590,7 +1590,7 @@ namespace bgfx
|
||||
///
|
||||
/// @attention C99 equivalent is `bgfx_encoder_discard`.
|
||||
///
|
||||
void discard();
|
||||
void discard(uint64_t flags);
|
||||
|
||||
/// Blit texture 2D region between two 2D textures.
|
||||
///
|
||||
@@ -3985,7 +3985,7 @@ namespace bgfx
|
||||
///
|
||||
/// @attention C99 equivalent is `bgfx_discard`.
|
||||
///
|
||||
void discard();
|
||||
void discard(uint64_t flags);
|
||||
|
||||
/// Blit 2D texture region between two 2D textures.
|
||||
///
|
||||
|
||||
@@ -2670,10 +2670,12 @@ BGFX_C_API void bgfx_encoder_dispatch(bgfx_encoder_t* _this, bgfx_view_id_t _id,
|
||||
BGFX_C_API void bgfx_encoder_dispatch_indirect(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
|
||||
|
||||
/**
|
||||
* Discard all previously set state for draw or compute call.
|
||||
* Discard previously set state for draw or compute call.
|
||||
*
|
||||
* @param[in] _flags rendering states to discard
|
||||
*
|
||||
*/
|
||||
BGFX_C_API void bgfx_encoder_discard(bgfx_encoder_t* _this);
|
||||
BGFX_C_API void bgfx_encoder_discard(bgfx_encoder_t* _this, uint64_t _flags);
|
||||
|
||||
/**
|
||||
* Blit 2D texture region between two 2D textures.
|
||||
@@ -3186,10 +3188,12 @@ BGFX_C_API void bgfx_dispatch(bgfx_view_id_t _id, bgfx_program_handle_t _program
|
||||
BGFX_C_API void bgfx_dispatch_indirect(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
|
||||
|
||||
/**
|
||||
* Discard all previously set state for draw or compute call.
|
||||
* Discard previously set state for draw or compute call.
|
||||
*
|
||||
* @param[in] _flags rendering states to discard
|
||||
*
|
||||
*/
|
||||
BGFX_C_API void bgfx_discard(void);
|
||||
BGFX_C_API void bgfx_discard(uint64_t _flags);
|
||||
|
||||
/**
|
||||
* Blit 2D texture region between two 2D textures.
|
||||
@@ -3554,7 +3558,7 @@ struct bgfx_interface_vtbl
|
||||
void (*encoder_set_image)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
|
||||
void (*encoder_dispatch)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ);
|
||||
void (*encoder_dispatch_indirect)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
|
||||
void (*encoder_discard)(bgfx_encoder_t* _this);
|
||||
void (*encoder_discard)(bgfx_encoder_t* _this, uint64_t _flags);
|
||||
void (*encoder_blit)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
|
||||
void (*request_screen_shot)(bgfx_frame_buffer_handle_t _handle, const char* _filePath);
|
||||
bgfx_render_frame_t (*render_frame)(int32_t _msecs);
|
||||
@@ -3596,7 +3600,7 @@ struct bgfx_interface_vtbl
|
||||
void (*set_image)(uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
|
||||
void (*dispatch)(bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ);
|
||||
void (*dispatch_indirect)(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
|
||||
void (*discard)(void);
|
||||
void (*discard)(uint64_t _flags);
|
||||
void (*blit)(bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
|
||||
};
|
||||
|
||||
|
||||
@@ -99,6 +99,19 @@
|
||||
#define BGFX_STATE_CULL_SHIFT 36 //!< Culling mode bit shift
|
||||
#define BGFX_STATE_CULL_MASK UINT64_C(0x0000003000000000) //!< Culling mode bit mask
|
||||
|
||||
/**
|
||||
* Rendering state discard. When state is preserved in submit, rendering states can be discarded on a finer grain.
|
||||
*
|
||||
*/
|
||||
#define BGFX_STATE_DISCARD_INDEX_BUFFER UINT64_C(0x0000000000000001) //!< Discard only Index Buffer
|
||||
#define BGFX_STATE_DISCARD_VERTEX_STREAMS UINT64_C(0x0000000000000002) //!< Discard only Vertex Streams
|
||||
#define BGFX_STATE_DISCARD_TEXTURE_SAMPLERS UINT64_C(0x0000000000000003) //!< Discard only texture samplers
|
||||
#define BGFX_STATE_DISCARD_COMPUTE UINT64_C(0x0000000000000004) //!< Discard only Compute shader related state
|
||||
#define BGFX_STATE_DISCARD_STATE UINT64_C(0x0000000000000005) //!< Discard only state
|
||||
#define BGFX_STATE_DISCARD_ALL UINT64_C(0xffffffffffffffff) //!< Discard every rendering states
|
||||
#define BGFX_STATE_DISCARD_SHIFT 0 //!< Discard flags bit shift
|
||||
#define BGFX_STATE_DISCARD_MASK UINT64_C(0x0000000000000007) //!< Discard flags bit mask
|
||||
|
||||
/**
|
||||
* Alpha reference value.
|
||||
*
|
||||
|
||||
@@ -83,6 +83,16 @@ flag.StateCull { bits = 64, shift = 36, range = 2, base = 1, desc = "Culling mod
|
||||
.Ccw --- Cull counter-clockwise triangles.
|
||||
()
|
||||
|
||||
--- Rendering state discard. When state is preserved in submit, rendering states can be discarded on a finer grain.
|
||||
flag.StateDiscard { bits = 64, shift = 0, range = 3, base = 1, desc = "Discard flags" }
|
||||
.IndexBuffer --- Discard only Index Buffer
|
||||
.VertexStreams --- Discard only Vertex Streams
|
||||
.TextureSamplers --- Discard only texture samplers
|
||||
.Compute --- Discard only Compute shader related state
|
||||
.State --- Discard only state
|
||||
.All (0xffffffffffffffff) --- Discard every rendering states
|
||||
()
|
||||
|
||||
--- Alpha reference value.
|
||||
flag.StateAlphaRef { bits = 64, shift = 40, range = 8, desc = "Alpha reference", "helper" }
|
||||
|
||||
@@ -2421,11 +2431,11 @@ func.Encoder.dispatch
|
||||
.id "ViewId" --- View id.
|
||||
.program "ProgramHandle" --- Compute program.
|
||||
.numX "uint32_t" --- Number of groups X.
|
||||
{ deafult = 1 }
|
||||
{ default = 1 }
|
||||
.numY "uint32_t" --- Number of groups Y.
|
||||
{ deafult = 1 }
|
||||
{ default = 1 }
|
||||
.numZ "uint32_t" --- Number of groups Z.
|
||||
{ deafult = 1 }
|
||||
{ default = 1 }
|
||||
|
||||
--- Dispatch compute indirect.
|
||||
func.Encoder.dispatch { cname = "dispatch_indirect" }
|
||||
@@ -2434,13 +2444,14 @@ func.Encoder.dispatch { cname = "dispatch_indirect" }
|
||||
.program "ProgramHandle" --- Compute program.
|
||||
.indirectHandle "IndirectBufferHandle" --- Indirect buffer.
|
||||
.start "uint16_t" --- First element in indirect buffer.
|
||||
{ deafult = 0 }
|
||||
{ default = 0 }
|
||||
.num "uint16_t" --- Number of dispatches.
|
||||
{ deafult = 1 }
|
||||
{ default = 1 }
|
||||
|
||||
--- Discard all previously set state for draw or compute call.
|
||||
--- Discard previously set state for draw or compute call.
|
||||
func.Encoder.discard
|
||||
"void"
|
||||
.flags "uint64_t" --- rendering states to discard
|
||||
|
||||
--- Blit 2D texture region between two 2D textures.
|
||||
---
|
||||
@@ -2931,11 +2942,11 @@ func.dispatch
|
||||
.id "ViewId" --- View id.
|
||||
.program "ProgramHandle" --- Compute program.
|
||||
.numX "uint32_t" --- Number of groups X.
|
||||
{ deafult = 1 }
|
||||
{ default = 1 }
|
||||
.numY "uint32_t" --- Number of groups Y.
|
||||
{ deafult = 1 }
|
||||
{ default = 1 }
|
||||
.numZ "uint32_t" --- Number of groups Z.
|
||||
{ deafult = 1 }
|
||||
{ default = 1 }
|
||||
|
||||
--- Dispatch compute indirect.
|
||||
func.dispatch { cname = "dispatch_indirect" }
|
||||
@@ -2944,13 +2955,14 @@ func.dispatch { cname = "dispatch_indirect" }
|
||||
.program "ProgramHandle" --- Compute program.
|
||||
.indirectHandle "IndirectBufferHandle" --- Indirect buffer.
|
||||
.start "uint16_t" --- First element in indirect buffer.
|
||||
{ deafult = 0 }
|
||||
{ default = 0 }
|
||||
.num "uint16_t" --- Number of dispatches.
|
||||
{ deafult = 1 }
|
||||
{ default = 1 }
|
||||
|
||||
--- Discard all previously set state for draw or compute call.
|
||||
--- Discard previously set state for draw or compute call.
|
||||
func.discard
|
||||
"void"
|
||||
.flags "uint64_t" --- rendering states to discard
|
||||
|
||||
--- Blit 2D texture region between two 2D textures.
|
||||
---
|
||||
|
||||
26
src/bgfx.cpp
26
src/bgfx.cpp
@@ -1184,14 +1184,14 @@ namespace bgfx
|
||||
|
||||
if (m_discard)
|
||||
{
|
||||
discard();
|
||||
discard(BGFX_STATE_DISCARD_ALL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 == m_draw.m_numVertices
|
||||
&& 0 == m_draw.m_numIndices)
|
||||
{
|
||||
discard();
|
||||
discard(BGFX_STATE_DISCARD_ALL);
|
||||
++m_numDropped;
|
||||
return;
|
||||
}
|
||||
@@ -1199,7 +1199,7 @@ namespace bgfx
|
||||
const uint32_t renderItemIdx = bx::atomicFetchAndAddsat<uint32_t>(&m_frame->m_numRenderItems, 1, BGFX_CONFIG_MAX_DRAW_CALLS);
|
||||
if (BGFX_CONFIG_MAX_DRAW_CALLS-1 <= renderItemIdx)
|
||||
{
|
||||
discard();
|
||||
discard(BGFX_STATE_DISCARD_ALL);
|
||||
++m_numDropped;
|
||||
return;
|
||||
}
|
||||
@@ -1266,8 +1266,8 @@ namespace bgfx
|
||||
|
||||
if (!_preserveState)
|
||||
{
|
||||
m_draw.clear();
|
||||
m_bind.clear();
|
||||
m_draw.clear(BGFX_STATE_DISCARD_ALL);
|
||||
m_bind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
m_uniformBegin = m_uniformEnd;
|
||||
}
|
||||
}
|
||||
@@ -1281,14 +1281,14 @@ namespace bgfx
|
||||
|
||||
if (m_discard)
|
||||
{
|
||||
discard();
|
||||
discard(BGFX_STATE_DISCARD_ALL);
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32_t renderItemIdx = bx::atomicFetchAndAddsat<uint32_t>(&m_frame->m_numRenderItems, 1, BGFX_CONFIG_MAX_DRAW_CALLS);
|
||||
if (BGFX_CONFIG_MAX_DRAW_CALLS-1 <= renderItemIdx)
|
||||
{
|
||||
discard();
|
||||
discard(BGFX_STATE_DISCARD_ALL);
|
||||
++m_numDropped;
|
||||
return;
|
||||
}
|
||||
@@ -1319,8 +1319,8 @@ namespace bgfx
|
||||
m_frame->m_renderItem[renderItemIdx].compute = m_compute;
|
||||
m_frame->m_renderItemBind[renderItemIdx] = m_bind;
|
||||
|
||||
m_compute.clear();
|
||||
m_bind.clear();
|
||||
m_compute.clear(BGFX_STATE_DISCARD_ALL);
|
||||
m_bind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
m_uniformBegin = m_uniformEnd;
|
||||
}
|
||||
|
||||
@@ -3780,9 +3780,9 @@ namespace bgfx
|
||||
BGFX_ENCODER(dispatch(_id, _program, _indirectHandle, _start, _num) );
|
||||
}
|
||||
|
||||
void Encoder::discard()
|
||||
void Encoder::discard(uint64_t flags)
|
||||
{
|
||||
BGFX_ENCODER(discard() );
|
||||
BGFX_ENCODER(discard(flags) );
|
||||
}
|
||||
|
||||
void Encoder::blit(ViewId _id, TextureHandle _dst, uint16_t _dstX, uint16_t _dstY, TextureHandle _src, uint16_t _srcX, uint16_t _srcY, uint16_t _width, uint16_t _height)
|
||||
@@ -4992,10 +4992,10 @@ namespace bgfx
|
||||
s_ctx->m_encoder0->dispatch(_id, _handle, _indirectHandle, _start, _num);
|
||||
}
|
||||
|
||||
void discard()
|
||||
void discard(uint64_t flags)
|
||||
{
|
||||
BGFX_CHECK_API_THREAD();
|
||||
s_ctx->m_encoder0->discard();
|
||||
s_ctx->m_encoder0->discard(flags);
|
||||
}
|
||||
|
||||
void blit(ViewId _id, TextureHandle _dst, uint16_t _dstX, uint16_t _dstY, TextureHandle _src, uint16_t _srcX, uint16_t _srcY, uint16_t _width, uint16_t _height)
|
||||
|
||||
@@ -912,10 +912,10 @@ BGFX_C_API void bgfx_encoder_dispatch_indirect(bgfx_encoder_t* _this, bgfx_view_
|
||||
This->dispatch((bgfx::ViewId)_id, program.cpp, indirectHandle.cpp, _start, _num);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_encoder_discard(bgfx_encoder_t* _this)
|
||||
BGFX_C_API void bgfx_encoder_discard(bgfx_encoder_t* _this, uint64_t _flags)
|
||||
{
|
||||
bgfx::Encoder* This = (bgfx::Encoder*)_this;
|
||||
This->discard();
|
||||
This->discard(_flags);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_encoder_blit(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth)
|
||||
@@ -1154,9 +1154,9 @@ BGFX_C_API void bgfx_dispatch_indirect(bgfx_view_id_t _id, bgfx_program_handle_t
|
||||
bgfx::dispatch((bgfx::ViewId)_id, program.cpp, indirectHandle.cpp, _start, _num);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_discard(void)
|
||||
BGFX_C_API void bgfx_discard(uint64_t _flags)
|
||||
{
|
||||
bgfx::discard();
|
||||
bgfx::discard(_flags);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_blit(bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth)
|
||||
|
||||
114
src/bgfx_p.h
114
src/bgfx_p.h
@@ -1543,14 +1543,17 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
BX_ALIGN_DECL_CACHE_LINE(struct) RenderBind
|
||||
{
|
||||
void clear()
|
||||
void clear(uint64_t flags)
|
||||
{
|
||||
for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++ii)
|
||||
if (flags & BGFX_STATE_DISCARD_TEXTURE_SAMPLERS)
|
||||
{
|
||||
Binding& bind = m_bind[ii];
|
||||
bind.m_idx = kInvalidHandle;
|
||||
bind.m_type = 0;
|
||||
bind.m_samplerFlags = 0;
|
||||
for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++ii)
|
||||
{
|
||||
Binding& bind = m_bind[ii];
|
||||
bind.m_idx = kInvalidHandle;
|
||||
bind.m_type = 0;
|
||||
bind.m_samplerFlags = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1559,32 +1562,42 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
BX_ALIGN_DECL_CACHE_LINE(struct) RenderDraw
|
||||
{
|
||||
void clear()
|
||||
void clear(uint64_t flags)
|
||||
{
|
||||
m_uniformBegin = 0;
|
||||
m_uniformEnd = 0;
|
||||
m_stateFlags = BGFX_STATE_DEFAULT;
|
||||
m_stencil = packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT);
|
||||
m_rgba = 0;
|
||||
m_startMatrix = 0;
|
||||
m_startIndex = 0;
|
||||
m_numIndices = UINT32_MAX;
|
||||
m_numVertices = UINT32_MAX;
|
||||
m_instanceDataOffset = 0;
|
||||
m_instanceDataStride = 0;
|
||||
m_numInstances = 1;
|
||||
m_startIndirect = 0;
|
||||
m_numIndirect = UINT16_MAX;
|
||||
m_numMatrices = 1;
|
||||
m_submitFlags = 0;
|
||||
m_scissor = UINT16_MAX;
|
||||
m_streamMask = 0;
|
||||
m_stream[0].clear();
|
||||
m_indexBuffer.idx = kInvalidHandle;
|
||||
m_instanceDataBuffer.idx = kInvalidHandle;
|
||||
m_indirectBuffer.idx = kInvalidHandle;
|
||||
m_occlusionQuery.idx = kInvalidHandle;
|
||||
m_uniformIdx = UINT8_MAX;
|
||||
if (flags & BGFX_STATE_DISCARD_STATE)
|
||||
{
|
||||
m_uniformBegin = 0;
|
||||
m_uniformEnd = 0;
|
||||
m_stateFlags = BGFX_STATE_DEFAULT;
|
||||
m_stencil = packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT);
|
||||
m_rgba = 0;
|
||||
m_startMatrix = 0;
|
||||
m_startIndex = 0;
|
||||
m_numIndices = UINT32_MAX;
|
||||
m_numVertices = UINT32_MAX;
|
||||
m_instanceDataOffset = 0;
|
||||
m_instanceDataStride = 0;
|
||||
m_numInstances = 1;
|
||||
m_startIndirect = 0;
|
||||
m_numIndirect = UINT16_MAX;
|
||||
m_numMatrices = 1;
|
||||
m_submitFlags = 0;
|
||||
m_scissor = UINT16_MAX;
|
||||
|
||||
m_instanceDataBuffer.idx = kInvalidHandle;
|
||||
m_indirectBuffer.idx = kInvalidHandle;
|
||||
m_occlusionQuery.idx = kInvalidHandle;
|
||||
m_uniformIdx = UINT8_MAX;
|
||||
}
|
||||
if (flags & BGFX_STATE_DISCARD_VERTEX_STREAMS)
|
||||
{
|
||||
m_streamMask = 0;
|
||||
m_stream[0].clear();
|
||||
}
|
||||
if (flags & BGFX_STATE_DISCARD_INDEX_BUFFER)
|
||||
{
|
||||
m_indexBuffer.idx = kInvalidHandle;
|
||||
}
|
||||
}
|
||||
|
||||
bool setStreamBit(uint8_t _stream, VertexBufferHandle _handle)
|
||||
@@ -1625,21 +1638,24 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
BX_ALIGN_DECL_CACHE_LINE(struct) RenderCompute
|
||||
{
|
||||
void clear()
|
||||
void clear(uint64_t flags)
|
||||
{
|
||||
m_uniformBegin = 0;
|
||||
m_uniformEnd = 0;
|
||||
m_startMatrix = 0;
|
||||
m_numX = 0;
|
||||
m_numY = 0;
|
||||
m_numZ = 0;
|
||||
m_numMatrices = 0;
|
||||
m_submitFlags = 0;
|
||||
m_uniformIdx = UINT8_MAX;
|
||||
if (flags & BGFX_STATE_DISCARD_COMPUTE)
|
||||
{
|
||||
m_uniformBegin = 0;
|
||||
m_uniformEnd = 0;
|
||||
m_startMatrix = 0;
|
||||
m_numX = 0;
|
||||
m_numY = 0;
|
||||
m_numZ = 0;
|
||||
m_numMatrices = 0;
|
||||
m_submitFlags = 0;
|
||||
m_uniformIdx = UINT8_MAX;
|
||||
|
||||
m_indirectBuffer.idx = kInvalidHandle;
|
||||
m_startIndirect = 0;
|
||||
m_numIndirect = UINT16_MAX;
|
||||
m_indirectBuffer.idx = kInvalidHandle;
|
||||
m_startIndirect = 0;
|
||||
m_numIndirect = UINT16_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t m_uniformBegin;
|
||||
@@ -2183,7 +2199,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
{
|
||||
EncoderImpl()
|
||||
{
|
||||
discard();
|
||||
discard(BGFX_STATE_DISCARD_ALL);
|
||||
}
|
||||
|
||||
void begin(Frame* _frame, uint8_t _idx)
|
||||
@@ -2478,7 +2494,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
bind.m_mip = _mip;
|
||||
}
|
||||
|
||||
void discard()
|
||||
void discard(uint64_t flags)
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
|
||||
{
|
||||
@@ -2486,9 +2502,9 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
}
|
||||
|
||||
m_discard = false;
|
||||
m_draw.clear();
|
||||
m_compute.clear();
|
||||
m_bind.clear();
|
||||
m_draw.clear(flags);
|
||||
m_compute.clear(flags);
|
||||
m_bind.clear(flags);
|
||||
}
|
||||
|
||||
void submit(ViewId _id, ProgramHandle _program, OcclusionQueryHandle _occlusionQuery, uint32_t _depth, bool _preserveState);
|
||||
|
||||
@@ -5309,12 +5309,12 @@ namespace bgfx { namespace d3d11
|
||||
_render->sort();
|
||||
|
||||
RenderDraw currentState;
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_stateFlags = BGFX_STATE_NONE;
|
||||
currentState.m_stencil = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
|
||||
|
||||
RenderBind currentBind;
|
||||
currentBind.clear();
|
||||
currentBind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
|
||||
static ViewState viewState;
|
||||
viewState.reset(_render);
|
||||
@@ -5617,9 +5617,9 @@ namespace bgfx { namespace d3d11
|
||||
{
|
||||
if (resetState)
|
||||
{
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_scissor = !draw.m_scissor;
|
||||
currentBind.clear();
|
||||
currentBind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -5640,14 +5640,14 @@ namespace bgfx { namespace d3d11
|
||||
{
|
||||
wasCompute = false;
|
||||
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_scissor = !draw.m_scissor;
|
||||
changedFlags = BGFX_STATE_MASK;
|
||||
changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
|
||||
currentState.m_stateFlags = newFlags;
|
||||
currentState.m_stencil = newStencil;
|
||||
|
||||
currentBind.clear();
|
||||
currentBind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
|
||||
setBlendState(newFlags);
|
||||
setDepthStencilState(newFlags, packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT) );
|
||||
|
||||
@@ -5753,12 +5753,12 @@ namespace bgfx { namespace d3d12
|
||||
_render->sort();
|
||||
|
||||
RenderDraw currentState;
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_stateFlags = BGFX_STATE_NONE;
|
||||
currentState.m_stencil = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
|
||||
|
||||
RenderBind currentBind;
|
||||
currentBind.clear();
|
||||
currentBind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
|
||||
static ViewState viewState;
|
||||
viewState.reset(_render);
|
||||
@@ -6174,9 +6174,9 @@ namespace bgfx { namespace d3d12
|
||||
{
|
||||
if (resetState)
|
||||
{
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_scissor = !draw.m_scissor;
|
||||
currentBind.clear();
|
||||
currentBind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
commandListChanged = true;
|
||||
}
|
||||
|
||||
@@ -6196,14 +6196,14 @@ namespace bgfx { namespace d3d12
|
||||
{
|
||||
wasCompute = false;
|
||||
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_scissor = !draw.m_scissor;
|
||||
changedFlags = BGFX_STATE_MASK;
|
||||
changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
|
||||
currentState.m_stateFlags = newFlags;
|
||||
currentState.m_stencil = newStencil;
|
||||
|
||||
currentBind.clear();
|
||||
currentBind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
|
||||
commandListChanged = true;
|
||||
}
|
||||
@@ -6223,14 +6223,14 @@ namespace bgfx { namespace d3d12
|
||||
currentBindHash = 0;
|
||||
currentSamplerStateIdx = kInvalidHandle;
|
||||
currentProgram = BGFX_INVALID_HANDLE;
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_scissor = !draw.m_scissor;
|
||||
changedFlags = BGFX_STATE_MASK;
|
||||
changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
|
||||
currentState.m_stateFlags = newFlags;
|
||||
currentState.m_stencil = newStencil;
|
||||
|
||||
currentBind.clear();
|
||||
currentBind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
|
||||
const uint64_t pt = newFlags&BGFX_STATE_PT_MASK;
|
||||
primIndex = uint8_t(pt>>BGFX_STATE_PT_SHIFT);
|
||||
|
||||
@@ -3746,12 +3746,12 @@ namespace bgfx { namespace d3d9
|
||||
_render->sort();
|
||||
|
||||
RenderDraw currentState;
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_stateFlags = BGFX_STATE_NONE;
|
||||
currentState.m_stencil = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
|
||||
|
||||
RenderBind currentBind;
|
||||
currentBind.clear();
|
||||
currentBind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
|
||||
static ViewState viewState;
|
||||
viewState.reset(_render);
|
||||
@@ -3839,7 +3839,7 @@ namespace bgfx { namespace d3d9
|
||||
|
||||
if (key.m_view != view)
|
||||
{
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_scissor = !draw.m_scissor;
|
||||
changedFlags = BGFX_STATE_MASK;
|
||||
changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
|
||||
|
||||
@@ -6482,12 +6482,12 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
|
||||
_render->sort();
|
||||
|
||||
RenderDraw currentState;
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_stateFlags = BGFX_STATE_NONE;
|
||||
currentState.m_stencil = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
|
||||
|
||||
RenderBind currentBind;
|
||||
currentBind.clear();
|
||||
currentBind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
|
||||
static ViewState viewState;
|
||||
viewState.reset(_render);
|
||||
@@ -6769,9 +6769,9 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
|
||||
{
|
||||
if (resetState)
|
||||
{
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_scissor = !draw.m_scissor;
|
||||
currentBind.clear();
|
||||
currentBind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -6788,14 +6788,14 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
|
||||
|
||||
if (resetState)
|
||||
{
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_scissor = !draw.m_scissor;
|
||||
changedFlags = BGFX_STATE_MASK;
|
||||
changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
|
||||
currentState.m_stateFlags = newFlags;
|
||||
currentState.m_stencil = newStencil;
|
||||
|
||||
currentBind.clear();
|
||||
currentBind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
}
|
||||
|
||||
uint16_t scissor = draw.m_scissor;
|
||||
|
||||
@@ -3687,12 +3687,12 @@ namespace bgfx { namespace mtl
|
||||
_render->sort();
|
||||
|
||||
RenderDraw currentState;
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_stateFlags = BGFX_STATE_NONE;
|
||||
currentState.m_stencil = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
|
||||
|
||||
RenderBind currentBind;
|
||||
currentBind.clear();
|
||||
currentBind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
|
||||
static ViewState viewState;
|
||||
viewState.reset(_render);
|
||||
@@ -4136,9 +4136,9 @@ namespace bgfx { namespace mtl
|
||||
{
|
||||
if (resetState)
|
||||
{
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_scissor = !draw.m_scissor;
|
||||
currentBind.clear();
|
||||
currentBind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -4155,14 +4155,14 @@ namespace bgfx { namespace mtl
|
||||
|
||||
if (resetState)
|
||||
{
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_scissor = !draw.m_scissor;
|
||||
changedFlags = BGFX_STATE_MASK;
|
||||
changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
|
||||
currentState.m_stateFlags = newFlags;
|
||||
currentState.m_stencil = newStencil;
|
||||
|
||||
currentBind.clear();
|
||||
currentBind.clear(BGFX_STATE_DISCARD_ALL);
|
||||
|
||||
currentProgram = BGFX_INVALID_HANDLE;
|
||||
setDepthStencilState(newFlags, packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT) );
|
||||
|
||||
@@ -5733,7 +5733,7 @@ VK_DESTROY
|
||||
_render->sort();
|
||||
|
||||
RenderDraw currentState;
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_stateFlags = BGFX_STATE_NONE;
|
||||
currentState.m_stencil = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
|
||||
|
||||
@@ -6138,7 +6138,7 @@ VK_DESTROY
|
||||
currentDslHash = 0;
|
||||
currentSamplerStateIdx = kInvalidHandle;
|
||||
currentProgram = BGFX_INVALID_HANDLE;
|
||||
currentState.clear();
|
||||
currentState.clear(BGFX_STATE_DISCARD_ALL);
|
||||
currentState.m_scissor = !draw.m_scissor;
|
||||
changedFlags = BGFX_STATE_MASK;
|
||||
changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
|
||||
|
||||
Reference in New Issue
Block a user