mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 10:35:43 -05:00
D3D9: Fixed volume texture update.
This commit is contained in:
parent
0c0542b2e6
commit
76ad2441b0
12 changed files with 85 additions and 151 deletions
|
@ -176,17 +176,17 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
|
||||
if (texture3DSupported)
|
||||
{
|
||||
if (0 != (BGFX_CAPS_FORMAT_TEXTURE_COLOR & caps->formats[bgfx::TextureFormat::R8]) )
|
||||
if (0 != (BGFX_CAPS_FORMAT_TEXTURE_2D & caps->formats[bgfx::TextureFormat::R8]) )
|
||||
{
|
||||
textures3d[numTextures3d++] = bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R8, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem8);
|
||||
}
|
||||
|
||||
if (0 != (BGFX_CAPS_FORMAT_TEXTURE_COLOR & caps->formats[bgfx::TextureFormat::R16F]) )
|
||||
if (0 != (BGFX_CAPS_FORMAT_TEXTURE_2D & caps->formats[bgfx::TextureFormat::R16F]) )
|
||||
{
|
||||
textures3d[numTextures3d++] = bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R16F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem16f);
|
||||
}
|
||||
|
||||
if (0 != (BGFX_CAPS_FORMAT_TEXTURE_COLOR & caps->formats[bgfx::TextureFormat::R32F]) )
|
||||
if (0 != (BGFX_CAPS_FORMAT_TEXTURE_2D & caps->formats[bgfx::TextureFormat::R32F]) )
|
||||
{
|
||||
textures3d[numTextures3d++] = bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R32F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem32f);
|
||||
}
|
||||
|
|
|
@ -471,10 +471,10 @@ namespace bgfx
|
|||
|
||||
/// Supported texture formats.
|
||||
/// - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - not supported
|
||||
/// - `BGFX_CAPS_FORMAT_TEXTURE_COLOR` - supported
|
||||
/// - `BGFX_CAPS_FORMAT_TEXTURE_EMULATED` - emulated
|
||||
/// - `BGFX_CAPS_FORMAT_TEXTURE_2D` - supported
|
||||
/// - `BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED` - emulated
|
||||
/// - `BGFX_CAPS_FORMAT_TEXTURE_VERTEX` - supported vertex texture
|
||||
uint8_t formats[TextureFormat::Count];
|
||||
uint16_t formats[TextureFormat::Count];
|
||||
};
|
||||
|
||||
/// Transient index buffer.
|
||||
|
@ -1448,7 +1448,7 @@ namespace bgfx
|
|||
///
|
||||
/// @attention C99 equivalent is `bgfx_create_frame_buffer_from_handles`.
|
||||
///
|
||||
FrameBufferHandle createFrameBuffer(uint8_t _num, TextureHandle* _handles, bool _destroyTextures = false);
|
||||
FrameBufferHandle createFrameBuffer(uint8_t _num, const TextureHandle* _handles, bool _destroyTextures = false);
|
||||
|
||||
/// Create frame buffer for multiple window rendering.
|
||||
///
|
||||
|
|
|
@ -372,15 +372,15 @@
|
|||
#define BGFX_CAPS_TEXTURE_READ_BACK UINT64_C(0x0000000000020000) //!< Read-back texture is supported.
|
||||
|
||||
///
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_NONE UINT8_C(0x00) //!< Texture format is not supported.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_COLOR UINT8_C(0x01) //!< Texture format is supported.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_COLOR_SRGB UINT8_C(0x02) //!< Texture as sRGB format is supported.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_EMULATED UINT8_C(0x04) //!< Texture format is emulated.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_VERTEX UINT8_C(0x08) //!< Texture format can be used from vertex shader.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_IMAGE UINT8_C(0x10) //!< Texture format can be used as image from compute shader.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER UINT8_C(0x20) //!< Texture format can be used as frame buffer.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA UINT8_C(0x40) //!< Texture format can be used as MSAA frame buffer.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_MSAA UINT8_C(0x80) //!< Texture can be sampled as MSAA.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_NONE UINT16_C(0x0000) //!< Texture format is not supported.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_2D UINT16_C(0x0001) //!< Texture format is supported.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB UINT16_C(0x0002) //!< Texture as sRGB format is supported.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED UINT16_C(0x0004) //!< Texture format is emulated.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_VERTEX UINT16_C(0x0008) //!< Texture format can be used from vertex shader.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_IMAGE UINT16_C(0x0010) //!< Texture format can be used as image from compute shader.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER UINT16_C(0x0020) //!< Texture format can be used as frame buffer.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA UINT16_C(0x0040) //!< Texture format can be used as MSAA frame buffer.
|
||||
#define BGFX_CAPS_FORMAT_TEXTURE_MSAA UINT16_C(0x0080) //!< Texture can be sampled as MSAA.
|
||||
|
||||
///
|
||||
#define BGFX_VIEW_NONE UINT8_C(0x00) //!<
|
||||
|
|
|
@ -337,7 +337,7 @@ typedef struct bgfx_caps
|
|||
uint16_t deviceId;
|
||||
bgfx_caps_gpu_t gpu[4];
|
||||
|
||||
uint8_t formats[BGFX_TEXTURE_FORMAT_COUNT];
|
||||
uint16_t formats[BGFX_TEXTURE_FORMAT_COUNT];
|
||||
|
||||
} bgfx_caps_t;
|
||||
|
||||
|
@ -624,7 +624,7 @@ BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer(uint16_t _width,
|
|||
BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_scaled(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint32_t _textureFlags);
|
||||
|
||||
/**/
|
||||
BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, bgfx_texture_handle_t* _handles, bool _destroyTextures);
|
||||
BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, const bgfx_texture_handle_t* _handles, bool _destroyTextures);
|
||||
|
||||
/**/
|
||||
BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_nwh(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _depthFormat);
|
||||
|
|
16
src/bgfx.cpp
16
src/bgfx.cpp
|
@ -1011,10 +1011,10 @@ namespace bgfx
|
|||
if (TextureFormat::Unknown != ii
|
||||
&& TextureFormat::UnknownDepth != ii)
|
||||
{
|
||||
uint8_t flags = g_caps.formats[ii];
|
||||
uint16_t flags = g_caps.formats[ii];
|
||||
BX_TRACE("\t[%c%c%c%c%c%c%c] %s"
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_COLOR ? 'x' : flags&BGFX_CAPS_FORMAT_TEXTURE_EMULATED ? '*' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_COLOR_SRGB ? 'l' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_2D ? 'x' : flags&BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED ? '*' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB ? 'l' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_VERTEX ? 'v' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_IMAGE ? 'i' : ' '
|
||||
, flags&BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER ? 'f' : ' '
|
||||
|
@ -1135,9 +1135,9 @@ namespace bgfx
|
|||
|
||||
for (uint32_t ii = 0; ii < BX_COUNTOF(s_emulatedFormats); ++ii)
|
||||
{
|
||||
if (0 == (g_caps.formats[s_emulatedFormats[ii] ] & BGFX_CAPS_FORMAT_TEXTURE_COLOR) )
|
||||
if (0 == (g_caps.formats[s_emulatedFormats[ii] ] & BGFX_CAPS_FORMAT_TEXTURE_2D) )
|
||||
{
|
||||
g_caps.formats[s_emulatedFormats[ii] ] |= BGFX_CAPS_FORMAT_TEXTURE_EMULATED;
|
||||
g_caps.formats[s_emulatedFormats[ii] ] |= BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2946,7 +2946,7 @@ again:
|
|||
return createFrameBuffer(1, &th, true);
|
||||
}
|
||||
|
||||
FrameBufferHandle createFrameBuffer(uint8_t _num, TextureHandle* _handles, bool _destroyTextures)
|
||||
FrameBufferHandle createFrameBuffer(uint8_t _num, const TextureHandle* _handles, bool _destroyTextures)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
BX_CHECK(_num != 0, "Number of frame buffer attachments can't be 0.");
|
||||
|
@ -3872,10 +3872,10 @@ BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_scaled(bgfx_backb
|
|||
return handle.c;
|
||||
}
|
||||
|
||||
BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, bgfx_texture_handle_t* _handles, bool _destroyTextures)
|
||||
BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, const bgfx_texture_handle_t* _handles, bool _destroyTextures)
|
||||
{
|
||||
union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle;
|
||||
handle.cpp = bgfx::createFrameBuffer(_num, (bgfx::TextureHandle*)_handles, _destroyTextures);
|
||||
handle.cpp = bgfx::createFrameBuffer(_num, (const bgfx::TextureHandle*)_handles, _destroyTextures);
|
||||
return handle.c;
|
||||
}
|
||||
|
||||
|
|
31
src/bgfx_p.h
31
src/bgfx_p.h
|
@ -3076,8 +3076,37 @@ namespace bgfx
|
|||
cmdbuf.write(_mem);
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(FrameBufferHandle createFrameBuffer(uint8_t _num, TextureHandle* _handles, bool _destroyTextures) )
|
||||
bool checkFrameBuffer(uint8_t _num, const TextureHandle* _handles) const
|
||||
{
|
||||
uint8_t color = 0;
|
||||
uint8_t depth = 0;
|
||||
|
||||
for (uint32_t ii = 0; ii < _num; ++ii)
|
||||
{
|
||||
TextureHandle texHandle = _handles[ii];
|
||||
if (isDepth(TextureFormat::Enum(m_textureRef[texHandle.idx].m_format)))
|
||||
{
|
||||
++depth;
|
||||
}
|
||||
else
|
||||
{
|
||||
++color;
|
||||
}
|
||||
}
|
||||
|
||||
return color <= g_caps.maxFBAttachments
|
||||
&& depth <= 1
|
||||
;
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(FrameBufferHandle createFrameBuffer(uint8_t _num, const TextureHandle* _handles, bool _destroyTextures) )
|
||||
{
|
||||
BX_CHECK(checkFrameBuffer(_num, _handles)
|
||||
, "Too many frame buffer attachments (num attachments: %d, max color attachments %d)!"
|
||||
, _num
|
||||
, g_caps.maxFBAttachments
|
||||
);
|
||||
|
||||
FrameBufferHandle handle = { m_frameBufferHandle.alloc() };
|
||||
BX_WARN(isValid(handle), "Failed to allocate frame buffer handle.");
|
||||
|
||||
|
|
|
@ -1277,7 +1277,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||
| D3D11_FORMAT_SUPPORT_TEXTURE3D
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_COLOR
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
|
@ -1362,7 +1362,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||
| D3D11_FORMAT_SUPPORT_TEXTURE3D
|
||||
| D3D11_FORMAT_SUPPORT_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_COLOR_SRGB
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
}
|
||||
|
|
|
@ -910,7 +910,7 @@ namespace bgfx { namespace d3d12
|
|||
| D3D12_FORMAT_SUPPORT1_TEXTURE3D
|
||||
| D3D12_FORMAT_SUPPORT1_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_COLOR
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
|
@ -995,7 +995,7 @@ namespace bgfx { namespace d3d12
|
|||
| D3D12_FORMAT_SUPPORT1_TEXTURE3D
|
||||
| D3D12_FORMAT_SUPPORT1_TEXTURECUBE
|
||||
) )
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_COLOR_SRGB
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
}
|
||||
|
|
|
@ -582,14 +582,14 @@ namespace bgfx { namespace d3d9
|
|||
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
|
||||
{
|
||||
uint8_t support = 0;
|
||||
|
||||
|
||||
support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
|
||||
, m_deviceType
|
||||
, adapterFormat
|
||||
, 0
|
||||
, D3DRTYPE_TEXTURE
|
||||
, s_textureFormat[ii].m_fmt
|
||||
) ) ? BGFX_CAPS_FORMAT_TEXTURE_COLOR : BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||
) ) ? BGFX_CAPS_FORMAT_TEXTURE_2D : BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||
|
||||
support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
|
||||
, m_deviceType
|
||||
|
@ -597,7 +597,7 @@ namespace bgfx { namespace d3d9
|
|||
, D3DUSAGE_QUERY_SRGBREAD
|
||||
, D3DRTYPE_TEXTURE
|
||||
, s_textureFormat[ii].m_fmt
|
||||
) ) ? BGFX_CAPS_FORMAT_TEXTURE_COLOR_SRGB : BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||
) ) ? BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB : BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||
|
||||
support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
|
||||
, m_deviceType
|
||||
|
@ -2426,37 +2426,8 @@ namespace bgfx { namespace d3d9
|
|||
}
|
||||
else
|
||||
{
|
||||
const ImageBlockInfo& blockInfo = getBlockInfo(fmt);
|
||||
const uint32_t blockWidth = blockInfo.blockWidth;
|
||||
const uint32_t blockHeight = blockInfo.blockHeight;
|
||||
|
||||
for (uint8_t lod = 0, num = _numMips; lod < num; ++lod)
|
||||
{
|
||||
if ( (m_width >>lod) < blockWidth
|
||||
|| (m_height>>lod) < blockHeight)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t mipWidth = bx::uint32_max(blockWidth, ( ( (m_width >>lod) + blockWidth - 1) / blockWidth )*blockWidth);
|
||||
uint32_t mipHeight = bx::uint32_max(blockHeight, ( ( (m_height>>lod) + blockHeight - 1) / blockHeight)*blockHeight);
|
||||
|
||||
IDirect3DSurface9* srcSurface;
|
||||
DX_CHECK(m_staging2d->GetSurfaceLevel(lod, &srcSurface) );
|
||||
IDirect3DSurface9* dstSurface = getSurface(0, lod);
|
||||
|
||||
RECT srcRect = { LONG(0), LONG(0), LONG(mipWidth), LONG(mipHeight) };
|
||||
POINT dstPoint = { LONG(0), LONG(0) };
|
||||
|
||||
DX_CHECK(device->UpdateSurface(srcSurface
|
||||
, &srcRect
|
||||
, dstSurface
|
||||
, &dstPoint
|
||||
) );
|
||||
|
||||
srcSurface->Release();
|
||||
dstSurface->Release();
|
||||
}
|
||||
DX_CHECK(m_staging2d->AddDirtyRect(NULL));
|
||||
DX_CHECK(device->UpdateTexture(m_staging2d, m_texture2d));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2468,7 +2439,7 @@ namespace bgfx { namespace d3d9
|
|||
);
|
||||
}
|
||||
|
||||
void TextureD3D9::createVolumeTexture(uint32_t _width, uint32_t _height, uint32_t _depth, uint32_t _numMips)
|
||||
void TextureD3D9::createVolumeTexture(uint32_t _width, uint32_t _height, uint32_t _depth, uint8_t _numMips)
|
||||
{
|
||||
m_type = Texture3D;
|
||||
const TextureFormat::Enum fmt = (TextureFormat::Enum)m_textureFormat;
|
||||
|
@ -2500,7 +2471,7 @@ namespace bgfx { namespace d3d9
|
|||
}
|
||||
else
|
||||
{
|
||||
DX_CHECK(m_texture3d->AddDirtyBox(NULL) );
|
||||
DX_CHECK(m_staging3d->AddDirtyBox(NULL) );
|
||||
DX_CHECK(device->UpdateTexture(m_staging3d, m_texture3d) );
|
||||
}
|
||||
|
||||
|
@ -2513,7 +2484,7 @@ namespace bgfx { namespace d3d9
|
|||
);
|
||||
}
|
||||
|
||||
void TextureD3D9::createCubeTexture(uint32_t _edge, uint32_t _numMips)
|
||||
void TextureD3D9::createCubeTexture(uint32_t _width, uint8_t _numMips)
|
||||
{
|
||||
m_type = TextureCube;
|
||||
const TextureFormat::Enum fmt = (TextureFormat::Enum)m_textureFormat;
|
||||
|
@ -2532,7 +2503,7 @@ namespace bgfx { namespace d3d9
|
|||
}
|
||||
|
||||
IDirect3DDevice9* device = s_renderD3D9->m_device;
|
||||
DX_CHECK(device->CreateCubeTexture(_edge
|
||||
DX_CHECK(device->CreateCubeTexture(_width
|
||||
, _numMips
|
||||
, usage
|
||||
, s_textureFormat[fmt].m_fmt
|
||||
|
@ -2545,7 +2516,7 @@ namespace bgfx { namespace d3d9
|
|||
{
|
||||
if (NULL == m_staging)
|
||||
{
|
||||
DX_CHECK(device->CreateCubeTexture(_edge
|
||||
DX_CHECK(device->CreateCubeTexture(_width
|
||||
, _numMips
|
||||
, 0
|
||||
, s_textureFormat[fmt].m_fmt
|
||||
|
@ -2556,45 +2527,16 @@ namespace bgfx { namespace d3d9
|
|||
}
|
||||
else
|
||||
{
|
||||
const ImageBlockInfo& blockInfo = getBlockInfo(fmt);
|
||||
const uint32_t blockWidth = blockInfo.blockWidth;
|
||||
const uint32_t blockHeight = blockInfo.blockHeight;
|
||||
|
||||
for (uint8_t side = 0, numSides = 6; side < numSides; ++side)
|
||||
for (uint8_t ii = 0; ii < 6; ++ii)
|
||||
{
|
||||
for (uint8_t lod = 0, num = _numMips; lod < num; ++lod)
|
||||
{
|
||||
if ( (m_width >>lod) < blockWidth
|
||||
|| (m_height>>lod) < blockHeight)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t mipWidth = bx::uint32_max(blockWidth, ( ( (m_width >>lod) + blockWidth - 1) / blockWidth )*blockWidth);
|
||||
uint32_t mipHeight = bx::uint32_max(blockHeight, ( ( (m_height>>lod) + blockHeight - 1) / blockHeight)*blockHeight);
|
||||
|
||||
IDirect3DSurface9* srcSurface;
|
||||
DX_CHECK(m_stagingCube->GetCubeMapSurface(D3DCUBEMAP_FACES(side), lod, &srcSurface) );
|
||||
IDirect3DSurface9* dstSurface = getSurface(side, lod);
|
||||
|
||||
RECT srcRect = { LONG(0), LONG(0), LONG(mipWidth), LONG(mipHeight) };
|
||||
POINT dstPoint = { LONG(0), LONG(0) };
|
||||
|
||||
DX_CHECK(device->UpdateSurface(srcSurface
|
||||
, &srcRect
|
||||
, dstSurface
|
||||
, &dstPoint
|
||||
) );
|
||||
|
||||
srcSurface->Release();
|
||||
dstSurface->Release();
|
||||
}
|
||||
DX_CHECK(m_stagingCube->AddDirtyRect(D3DCUBEMAP_FACES(ii), NULL) );
|
||||
}
|
||||
DX_CHECK(device->UpdateTexture(m_stagingCube, m_textureCube) );
|
||||
}
|
||||
}
|
||||
|
||||
BGFX_FATAL(NULL != m_textureCube, Fatal::UnableToCreateTexture, "Failed to create cube texture (edge: %d, mips: %d, fmt: %s)."
|
||||
, _edge
|
||||
, _width
|
||||
, _numMips
|
||||
, getName(fmt)
|
||||
);
|
||||
|
@ -2668,65 +2610,28 @@ namespace bgfx { namespace d3d9
|
|||
|
||||
void TextureD3D9::unlock(uint8_t _side, uint8_t _lod)
|
||||
{
|
||||
IDirect3DDevice9* device = s_renderD3D9->m_device;
|
||||
|
||||
switch (m_type)
|
||||
{
|
||||
case Texture2D:
|
||||
{
|
||||
DX_CHECK(m_staging2d->UnlockRect(_lod) );
|
||||
|
||||
IDirect3DSurface9* srcSurface;
|
||||
DX_CHECK(m_staging2d->GetSurfaceLevel(0, &srcSurface) );
|
||||
IDirect3DSurface9* dstSurface = getSurface(0, _lod);
|
||||
|
||||
const ImageBlockInfo& blockInfo = getBlockInfo(TextureFormat::Enum(m_textureFormat) );
|
||||
uint32_t mipWidth = bx::uint32_max(blockInfo.blockWidth, m_width >>_lod);
|
||||
uint32_t mipHeight = bx::uint32_max(blockInfo.blockHeight, m_height>>_lod);
|
||||
|
||||
RECT srcRect = { LONG(0), LONG(0), LONG(mipWidth), LONG(mipHeight) };
|
||||
POINT dstPoint = { LONG(0), LONG(0) };
|
||||
|
||||
s_renderD3D9->m_device->UpdateSurface(srcSurface
|
||||
, &srcRect
|
||||
, dstSurface
|
||||
, &dstPoint
|
||||
);
|
||||
|
||||
srcSurface->Release();
|
||||
dstSurface->Release();
|
||||
DX_CHECK(device->UpdateTexture(m_staging2d, m_texture2d) );
|
||||
}
|
||||
return;
|
||||
|
||||
case Texture3D:
|
||||
{
|
||||
DX_CHECK(m_staging3d->UnlockBox(_lod) );
|
||||
DX_CHECK(m_texture3d->AddDirtyBox(NULL) );
|
||||
DX_CHECK(s_renderD3D9->m_device->UpdateTexture(m_staging3d, m_texture3d) );
|
||||
DX_CHECK(device->UpdateTexture(m_staging3d, m_texture3d) );
|
||||
}
|
||||
return;
|
||||
|
||||
case TextureCube:
|
||||
{
|
||||
DX_CHECK(m_stagingCube->UnlockRect(D3DCUBEMAP_FACES(_side), _lod) );
|
||||
|
||||
IDirect3DSurface9* srcSurface;
|
||||
DX_CHECK(m_stagingCube->GetCubeMapSurface(D3DCUBEMAP_FACES(_side), _lod, &srcSurface) );
|
||||
IDirect3DSurface9* dstSurface = getSurface(_side, _lod);
|
||||
|
||||
const ImageBlockInfo& blockInfo = getBlockInfo(TextureFormat::Enum(m_textureFormat) );
|
||||
uint32_t mipWidth = bx::uint32_max(blockInfo.blockWidth, m_width >>_lod);
|
||||
uint32_t mipHeight = bx::uint32_max(blockInfo.blockHeight, m_height>>_lod);
|
||||
|
||||
RECT srcRect = { LONG(0), LONG(0), LONG(mipWidth), LONG(mipHeight) };
|
||||
POINT dstPoint = { LONG(0), LONG(0) };
|
||||
|
||||
DX_CHECK(s_renderD3D9->m_device->UpdateSurface(srcSurface
|
||||
, &srcRect
|
||||
, dstSurface
|
||||
, &dstPoint
|
||||
) );
|
||||
|
||||
srcSurface->Release();
|
||||
dstSurface->Release();
|
||||
DX_CHECK(device->UpdateTexture(m_stagingCube, m_textureCube) );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -316,8 +316,8 @@ namespace bgfx { namespace d3d9
|
|||
}
|
||||
|
||||
void createTexture(uint32_t _width, uint32_t _height, uint8_t _numMips);
|
||||
void createVolumeTexture(uint32_t _width, uint32_t _height, uint32_t _depth, uint32_t _numMips);
|
||||
void createCubeTexture(uint32_t _edge, uint32_t _numMips);
|
||||
void createVolumeTexture(uint32_t _width, uint32_t _height, uint32_t _depth, uint8_t _numMips);
|
||||
void createCubeTexture(uint32_t _width, uint8_t _numMips);
|
||||
|
||||
uint8_t* lock(uint8_t _side, uint8_t _lod, uint32_t& _pitch, uint32_t& _slicePitch, const Rect* _rect = NULL);
|
||||
void unlock(uint8_t _side, uint8_t _lod);
|
||||
|
|
|
@ -1594,12 +1594,12 @@ namespace bgfx { namespace gl
|
|||
{
|
||||
uint8_t supported = 0;
|
||||
supported |= s_textureFormat[ii].m_supported
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_COLOR
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
supported |= isTextureFormatValid(TextureFormat::Enum(ii), true)
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_COLOR_SRGB
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
|
|
|
@ -433,12 +433,12 @@ namespace bgfx { namespace mtl
|
|||
uint8_t support = 0;
|
||||
|
||||
support |= MTLPixelFormatInvalid != s_textureFormat[ii].m_fmt
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_COLOR
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
support |= MTLPixelFormatInvalid != s_textureFormat[ii].m_fmtSrgb
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_COLOR_SRGB
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
|
|
Loading…
Reference in a new issue