summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/src/renderer_d3d9.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/src/renderer_d3d9.cpp')
-rw-r--r--3rdparty/bgfx/src/renderer_d3d9.cpp60
1 files changed, 32 insertions, 28 deletions
diff --git a/3rdparty/bgfx/src/renderer_d3d9.cpp b/3rdparty/bgfx/src/renderer_d3d9.cpp
index be388785ada..1b26f9a9193 100644
--- a/3rdparty/bgfx/src/renderer_d3d9.cpp
+++ b/3rdparty/bgfx/src/renderer_d3d9.cpp
@@ -578,11 +578,10 @@ namespace bgfx { namespace d3d9
| BGFX_CAPS_TEXTURE_READ_BACK
| (m_occlusionQuerySupport ? BGFX_CAPS_OCCLUSION_QUERY : 0)
);
- g_caps.maxTextureSize = uint16_t(bx::uint32_min(m_caps.MaxTextureWidth, m_caps.MaxTextureHeight) );
-// g_caps.maxVertexIndex = m_caps.MaxVertexIndex;
+ g_caps.limits.maxTextureSize = uint16_t(bx::uint32_min(m_caps.MaxTextureWidth, m_caps.MaxTextureHeight) );
m_caps.NumSimultaneousRTs = uint8_t(bx::uint32_min(m_caps.NumSimultaneousRTs, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
- g_caps.maxFBAttachments = uint8_t(m_caps.NumSimultaneousRTs);
+ g_caps.limits.maxFBAttachments = uint8_t(m_caps.NumSimultaneousRTs);
m_caps.MaxAnisotropy = bx::uint32_max(m_caps.MaxAnisotropy, 1);
@@ -988,27 +987,29 @@ namespace bgfx { namespace d3d9
m_updateTexture = NULL;
}
- void readTexture(TextureHandle _handle, void* _data) BX_OVERRIDE
+ void readTexture(TextureHandle _handle, void* _data, uint8_t _mip) BX_OVERRIDE
{
TextureD3D9& texture = m_textures[_handle.idx];
D3DLOCKED_RECT lockedRect;
- DX_CHECK(texture.m_texture2d->LockRect(0
+ DX_CHECK(texture.m_texture2d->LockRect(_mip
, &lockedRect
, NULL
, D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY
) );
- uint32_t srcPitch = lockedRect.Pitch;
- uint8_t* src = (uint8_t*)lockedRect.pBits;
+ uint32_t srcWidth = bx::uint32_max(1, texture.m_width >>_mip);
+ uint32_t srcHeight = bx::uint32_max(1, texture.m_height>>_mip);
+ uint32_t srcPitch = lockedRect.Pitch;
+ uint8_t* src = (uint8_t*)lockedRect.pBits;
const uint8_t bpp = getBitsPerPixel(TextureFormat::Enum(texture.m_textureFormat) );
uint8_t* dst = (uint8_t*)_data;
- uint32_t dstPitch = texture.m_width*bpp/8;
+ uint32_t dstPitch = srcWidth*bpp/8;
uint32_t pitch = bx::uint32_min(srcPitch, dstPitch);
- for (uint32_t yy = 0, height = texture.m_height; yy < height; ++yy)
+ for (uint32_t yy = 0, height = srcHeight; yy < height; ++yy)
{
memcpy(dst, src, pitch);
@@ -1016,7 +1017,7 @@ namespace bgfx { namespace d3d9
dst += dstPitch;
}
- DX_CHECK(texture.m_texture2d->UnlockRect(0) );
+ DX_CHECK(texture.m_texture2d->UnlockRect(_mip) );
}
void resizeTexture(TextureHandle _handle, uint16_t _width, uint16_t _height, uint8_t _numMips) BX_OVERRIDE
@@ -1113,6 +1114,7 @@ namespace bgfx { namespace d3d9
{
BX_FREE(g_allocator, m_uniforms[_handle.idx]);
m_uniforms[_handle.idx] = NULL;
+ m_uniformReg.remove(_handle);
}
void saveScreenShot(const char* _filePath) BX_OVERRIDE
@@ -1357,7 +1359,7 @@ namespace bgfx { namespace d3d9
if (!isValid(_fbh) )
{
DX_CHECK(m_device->SetRenderTarget(0, m_backBufferColor) );
- for (uint32_t ii = 1, num = g_caps.maxFBAttachments; ii < num; ++ii)
+ for (uint32_t ii = 1, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
{
DX_CHECK(m_device->SetRenderTarget(ii, NULL) );
}
@@ -1390,7 +1392,7 @@ namespace bgfx { namespace d3d9
}
}
- for (uint32_t ii = rtIdx, num = g_caps.maxFBAttachments; ii < num; ++ii)
+ for (uint32_t ii = rtIdx, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
{
DX_CHECK(m_device->SetRenderTarget(ii, NULL) );
}
@@ -1507,7 +1509,7 @@ namespace bgfx { namespace d3d9
}
DX_CHECK(m_device->SetRenderTarget(0, m_backBufferColor) );
- for (uint32_t ii = 1, num = g_caps.maxFBAttachments; ii < num; ++ii)
+ for (uint32_t ii = 1, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
{
DX_CHECK(m_device->SetRenderTarget(ii, NULL) );
}
@@ -2426,7 +2428,7 @@ namespace bgfx { namespace d3d9
else if (0 == (BGFX_UNIFORM_SAMPLERBIT & type) )
{
const UniformInfo* info = s_renderD3D9->m_uniformReg.find(name);
- BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
+ BX_WARN(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
if (NULL != info)
{
@@ -4020,22 +4022,24 @@ namespace bgfx { namespace d3d9
}
if (programChanged
- || currentState.m_vertexBuffer.idx != draw.m_vertexBuffer.idx
+ || currentState.m_streamMask != draw.m_streamMask
+ || currentState.m_stream[0].m_handle.idx != draw.m_stream[0].m_handle.idx
|| currentState.m_instanceDataBuffer.idx != draw.m_instanceDataBuffer.idx
- || currentState.m_instanceDataOffset != draw.m_instanceDataOffset
- || currentState.m_instanceDataStride != draw.m_instanceDataStride)
+ || currentState.m_instanceDataOffset != draw.m_instanceDataOffset
+ || currentState.m_instanceDataStride != draw.m_instanceDataStride)
{
- currentState.m_vertexBuffer = draw.m_vertexBuffer;
+ currentState.m_streamMask = draw.m_streamMask;
+ currentState.m_stream[0].m_handle = draw.m_stream[0].m_handle;
currentState.m_instanceDataBuffer.idx = draw.m_instanceDataBuffer.idx;
- currentState.m_instanceDataOffset = draw.m_instanceDataOffset;
- currentState.m_instanceDataStride = draw.m_instanceDataStride;
+ currentState.m_instanceDataOffset = draw.m_instanceDataOffset;
+ currentState.m_instanceDataStride = draw.m_instanceDataStride;
- uint16_t handle = draw.m_vertexBuffer.idx;
+ uint16_t handle = draw.m_stream[0].m_handle.idx;
if (invalidHandle != handle)
{
const VertexBufferD3D9& vb = m_vertexBuffers[handle];
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
+ uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[0].m_decl.idx : vb.m_decl.idx;
const VertexDeclD3D9& vertexDecl = m_vertexDecls[decl];
DX_CHECK(device->SetStreamSource(0, vb.m_ptr, 0, vertexDecl.m_decl.m_stride) );
@@ -4081,13 +4085,13 @@ namespace bgfx { namespace d3d9
}
}
- if (isValid(currentState.m_vertexBuffer) )
+ if (0 != currentState.m_streamMask)
{
uint32_t numVertices = draw.m_numVertices;
if (UINT32_MAX == numVertices)
{
- const VertexBufferD3D9& vb = m_vertexBuffers[currentState.m_vertexBuffer.idx];
- uint16_t decl = !isValid(vb.m_decl) ? draw.m_vertexDecl.idx : vb.m_decl.idx;
+ const VertexBufferD3D9& vb = m_vertexBuffers[currentState.m_stream[0].m_handle.idx];
+ uint16_t decl = !isValid(vb.m_decl) ? draw.m_stream[0].m_decl.idx : vb.m_decl.idx;
const VertexDeclD3D9& vertexDecl = m_vertexDecls[decl];
numVertices = vb.m_size/vertexDecl.m_decl.m_stride;
}
@@ -4114,7 +4118,7 @@ namespace bgfx { namespace d3d9
numPrimsRendered = numPrimsSubmitted*draw.m_numInstances;
DX_CHECK(device->DrawIndexedPrimitive(prim.m_type
- , draw.m_startVertex
+ , draw.m_stream[0].m_startVertex
, 0
, numVertices
, 0
@@ -4129,7 +4133,7 @@ namespace bgfx { namespace d3d9
numPrimsRendered = numPrimsSubmitted*draw.m_numInstances;
DX_CHECK(device->DrawIndexedPrimitive(prim.m_type
- , draw.m_startVertex
+ , draw.m_stream[0].m_startVertex
, 0
, numVertices
, draw.m_startIndex
@@ -4144,7 +4148,7 @@ namespace bgfx { namespace d3d9
numPrimsRendered = numPrimsSubmitted*draw.m_numInstances;
DX_CHECK(device->DrawPrimitive(prim.m_type
- , draw.m_startVertex
+ , draw.m_stream[0].m_startVertex
, numPrimsSubmitted
) );
}