Fixed framebuffer RW.

This commit is contained in:
Branimir Karadžić 2019-02-18 13:40:17 -08:00
parent 1ee30e6d50
commit 1b9dd14683
6 changed files with 38 additions and 29 deletions

View File

@ -44,8 +44,8 @@ FS_FLAGS=--platform windows -p ps_3_0 -O 3
SHADER_PATH=shaders/dx9
else
ifeq ($(TARGET), 1)
VS_FLAGS=--platform windows -p vs_4_0 -O 3
FS_FLAGS=--platform windows -p ps_4_0 -O 3
VS_FLAGS=--platform windows -p vs_5_0 -O 3
FS_FLAGS=--platform windows -p ps_5_0 -O 3
CS_FLAGS=--platform windows -p cs_5_0 -O 1
SHADER_PATH=shaders/dx11
else

View File

@ -10,6 +10,8 @@
#ifndef __cplusplus
#define FRAMEBUFFER_IMAGE2D_RW(_name, _format, _reg) IMAGE2D_RW(_name, _format, 16+(_reg) )
#if BGFX_SHADER_LANGUAGE_GLSL
#define SHARED shared

View File

@ -391,14 +391,14 @@ namespace bgfx { namespace d3d11
void clear()
{
bx::memSet(m_uav, 0, sizeof(m_uav));
bx::memSet(m_srv, 0, sizeof(m_srv) );
bx::memSet(m_uav, 0, sizeof(m_uav) );
bx::memSet(m_srv, 0, sizeof(m_srv) );
bx::memSet(m_sampler, 0, sizeof(m_sampler) );
}
ID3D11UnorderedAccessView* m_uav[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
ID3D11ShaderResourceView* m_srv[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
ID3D11SamplerState* m_sampler[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
ID3D11ShaderResourceView* m_srv[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
ID3D11SamplerState* m_sampler[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS];
};
BX_PRAGMA_DIAGNOSTIC_PUSH();
@ -4592,10 +4592,12 @@ namespace bgfx { namespace d3d11
{
m_rtv[ii] = NULL;
}
for(uint32_t ii = 0; ii < BX_COUNTOF(m_uav); ++ii)
for (uint32_t ii = 0; ii < BX_COUNTOF(m_uav); ++ii)
{
m_uav[ii] = NULL;
}
m_dsv = NULL;
m_swapChain = NULL;
@ -4870,8 +4872,7 @@ namespace bgfx { namespace d3d11
}
else
{
m_uav[m_num + m_numUav] = texture.m_uav;
m_numUav++;
m_uav[m_numUav++] = texture.m_uav;
}
}
}
@ -4948,9 +4949,9 @@ namespace bgfx { namespace d3d11
m_num
, m_rtv
, m_dsv
, m_num
, 16
, m_numUav
, m_uav + m_num
, m_uav
, NULL
);
m_needPresent = UINT16_MAX != m_denseIdx;
@ -5373,12 +5374,6 @@ namespace bgfx { namespace d3d11
view = key.m_view;
currentProgram = BGFX_INVALID_HANDLE;
if (_render->m_view[view].m_fbh.idx != fbh.idx)
{
fbh = _render->m_view[view].m_fbh;
setFrameBuffer(fbh);
}
if (item > 1)
{
profiler.end();
@ -5390,6 +5385,12 @@ namespace bgfx { namespace d3d11
profiler.begin(view);
if (_render->m_view[view].m_fbh.idx != fbh.idx)
{
fbh = _render->m_view[view].m_fbh;
setFrameBuffer(fbh);
}
viewState.m_rect = _render->m_view[view].m_rect;
const Rect& scissorRect = _render->m_view[view].m_scissor;

View File

@ -345,10 +345,10 @@ namespace bgfx { namespace d3d11
void set();
HRESULT present(uint32_t _syncInterval);
ID3D11RenderTargetView* m_rtv[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS-1];
ID3D11RenderTargetView* m_rtv[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS-1];
ID3D11UnorderedAccessView* m_uav[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS-1];
ID3D11ShaderResourceView* m_srv[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS-1];
ID3D11DepthStencilView* m_dsv;
ID3D11ShaderResourceView* m_srv[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS-1];
ID3D11DepthStencilView* m_dsv;
Dxgi::SwapChainI* m_swapChain;
void* m_nwh;
uint32_t m_width;

View File

@ -6205,24 +6205,27 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
{
for(uint32_t ii = 0; ii < m_numTh; ++ii)
{
if(m_attachment[ii].access == Access::Write)
continue;
const Attachment& at = m_attachment[ii];
TextureHandle handle = m_attachment[ii].handle;
if(isValid(handle))
if (at.access == Access::Write)
{
const TextureGL& texture = s_renderGL->m_textures[handle.idx];
continue;
}
if (isValid(at.handle) )
{
const TextureGL& texture = s_renderGL->m_textures[at.handle.idx];
if(0 != (texture.m_flags&BGFX_TEXTURE_COMPUTE_WRITE))
{
GL_CHECK(glBindImageTexture(ii
, texture.m_id
, m_attachment[ii].mip
, at.mip
, GL_FALSE //texture.isLayered() ? GL_TRUE : GL_FALSE
, m_attachment[ii].layer
, at.layer
, s_access[Access::ReadWrite]
, s_imageFormat[texture.m_textureFormat])
);
);
}
}
}

View File

@ -1943,7 +1943,10 @@ namespace bgfx
if (0 != glsl
|| 0 != essl)
{
if (!bx::strFind(preprocessor.m_preprocessed.c_str(), "layout(std430").isEmpty() )
const bx::StringView preprocessedInput(preprocessor.m_preprocessed.c_str() );
if (!bx::strFind(preprocessedInput, "layout(std430").isEmpty()
|| !bx::strFind(preprocessedInput, "image2D").isEmpty() )
{
glsl = 430;
}