mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-19 21:42:59 +01:00
Fixix blit submit.
This commit is contained in:
@@ -2126,6 +2126,8 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
m_occlusionQuery.invalidate(_handle);
|
||||
}
|
||||
|
||||
void submitBlit(BlitState& _bs, uint16_t _view);
|
||||
|
||||
void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) BX_OVERRIDE;
|
||||
|
||||
void blitSetup(TextVideoMemBlitter& _blitter) BX_OVERRIDE
|
||||
@@ -5316,6 +5318,85 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
}
|
||||
}
|
||||
|
||||
void RendererContextD3D11::submitBlit(BlitState& _bs, uint16_t _view)
|
||||
{
|
||||
ID3D11DeviceContext* deviceCtx = m_deviceCtx;
|
||||
|
||||
while (_bs.hasItem(_view) )
|
||||
{
|
||||
const BlitItem& blit = _bs.advance();
|
||||
|
||||
const TextureD3D11& src = m_textures[blit.m_src.idx];
|
||||
const TextureD3D11& dst = m_textures[blit.m_dst.idx];
|
||||
|
||||
uint32_t srcWidth = bx::uint32_min(src.m_width, blit.m_srcX + blit.m_width) - blit.m_srcX;
|
||||
uint32_t srcHeight = bx::uint32_min(src.m_height, blit.m_srcY + blit.m_height) - blit.m_srcY;
|
||||
uint32_t srcDepth = bx::uint32_min(src.m_depth, blit.m_srcZ + blit.m_depth) - blit.m_srcZ;
|
||||
uint32_t dstWidth = bx::uint32_min(dst.m_width, blit.m_dstX + blit.m_width) - blit.m_dstX;
|
||||
uint32_t dstHeight = bx::uint32_min(dst.m_height, blit.m_dstY + blit.m_height) - blit.m_dstY;
|
||||
uint32_t dstDepth = bx::uint32_min(dst.m_depth, blit.m_dstZ + blit.m_depth) - blit.m_dstZ;
|
||||
uint32_t width = bx::uint32_min(srcWidth, dstWidth);
|
||||
uint32_t height = bx::uint32_min(srcHeight, dstHeight);
|
||||
uint32_t depth = bx::uint32_min(srcDepth, dstDepth);
|
||||
|
||||
if (TextureD3D11::Texture3D == src.m_type)
|
||||
{
|
||||
D3D11_BOX box;
|
||||
box.left = blit.m_srcX;
|
||||
box.top = blit.m_srcY;
|
||||
box.front = blit.m_srcZ;
|
||||
box.right = blit.m_srcX + width;
|
||||
box.bottom = blit.m_srcY + height;;
|
||||
box.back = blit.m_srcZ + bx::uint32_imax(1, depth);
|
||||
|
||||
deviceCtx->CopySubresourceRegion(dst.m_ptr
|
||||
, blit.m_dstMip
|
||||
, blit.m_dstX
|
||||
, blit.m_dstY
|
||||
, blit.m_dstZ
|
||||
, src.m_ptr
|
||||
, blit.m_srcMip
|
||||
, &box
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool depthStencil = bimg::isDepth(bimg::TextureFormat::Enum(src.m_textureFormat) );
|
||||
BX_CHECK(!depthStencil
|
||||
|| (width == src.m_width && height == src.m_height)
|
||||
, "When blitting depthstencil surface, source resolution must match destination."
|
||||
);
|
||||
|
||||
D3D11_BOX box;
|
||||
box.left = blit.m_srcX;
|
||||
box.top = blit.m_srcY;
|
||||
box.front = 0;
|
||||
box.right = blit.m_srcX + width;
|
||||
box.bottom = blit.m_srcY + height;
|
||||
box.back = 1;
|
||||
|
||||
const uint32_t srcZ = TextureD3D11::TextureCube == src.m_type
|
||||
? blit.m_srcZ
|
||||
: 0
|
||||
;
|
||||
const uint32_t dstZ = TextureD3D11::TextureCube == dst.m_type
|
||||
? blit.m_dstZ
|
||||
: 0
|
||||
;
|
||||
|
||||
deviceCtx->CopySubresourceRegion(dst.m_ptr
|
||||
, dstZ*dst.m_numMips+blit.m_dstMip
|
||||
, blit.m_dstX
|
||||
, blit.m_dstY
|
||||
, 0
|
||||
, src.m_ptr
|
||||
, srcZ*src.m_numMips+blit.m_srcMip
|
||||
, depthStencil ? NULL : &box
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RendererContextD3D11::submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter)
|
||||
{
|
||||
if (m_lost
|
||||
@@ -5379,10 +5460,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
uint16_t view = UINT16_MAX;
|
||||
FrameBufferHandle fbh = { BGFX_CONFIG_MAX_FRAME_BUFFERS };
|
||||
|
||||
BlitKey blitKey;
|
||||
blitKey.decode(_render->m_blitKeys[0]);
|
||||
uint16_t numBlitItems = _render->m_numBlitItems;
|
||||
uint16_t blitItem = 0;
|
||||
BlitState bs(_render);
|
||||
|
||||
const uint64_t primType = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : 0;
|
||||
uint8_t primIndex = uint8_t(primType >> BGFX_STATE_PT_SHIFT);
|
||||
@@ -5535,81 +5613,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
prim = s_primInfo[BX_COUNTOF(s_primName)]; // Force primitive type update after clear quad.
|
||||
}
|
||||
|
||||
const uint8_t blitView = SortKey::decodeView(encodedKey);
|
||||
for (; blitItem < numBlitItems && blitKey.m_view <= blitView; blitItem++)
|
||||
{
|
||||
const BlitItem& blit = _render->m_blitItem[blitItem];
|
||||
blitKey.decode(_render->m_blitKeys[blitItem+1]);
|
||||
|
||||
const TextureD3D11& src = m_textures[blit.m_src.idx];
|
||||
const TextureD3D11& dst = m_textures[blit.m_dst.idx];
|
||||
|
||||
uint32_t srcWidth = bx::uint32_min(src.m_width, blit.m_srcX + blit.m_width) - blit.m_srcX;
|
||||
uint32_t srcHeight = bx::uint32_min(src.m_height, blit.m_srcY + blit.m_height) - blit.m_srcY;
|
||||
uint32_t srcDepth = bx::uint32_min(src.m_depth, blit.m_srcZ + blit.m_depth) - blit.m_srcZ;
|
||||
uint32_t dstWidth = bx::uint32_min(dst.m_width, blit.m_dstX + blit.m_width) - blit.m_dstX;
|
||||
uint32_t dstHeight = bx::uint32_min(dst.m_height, blit.m_dstY + blit.m_height) - blit.m_dstY;
|
||||
uint32_t dstDepth = bx::uint32_min(dst.m_depth, blit.m_dstZ + blit.m_depth) - blit.m_dstZ;
|
||||
uint32_t width = bx::uint32_min(srcWidth, dstWidth);
|
||||
uint32_t height = bx::uint32_min(srcHeight, dstHeight);
|
||||
uint32_t depth = bx::uint32_min(srcDepth, dstDepth);
|
||||
|
||||
if (TextureD3D11::Texture3D == src.m_type)
|
||||
{
|
||||
D3D11_BOX box;
|
||||
box.left = blit.m_srcX;
|
||||
box.top = blit.m_srcY;
|
||||
box.front = blit.m_srcZ;
|
||||
box.right = blit.m_srcX + width;
|
||||
box.bottom = blit.m_srcY + height;;
|
||||
box.back = blit.m_srcZ + bx::uint32_imax(1, depth);
|
||||
|
||||
deviceCtx->CopySubresourceRegion(dst.m_ptr
|
||||
, blit.m_dstMip
|
||||
, blit.m_dstX
|
||||
, blit.m_dstY
|
||||
, blit.m_dstZ
|
||||
, src.m_ptr
|
||||
, blit.m_srcMip
|
||||
, &box
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool depthStencil = bimg::isDepth(bimg::TextureFormat::Enum(src.m_textureFormat) );
|
||||
BX_CHECK(!depthStencil
|
||||
|| (width == src.m_width && height == src.m_height)
|
||||
, "When blitting depthstencil surface, source resolution must match destination."
|
||||
);
|
||||
|
||||
D3D11_BOX box;
|
||||
box.left = blit.m_srcX;
|
||||
box.top = blit.m_srcY;
|
||||
box.front = 0;
|
||||
box.right = blit.m_srcX + width;
|
||||
box.bottom = blit.m_srcY + height;
|
||||
box.back = 1;
|
||||
|
||||
const uint32_t srcZ = TextureD3D11::TextureCube == src.m_type
|
||||
? blit.m_srcZ
|
||||
: 0
|
||||
;
|
||||
const uint32_t dstZ = TextureD3D11::TextureCube == dst.m_type
|
||||
? blit.m_dstZ
|
||||
: 0
|
||||
;
|
||||
|
||||
deviceCtx->CopySubresourceRegion(dst.m_ptr
|
||||
, dstZ*dst.m_numMips+blit.m_dstMip
|
||||
, blit.m_dstX
|
||||
, blit.m_dstY
|
||||
, 0
|
||||
, src.m_ptr
|
||||
, srcZ*src.m_numMips+blit.m_srcMip
|
||||
, depthStencil ? NULL : &box
|
||||
);
|
||||
}
|
||||
}
|
||||
submitBlit(bs, view);
|
||||
}
|
||||
|
||||
if (isCompute)
|
||||
@@ -6259,6 +6263,8 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
invalidateCompute();
|
||||
}
|
||||
|
||||
submitBlit(bs, BGFX_CONFIG_MAX_VIEWS);
|
||||
|
||||
if (0 < _render->m_num)
|
||||
{
|
||||
if (0 != (m_resolution.m_flags & BGFX_RESET_FLUSH_AFTER_RENDER) )
|
||||
|
||||
@@ -1679,6 +1679,8 @@ namespace bgfx { namespace d3d12
|
||||
m_occlusionQuery.invalidate(_handle);
|
||||
}
|
||||
|
||||
void submitBlit(BlitState& _bs, uint16_t _view);
|
||||
|
||||
void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) BX_OVERRIDE;
|
||||
|
||||
void blitSetup(TextVideoMemBlitter& _blitter) BX_OVERRIDE
|
||||
@@ -4812,6 +4814,85 @@ data.NumQualityLevels = 0;
|
||||
uint16_t m_samplerStateIdx;
|
||||
};
|
||||
|
||||
void RendererContextD3D12::submitBlit(BlitState& _bs, uint16_t _view)
|
||||
{
|
||||
while (_bs.hasItem(_view) )
|
||||
{
|
||||
const BlitItem& blit = _bs.advance();
|
||||
|
||||
const TextureD3D12& src = m_textures[blit.m_src.idx];
|
||||
const TextureD3D12& dst = m_textures[blit.m_dst.idx];
|
||||
|
||||
uint32_t srcWidth = bx::uint32_min(src.m_width, blit.m_srcX + blit.m_width) - blit.m_srcX;
|
||||
uint32_t srcHeight = bx::uint32_min(src.m_height, blit.m_srcY + blit.m_height) - blit.m_srcY;
|
||||
uint32_t srcDepth = bx::uint32_min(src.m_depth, blit.m_srcZ + blit.m_depth) - blit.m_srcZ;
|
||||
uint32_t dstWidth = bx::uint32_min(dst.m_width, blit.m_dstX + blit.m_width) - blit.m_dstX;
|
||||
uint32_t dstHeight = bx::uint32_min(dst.m_height, blit.m_dstY + blit.m_height) - blit.m_dstY;
|
||||
uint32_t dstDepth = bx::uint32_min(dst.m_depth, blit.m_dstZ + blit.m_depth) - blit.m_dstZ;
|
||||
uint32_t width = bx::uint32_min(srcWidth, dstWidth);
|
||||
uint32_t height = bx::uint32_min(srcHeight, dstHeight);
|
||||
uint32_t depth = bx::uint32_min(srcDepth, dstDepth);
|
||||
|
||||
if (TextureD3D12::Texture3D == src.m_type)
|
||||
{
|
||||
D3D12_BOX box;
|
||||
box.left = blit.m_srcX;
|
||||
box.top = blit.m_srcY;
|
||||
box.front = blit.m_srcZ;
|
||||
box.right = blit.m_srcX + width;
|
||||
box.bottom = blit.m_srcY + height;;
|
||||
box.back = blit.m_srcZ + bx::uint32_imax(1, depth);
|
||||
|
||||
D3D12_TEXTURE_COPY_LOCATION dstLocation = { dst.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, {{}} };
|
||||
D3D12_TEXTURE_COPY_LOCATION srcLocation = { src.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, {{}} };
|
||||
m_commandList->CopyTextureRegion(&dstLocation
|
||||
, blit.m_dstX
|
||||
, blit.m_dstY
|
||||
, blit.m_dstZ
|
||||
, &srcLocation
|
||||
, &box
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
D3D12_BOX box;
|
||||
box.left = blit.m_srcX;
|
||||
box.top = blit.m_srcY;
|
||||
box.front = 0;
|
||||
box.right = blit.m_srcX + width;
|
||||
box.bottom = blit.m_srcY + height;;
|
||||
box.back = 1;
|
||||
|
||||
const uint32_t srcZ = TextureD3D12::TextureCube == src.m_type
|
||||
? blit.m_srcZ
|
||||
: 0
|
||||
;
|
||||
const uint32_t dstZ = TextureD3D12::TextureCube == dst.m_type
|
||||
? blit.m_dstZ
|
||||
: 0
|
||||
;
|
||||
|
||||
D3D12_TEXTURE_COPY_LOCATION dstLocation;
|
||||
dstLocation.pResource = dst.m_ptr;
|
||||
dstLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
|
||||
dstLocation.SubresourceIndex = dstZ*dst.m_numMips+blit.m_dstMip;
|
||||
D3D12_TEXTURE_COPY_LOCATION srcLocation;
|
||||
srcLocation.pResource = src.m_ptr;
|
||||
srcLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
|
||||
srcLocation.SubresourceIndex = srcZ*src.m_numMips+blit.m_srcMip;
|
||||
|
||||
bool depthStencil = bimg::isDepth(bimg::TextureFormat::Enum(src.m_textureFormat) );
|
||||
m_commandList->CopyTextureRegion(&dstLocation
|
||||
, blit.m_dstX
|
||||
, blit.m_dstY
|
||||
, 0
|
||||
, &srcLocation
|
||||
, depthStencil ? NULL : &box
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RendererContextD3D12::submit(Frame* _render, ClearQuad& /*_clearQuad*/, TextVideoMemBlitter& _textVideoMemBlitter)
|
||||
{
|
||||
// PIX_BEGINEVENT(D3DCOLOR_FRAME, L"rendererSubmit");
|
||||
@@ -4868,10 +4949,7 @@ data.NumQualityLevels = 0;
|
||||
uint16_t view = UINT16_MAX;
|
||||
FrameBufferHandle fbh = { BGFX_CONFIG_MAX_FRAME_BUFFERS };
|
||||
|
||||
BlitKey blitKey;
|
||||
blitKey.decode(_render->m_blitKeys[0]);
|
||||
uint16_t numBlitItems = _render->m_numBlitItems;
|
||||
uint16_t blitItem = 0;
|
||||
BlitState bs(_render);
|
||||
|
||||
uint32_t blendFactor = 0;
|
||||
|
||||
@@ -4986,83 +5064,7 @@ data.NumQualityLevels = 0;
|
||||
|
||||
prim = s_primInfo[BX_COUNTOF(s_primName)]; // Force primitive type update.
|
||||
|
||||
const uint8_t blitView = SortKey::decodeView(encodedKey);
|
||||
for (; blitItem < numBlitItems && blitKey.m_view <= blitView; blitItem++)
|
||||
{
|
||||
const BlitItem& blit = _render->m_blitItem[blitItem];
|
||||
blitKey.decode(_render->m_blitKeys[blitItem+1]);
|
||||
|
||||
const TextureD3D12& src = m_textures[blit.m_src.idx];
|
||||
const TextureD3D12& dst = m_textures[blit.m_dst.idx];
|
||||
|
||||
uint32_t srcWidth = bx::uint32_min(src.m_width, blit.m_srcX + blit.m_width) - blit.m_srcX;
|
||||
uint32_t srcHeight = bx::uint32_min(src.m_height, blit.m_srcY + blit.m_height) - blit.m_srcY;
|
||||
uint32_t srcDepth = bx::uint32_min(src.m_depth, blit.m_srcZ + blit.m_depth) - blit.m_srcZ;
|
||||
uint32_t dstWidth = bx::uint32_min(dst.m_width, blit.m_dstX + blit.m_width) - blit.m_dstX;
|
||||
uint32_t dstHeight = bx::uint32_min(dst.m_height, blit.m_dstY + blit.m_height) - blit.m_dstY;
|
||||
uint32_t dstDepth = bx::uint32_min(dst.m_depth, blit.m_dstZ + blit.m_depth) - blit.m_dstZ;
|
||||
uint32_t width = bx::uint32_min(srcWidth, dstWidth);
|
||||
uint32_t height = bx::uint32_min(srcHeight, dstHeight);
|
||||
uint32_t depth = bx::uint32_min(srcDepth, dstDepth);
|
||||
|
||||
if (TextureD3D12::Texture3D == src.m_type)
|
||||
{
|
||||
D3D12_BOX box;
|
||||
box.left = blit.m_srcX;
|
||||
box.top = blit.m_srcY;
|
||||
box.front = blit.m_srcZ;
|
||||
box.right = blit.m_srcX + width;
|
||||
box.bottom = blit.m_srcY + height;;
|
||||
box.back = blit.m_srcZ + bx::uint32_imax(1, depth);
|
||||
|
||||
D3D12_TEXTURE_COPY_LOCATION dstLocation = { dst.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, {{}} };
|
||||
D3D12_TEXTURE_COPY_LOCATION srcLocation = { src.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, {{}} };
|
||||
m_commandList->CopyTextureRegion(&dstLocation
|
||||
, blit.m_dstX
|
||||
, blit.m_dstY
|
||||
, blit.m_dstZ
|
||||
, &srcLocation
|
||||
, &box
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
D3D12_BOX box;
|
||||
box.left = blit.m_srcX;
|
||||
box.top = blit.m_srcY;
|
||||
box.front = 0;
|
||||
box.right = blit.m_srcX + width;
|
||||
box.bottom = blit.m_srcY + height;;
|
||||
box.back = 1;
|
||||
|
||||
const uint32_t srcZ = TextureD3D12::TextureCube == src.m_type
|
||||
? blit.m_srcZ
|
||||
: 0
|
||||
;
|
||||
const uint32_t dstZ = TextureD3D12::TextureCube == dst.m_type
|
||||
? blit.m_dstZ
|
||||
: 0
|
||||
;
|
||||
|
||||
D3D12_TEXTURE_COPY_LOCATION dstLocation;
|
||||
dstLocation.pResource = dst.m_ptr;
|
||||
dstLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
|
||||
dstLocation.SubresourceIndex = dstZ*dst.m_numMips+blit.m_dstMip;
|
||||
D3D12_TEXTURE_COPY_LOCATION srcLocation;
|
||||
srcLocation.pResource = src.m_ptr;
|
||||
srcLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
|
||||
srcLocation.SubresourceIndex = srcZ*src.m_numMips+blit.m_srcMip;
|
||||
|
||||
bool depthStencil = bimg::isDepth(bimg::TextureFormat::Enum(src.m_textureFormat) );
|
||||
m_commandList->CopyTextureRegion(&dstLocation
|
||||
, blit.m_dstX
|
||||
, blit.m_dstY
|
||||
, 0
|
||||
, &srcLocation
|
||||
, depthStencil ? NULL : &box
|
||||
);
|
||||
}
|
||||
}
|
||||
submitBlit(bs, view);
|
||||
}
|
||||
|
||||
if (isCompute)
|
||||
@@ -5548,6 +5550,8 @@ data.NumQualityLevels = 0;
|
||||
}
|
||||
}
|
||||
|
||||
submitBlit(bs, BGFX_CONFIG_MAX_VIEWS);
|
||||
|
||||
m_batch.end(m_commandList);
|
||||
}
|
||||
|
||||
|
||||
@@ -1238,6 +1238,8 @@ namespace bgfx { namespace d3d9
|
||||
m_occlusionQuery.invalidate(_handle);
|
||||
}
|
||||
|
||||
void submitBlit(BlitState& _bs, uint16_t _view);
|
||||
|
||||
void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) BX_OVERRIDE;
|
||||
|
||||
void blitSetup(TextVideoMemBlitter& _blitter) BX_OVERRIDE
|
||||
@@ -3610,6 +3612,60 @@ namespace bgfx { namespace d3d9
|
||||
}
|
||||
}
|
||||
|
||||
void RendererContextD3D9::submitBlit(BlitState& _bs, uint16_t _view)
|
||||
{
|
||||
while (_bs.hasItem(_view) )
|
||||
{
|
||||
const BlitItem& blit = _bs.advance();
|
||||
|
||||
const TextureD3D9& src = m_textures[blit.m_src.idx];
|
||||
const TextureD3D9& dst = m_textures[blit.m_dst.idx];
|
||||
|
||||
uint32_t srcWidth = bx::uint32_min(src.m_width, blit.m_srcX + blit.m_width) - blit.m_srcX;
|
||||
uint32_t srcHeight = bx::uint32_min(src.m_height, blit.m_srcY + blit.m_height) - blit.m_srcY;
|
||||
uint32_t dstWidth = bx::uint32_min(dst.m_width, blit.m_dstX + blit.m_width) - blit.m_dstX;
|
||||
uint32_t dstHeight = bx::uint32_min(dst.m_height, blit.m_dstY + blit.m_height) - blit.m_dstY;
|
||||
uint32_t width = bx::uint32_min(srcWidth, dstWidth);
|
||||
uint32_t height = bx::uint32_min(srcHeight, dstHeight);
|
||||
|
||||
RECT srcRect = { LONG(blit.m_srcX), LONG(blit.m_srcY), LONG(blit.m_srcX + width), LONG(blit.m_srcY + height) };
|
||||
RECT dstRect = { LONG(blit.m_dstX), LONG(blit.m_dstY), LONG(blit.m_dstX + width), LONG(blit.m_dstY + height) };
|
||||
|
||||
IDirect3DSurface9* srcSurface = src.getSurface(uint8_t(blit.m_srcZ), blit.m_srcMip);
|
||||
IDirect3DSurface9* dstSurface = dst.getSurface(uint8_t(blit.m_dstZ), blit.m_dstMip);
|
||||
|
||||
// UpdateSurface (pool src: SYSTEMMEM, dst: DEFAULT)
|
||||
// s/d T RTT RT
|
||||
// T y y y
|
||||
// RTT - - -
|
||||
// RT - - -
|
||||
//
|
||||
// StretchRect (pool src and dst must be DEFAULT)
|
||||
// s/d T RTT RT
|
||||
// T - y y
|
||||
// RTT - y y
|
||||
// RT - y y
|
||||
//
|
||||
// GetRenderTargetData (dst must be SYSTEMMEM)
|
||||
|
||||
bool depth = bimg::isDepth(bimg::TextureFormat::Enum(src.m_textureFormat) );
|
||||
HRESULT hr = m_device->StretchRect(srcSurface
|
||||
, depth ? NULL : &srcRect
|
||||
, dstSurface
|
||||
, depth ? NULL : &dstRect
|
||||
, D3DTEXF_NONE
|
||||
);
|
||||
if (FAILED(hr) )
|
||||
{
|
||||
hr = m_device->GetRenderTargetData(srcSurface, dstSurface);
|
||||
BX_WARN(SUCCEEDED(hr), "StretchRect and GetRenderTargetData failed %x.", hr);
|
||||
}
|
||||
|
||||
srcSurface->Release();
|
||||
dstSurface->Release();
|
||||
}
|
||||
}
|
||||
|
||||
void RendererContextD3D9::submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter)
|
||||
{
|
||||
IDirect3DDevice9* device = m_device;
|
||||
@@ -3658,10 +3714,7 @@ namespace bgfx { namespace d3d9
|
||||
FrameBufferHandle fbh = { BGFX_CONFIG_MAX_FRAME_BUFFERS };
|
||||
uint32_t blendFactor = 0;
|
||||
|
||||
BlitKey blitKey;
|
||||
blitKey.decode(_render->m_blitKeys[0]);
|
||||
uint16_t numBlitItems = _render->m_numBlitItems;
|
||||
uint16_t blitItem = 0;
|
||||
BlitState bs(_render);
|
||||
|
||||
uint8_t primIndex;
|
||||
{
|
||||
@@ -3776,58 +3829,7 @@ namespace bgfx { namespace d3d9
|
||||
DX_CHECK(device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE) );
|
||||
DX_CHECK(device->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER) );
|
||||
|
||||
const uint8_t blitView = SortKey::decodeView(encodedKey);
|
||||
for (; blitItem < numBlitItems && blitKey.m_view <= blitView; blitItem++)
|
||||
{
|
||||
const BlitItem& blit = _render->m_blitItem[blitItem];
|
||||
blitKey.decode(_render->m_blitKeys[blitItem+1]);
|
||||
|
||||
const TextureD3D9& src = m_textures[blit.m_src.idx];
|
||||
const TextureD3D9& dst = m_textures[blit.m_dst.idx];
|
||||
|
||||
uint32_t srcWidth = bx::uint32_min(src.m_width, blit.m_srcX + blit.m_width) - blit.m_srcX;
|
||||
uint32_t srcHeight = bx::uint32_min(src.m_height, blit.m_srcY + blit.m_height) - blit.m_srcY;
|
||||
uint32_t dstWidth = bx::uint32_min(dst.m_width, blit.m_dstX + blit.m_width) - blit.m_dstX;
|
||||
uint32_t dstHeight = bx::uint32_min(dst.m_height, blit.m_dstY + blit.m_height) - blit.m_dstY;
|
||||
uint32_t width = bx::uint32_min(srcWidth, dstWidth);
|
||||
uint32_t height = bx::uint32_min(srcHeight, dstHeight);
|
||||
|
||||
RECT srcRect = { LONG(blit.m_srcX), LONG(blit.m_srcY), LONG(blit.m_srcX + width), LONG(blit.m_srcY + height) };
|
||||
RECT dstRect = { LONG(blit.m_dstX), LONG(blit.m_dstY), LONG(blit.m_dstX + width), LONG(blit.m_dstY + height) };
|
||||
|
||||
IDirect3DSurface9* srcSurface = src.getSurface(uint8_t(blit.m_srcZ), blit.m_srcMip);
|
||||
IDirect3DSurface9* dstSurface = dst.getSurface(uint8_t(blit.m_dstZ), blit.m_dstMip);
|
||||
|
||||
// UpdateSurface (pool src: SYSTEMMEM, dst: DEFAULT)
|
||||
// s/d T RTT RT
|
||||
// T y y y
|
||||
// RTT - - -
|
||||
// RT - - -
|
||||
//
|
||||
// StretchRect (pool src and dst must be DEFAULT)
|
||||
// s/d T RTT RT
|
||||
// T - y y
|
||||
// RTT - y y
|
||||
// RT - y y
|
||||
//
|
||||
// GetRenderTargetData (dst must be SYSTEMMEM)
|
||||
|
||||
bool depth = bimg::isDepth(bimg::TextureFormat::Enum(src.m_textureFormat) );
|
||||
HRESULT hr = m_device->StretchRect(srcSurface
|
||||
, depth ? NULL : &srcRect
|
||||
, dstSurface
|
||||
, depth ? NULL : &dstRect
|
||||
, D3DTEXF_NONE
|
||||
);
|
||||
if (FAILED(hr) )
|
||||
{
|
||||
hr = m_device->GetRenderTargetData(srcSurface, dstSurface);
|
||||
BX_WARN(SUCCEEDED(hr), "StretchRect and GetRenderTargetData failed %x.", hr);
|
||||
}
|
||||
|
||||
srcSurface->Release();
|
||||
dstSurface->Release();
|
||||
}
|
||||
submitBlit(bs, view);
|
||||
}
|
||||
|
||||
uint16_t scissor = draw.m_scissor;
|
||||
@@ -4268,6 +4270,8 @@ namespace bgfx { namespace d3d9
|
||||
}
|
||||
}
|
||||
|
||||
submitBlit(bs, BGFX_CONFIG_MAX_VIEWS);
|
||||
|
||||
if (0 < _render->m_num)
|
||||
{
|
||||
if (0 != (m_resolution.m_flags & BGFX_RESET_FLUSH_AFTER_RENDER) )
|
||||
|
||||
@@ -2120,6 +2120,8 @@ VK_IMPORT_DEVICE
|
||||
BX_UNUSED(_handle);
|
||||
}
|
||||
|
||||
void submitBlit(BlitState& _bs, uint16_t _view);
|
||||
|
||||
void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) BX_OVERRIDE;
|
||||
|
||||
void blitSetup(TextVideoMemBlitter& /*_blitter*/) BX_OVERRIDE
|
||||
@@ -3610,6 +3612,11 @@ VK_DESTROY
|
||||
{
|
||||
}
|
||||
|
||||
void RendererContextVK::submitBlit(BlitState& _bs, uint16_t _view)
|
||||
{
|
||||
BX_UNUSED(_bs, _view);
|
||||
}
|
||||
|
||||
void RendererContextVK::submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter)
|
||||
{
|
||||
BX_UNUSED(_render, _clearQuad, _textVideoMemBlitter);
|
||||
@@ -3659,10 +3666,7 @@ VK_DESTROY
|
||||
uint16_t view = UINT16_MAX;
|
||||
FrameBufferHandle fbh = { BGFX_CONFIG_MAX_FRAME_BUFFERS };
|
||||
|
||||
BlitKey blitKey;
|
||||
blitKey.decode(_render->m_blitKeys[0]);
|
||||
uint16_t numBlitItems = _render->m_numBlitItems;
|
||||
uint16_t blitItem = 0;
|
||||
BlitState bs(_render);
|
||||
|
||||
uint32_t blendFactor = 0;
|
||||
|
||||
@@ -3822,77 +3826,7 @@ BX_UNUSED(currentSamplerStateIdx);
|
||||
|
||||
prim = s_primInfo[BX_COUNTOF(s_primName)]; // Force primitive type update.
|
||||
|
||||
const uint8_t blitView = SortKey::decodeView(encodedKey);
|
||||
for (; blitItem < numBlitItems && blitKey.m_view <= blitView; blitItem++)
|
||||
{
|
||||
const BlitItem& blit = _render->m_blitItem[blitItem];
|
||||
blitKey.decode(_render->m_blitKeys[blitItem+1]);
|
||||
BX_UNUSED(blit);
|
||||
|
||||
// const TextureD3D12& src = m_textures[blit.m_src.idx];
|
||||
// const TextureD3D12& dst = m_textures[blit.m_dst.idx];
|
||||
//
|
||||
// uint32_t srcWidth = bx::uint32_min(src.m_width, blit.m_srcX + blit.m_width) - blit.m_srcX;
|
||||
// uint32_t srcHeight = bx::uint32_min(src.m_height, blit.m_srcY + blit.m_height) - blit.m_srcY;
|
||||
// uint32_t srcDepth = bx::uint32_min(src.m_depth, blit.m_srcZ + blit.m_depth) - blit.m_srcZ;
|
||||
// uint32_t dstWidth = bx::uint32_min(dst.m_width, blit.m_dstX + blit.m_width) - blit.m_dstX;
|
||||
// uint32_t dstHeight = bx::uint32_min(dst.m_height, blit.m_dstY + blit.m_height) - blit.m_dstY;
|
||||
// uint32_t dstDepth = bx::uint32_min(dst.m_depth, blit.m_dstZ + blit.m_depth) - blit.m_dstZ;
|
||||
// uint32_t width = bx::uint32_min(srcWidth, dstWidth);
|
||||
// uint32_t height = bx::uint32_min(srcHeight, dstHeight);
|
||||
// uint32_t depth = bx::uint32_min(srcDepth, dstDepth);
|
||||
//
|
||||
// if (TextureD3D12::Texture3D == src.m_type)
|
||||
// {
|
||||
// D3D12_BOX box;
|
||||
// box.left = blit.m_srcX;
|
||||
// box.top = blit.m_srcY;
|
||||
// box.front = blit.m_srcZ;
|
||||
// box.right = blit.m_srcX + width;
|
||||
// box.bottom = blit.m_srcY + height;;
|
||||
// box.back = blit.m_srcZ + bx::uint32_imax(1, depth);
|
||||
//
|
||||
// D3D12_TEXTURE_COPY_LOCATION dstLocation = { dst.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, {{ 0 }} };
|
||||
// D3D12_TEXTURE_COPY_LOCATION srcLocation = { src.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, {{ 0 }} };
|
||||
// m_commandList->CopyTextureRegion(&dstLocation
|
||||
// , blit.m_dstX
|
||||
// , blit.m_dstY
|
||||
// , blit.m_dstZ
|
||||
// , &srcLocation
|
||||
// , &box
|
||||
// );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// D3D12_BOX box;
|
||||
// box.left = blit.m_srcX;
|
||||
// box.top = blit.m_srcY;
|
||||
// box.front = 0;
|
||||
// box.right = blit.m_srcX + width;
|
||||
// box.bottom = blit.m_srcY + height;;
|
||||
// box.back = 1;
|
||||
//
|
||||
// const uint32_t srcZ = TextureD3D12::TextureCube == src.m_type
|
||||
// ? blit.m_srcZ
|
||||
// : 0
|
||||
// ;
|
||||
// const uint32_t dstZ = TextureD3D12::TextureCube == dst.m_type
|
||||
// ? blit.m_dstZ
|
||||
// : 0
|
||||
// ;
|
||||
//
|
||||
// D3D12_TEXTURE_COPY_LOCATION dstLocation = { dst.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, {{ dstZ*dst.m_numMips+blit.m_dstMip }} };
|
||||
// D3D12_TEXTURE_COPY_LOCATION srcLocation = { src.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, {{ srcZ*src.m_numMips+blit.m_srcMip }} };
|
||||
// bool depthStencil = isDepth(TextureFormat::Enum(src.m_textureFormat) );
|
||||
// m_commandList->CopyTextureRegion(&dstLocation
|
||||
// , blit.m_dstX
|
||||
// , blit.m_dstY
|
||||
// , 0
|
||||
// , &srcLocation
|
||||
// , depthStencil ? NULL : &box
|
||||
// );
|
||||
// }
|
||||
}
|
||||
submitBlit(bs, view);
|
||||
}
|
||||
|
||||
if (isCompute)
|
||||
@@ -4400,6 +4334,8 @@ BX_UNUSED(currentSamplerStateIdx);
|
||||
}
|
||||
}
|
||||
|
||||
submitBlit(bs, BGFX_CONFIG_MAX_VIEWS);
|
||||
|
||||
// m_batch.end(m_commandList);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user