mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 00:58:30 -05:00
Pass texture flags to render target.
This commit is contained in:
parent
c4d7658fd9
commit
981dcc21be
8 changed files with 34 additions and 22 deletions
|
@ -368,7 +368,7 @@ namespace bgfx
|
|||
void destroyTexture(TextureHandle _handle);
|
||||
|
||||
///
|
||||
RenderTargetHandle createRenderTarget(uint16_t _width, uint16_t _height, uint32_t _flags = BGFX_RENDER_TARGET_COLOR_RGBA);
|
||||
RenderTargetHandle createRenderTarget(uint16_t _width, uint16_t _height, uint32_t _flags = BGFX_RENDER_TARGET_COLOR_RGBA, uint32_t _textureFlags = BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
|
||||
|
||||
///
|
||||
void destroyRenderTarget(RenderTargetHandle _handle);
|
||||
|
|
|
@ -809,9 +809,9 @@ namespace bgfx
|
|||
s_ctx.destroyTexture(_handle);
|
||||
}
|
||||
|
||||
RenderTargetHandle createRenderTarget(uint16_t _width, uint16_t _height, uint32_t _flags)
|
||||
RenderTargetHandle createRenderTarget(uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags)
|
||||
{
|
||||
return s_ctx.createRenderTarget(_width, _height, _flags);
|
||||
return s_ctx.createRenderTarget(_width, _height, _flags, _textureFlags);
|
||||
}
|
||||
|
||||
void destroyRenderTarget(RenderTargetHandle _handle)
|
||||
|
|
10
src/bgfx_p.h
10
src/bgfx_p.h
|
@ -1668,7 +1668,7 @@ namespace bgfx
|
|||
m_submit->free(_handle);
|
||||
}
|
||||
|
||||
RenderTargetHandle createRenderTarget(uint16_t _width, uint16_t _height, uint32_t _flags)
|
||||
RenderTargetHandle createRenderTarget(uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags)
|
||||
{
|
||||
RenderTargetHandle handle = { m_renderTargetHandle.alloc() };
|
||||
|
||||
|
@ -1677,6 +1677,7 @@ namespace bgfx
|
|||
cmdbuf.write(_width);
|
||||
cmdbuf.write(_height);
|
||||
cmdbuf.write(_flags);
|
||||
cmdbuf.write(_textureFlags);
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
@ -1930,7 +1931,7 @@ namespace bgfx
|
|||
void rendererDestroyMaterial(FragmentShaderHandle _handle);
|
||||
void rendererCreateTexture(TextureHandle _handle, Memory* _mem, uint32_t _flags);
|
||||
void rendererDestroyTexture(TextureHandle _handle);
|
||||
void rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags);
|
||||
void rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags);
|
||||
void rendererDestroyRenderTarget(RenderTargetHandle _handle);
|
||||
void rendererCreateUniform(UniformHandle _handle, ConstantType::Enum _type, uint16_t _num, const char* _name);
|
||||
void rendererDestroyUniform(UniformHandle _handle);
|
||||
|
@ -2212,7 +2213,10 @@ namespace bgfx
|
|||
uint32_t flags;
|
||||
_cmdbuf.read(flags);
|
||||
|
||||
rendererCreateRenderTarget(handle, width, height, flags);
|
||||
uint32_t textureFlags;
|
||||
_cmdbuf.read(textureFlags);
|
||||
|
||||
rendererCreateRenderTarget(handle, width, height, flags, textureFlags);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -1297,11 +1297,13 @@ namespace bgfx
|
|||
DX_CHECK(s_renderCtx.m_device->SetTexture(_stage, m_ptr) );
|
||||
}
|
||||
|
||||
void RenderTarget::create(uint16_t _width, uint16_t _height, uint32_t _flags)
|
||||
void RenderTarget::create(uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags)
|
||||
{
|
||||
m_width = _width;
|
||||
m_height = _height;
|
||||
m_flags = _flags;
|
||||
m_minFilter = s_textureFilter[(_textureFlags&BGFX_TEXTURE_MIN_MASK)>>BGFX_TEXTURE_MIN_SHIFT];
|
||||
m_magFilter = s_textureFilter[(_textureFlags&BGFX_TEXTURE_MAG_MASK)>>BGFX_TEXTURE_MAG_SHIFT];
|
||||
|
||||
createTextures();
|
||||
}
|
||||
|
@ -1434,8 +1436,8 @@ namespace bgfx
|
|||
|
||||
void RenderTarget::commit(uint8_t _stage)
|
||||
{
|
||||
DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_MINFILTER, D3DTEXF_LINEAR) );
|
||||
DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR) );
|
||||
DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_MINFILTER, m_minFilter) );
|
||||
DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_MAGFILTER, m_magFilter) );
|
||||
DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_MIPFILTER, D3DTEXF_POINT) );
|
||||
DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP) );
|
||||
DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP) );
|
||||
|
@ -1694,9 +1696,9 @@ namespace bgfx
|
|||
s_renderCtx.m_textures[_handle.idx].destroy();
|
||||
}
|
||||
|
||||
void Context::rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags)
|
||||
void Context::rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags)
|
||||
{
|
||||
s_renderCtx.m_renderTargets[_handle.idx].create(_width, _height, _flags);
|
||||
s_renderCtx.m_renderTargets[_handle.idx].create(_width, _height, _flags, _textureFlags);
|
||||
}
|
||||
|
||||
void Context::rendererDestroyRenderTarget(RenderTargetHandle _handle)
|
||||
|
|
|
@ -316,6 +316,8 @@ namespace bgfx
|
|||
, m_color(NULL)
|
||||
, m_depthTexture(NULL)
|
||||
, m_depth(NULL)
|
||||
, m_minFilter(D3DTEXF_LINEAR)
|
||||
, m_magFilter(D3DTEXF_LINEAR)
|
||||
, m_width(0)
|
||||
, m_height(0)
|
||||
, m_flags(0)
|
||||
|
@ -323,7 +325,7 @@ namespace bgfx
|
|||
{
|
||||
}
|
||||
|
||||
void create(uint16_t _width, uint16_t _height, uint32_t _flags);
|
||||
void create(uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags);
|
||||
void createTextures();
|
||||
void destroyTextures();
|
||||
|
||||
|
@ -352,6 +354,8 @@ namespace bgfx
|
|||
IDirect3DSurface9* m_color;
|
||||
IDirect3DTexture9* m_depthTexture;
|
||||
IDirect3DSurface9* m_depth;
|
||||
D3DTEXTUREFILTERTYPE m_minFilter;
|
||||
D3DTEXTUREFILTERTYPE m_magFilter;
|
||||
uint16_t m_width;
|
||||
uint16_t m_height;
|
||||
uint32_t m_flags;
|
||||
|
|
|
@ -1285,7 +1285,7 @@ namespace bgfx
|
|||
GL_CHECK(glBindTexture(m_target, 0) );
|
||||
}
|
||||
|
||||
void Texture::createColor(uint32_t _width, uint32_t _height)
|
||||
void Texture::createColor(uint32_t _width, uint32_t _height, GLenum _min, GLenum _mag)
|
||||
{
|
||||
GLenum internalFormat = /*_fp ? GL_RGBA16F_ARB :*/ GL_RGBA;
|
||||
GLenum type = /*_fp ? GL_HALF_FLOAT_ARB :*/ GL_UNSIGNED_BYTE;
|
||||
|
@ -1294,8 +1294,8 @@ namespace bgfx
|
|||
GL_CHECK(glGenTextures(1, &m_id) );
|
||||
BX_CHECK(0 != m_id, "Failed to generate texture id.");
|
||||
GL_CHECK(glBindTexture(m_target, m_id) );
|
||||
GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR) );
|
||||
GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR) );
|
||||
GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, _min) );
|
||||
GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_MAG_FILTER, _mag) );
|
||||
GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) );
|
||||
GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) );
|
||||
|
||||
|
@ -1352,7 +1352,7 @@ namespace bgfx
|
|||
}
|
||||
}
|
||||
|
||||
void RenderTarget::create(uint16_t _width, uint16_t _height, uint32_t _flags)
|
||||
void RenderTarget::create(uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags)
|
||||
{
|
||||
BX_TRACE("Create render target %dx%d 0x%02x", _width, _height, _flags);
|
||||
|
||||
|
@ -1362,10 +1362,12 @@ namespace bgfx
|
|||
// m_msaa = s_msaa[(m_flags&BGFX_RENDER_TARGET_MSAA_MASK)>>BGFX_RENDER_TARGET_MSAA_SHIFT];
|
||||
uint32_t colorFormat = (_flags&BGFX_RENDER_TARGET_COLOR_MASK)>>BGFX_RENDER_TARGET_COLOR_SHIFT;
|
||||
uint32_t depthFormat = (_flags&BGFX_RENDER_TARGET_DEPTH_MASK)>>BGFX_RENDER_TARGET_DEPTH_SHIFT;
|
||||
GLenum minFilter = s_textureFilter[(_textureFlags&BGFX_TEXTURE_MIN_MASK)>>BGFX_TEXTURE_MIN_SHIFT];
|
||||
GLenum magFilter = s_textureFilter[(_textureFlags&BGFX_TEXTURE_MAG_MASK)>>BGFX_TEXTURE_MAG_SHIFT];
|
||||
|
||||
if (0 < colorFormat)
|
||||
{
|
||||
m_color.createColor(_width, _height);
|
||||
m_color.createColor(_width, _height, minFilter, magFilter);
|
||||
}
|
||||
|
||||
#if 0 // GLES can't create texture with depth texture format...
|
||||
|
@ -1782,9 +1784,9 @@ namespace bgfx
|
|||
s_renderCtx.m_textures[_handle.idx].destroy();
|
||||
}
|
||||
|
||||
void Context::rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags)
|
||||
void Context::rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags)
|
||||
{
|
||||
s_renderCtx.m_renderTargets[_handle.idx].create(_width, _height, _flags);
|
||||
s_renderCtx.m_renderTargets[_handle.idx].create(_width, _height, _flags, _textureFlags);
|
||||
}
|
||||
|
||||
void Context::rendererDestroyRenderTarget(RenderTargetHandle _handle)
|
||||
|
|
|
@ -257,7 +257,7 @@ namespace bgfx
|
|||
}
|
||||
|
||||
void create(const Memory* _mem, uint32_t _flags);
|
||||
void createColor(uint32_t _width, uint32_t _height);
|
||||
void createColor(uint32_t _width, uint32_t _height, GLenum _min, GLenum _mag);
|
||||
void createDepth(uint32_t _width, uint32_t _height);
|
||||
void destroy();
|
||||
|
||||
|
@ -305,7 +305,7 @@ namespace bgfx
|
|||
|
||||
struct RenderTarget
|
||||
{
|
||||
void create(uint16_t _width, uint16_t _height, uint32_t _flags);
|
||||
void create(uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags);
|
||||
void destroy();
|
||||
|
||||
GLsizei m_width;
|
||||
|
|
|
@ -105,7 +105,7 @@ namespace bgfx
|
|||
{
|
||||
}
|
||||
|
||||
void Context::rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags)
|
||||
void Context::rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue