From 09fae5afcd4c43d7e6d32af94e03f8aab32bced1 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 26 Aug 2018 20:36:01 -0700 Subject: Few minor updates --- Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp | 12 +++++++++--- Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp | 2 +- Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp | 2 +- Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp | 2 +- Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp index fc2022b6..4d049040 100644 --- a/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp @@ -40,7 +40,8 @@ namespace Diligent TBuffViewBase(pRefCounters, pDevice, ViewDesc, pBuffer, bIsDefaultView ), m_GLTexBuffer(false) { - if( ViewDesc.ViewType == BUFFER_VIEW_SHADER_RESOURCE && pBuffer->GetDesc().Mode == BUFFER_MODE_FORMATTED ) + if( ViewDesc.ViewType == BUFFER_VIEW_SHADER_RESOURCE && + (pBuffer->GetDesc().Mode == BUFFER_MODE_FORMATTED || pBuffer->GetDesc().Mode == BUFFER_MODE_RAW) ) { #ifdef _MSC_VER # pragma warning(push) @@ -58,8 +59,13 @@ namespace Diligent ContextState.BindTexture(-1, GL_TEXTURE_BUFFER, m_GLTexBuffer ); const auto &BuffFmt = ViewDesc.Format; - VERIFY_EXPR(BuffFmt.ValueType != VT_UNDEFINED); - auto GLFormat = TypeToGLTexFormat( BuffFmt.ValueType, BuffFmt.NumComponents, BuffFmt.IsNormalized ); + GLenum GLFormat = 0; + if(pBuffer->GetDesc().Mode == BUFFER_MODE_FORMATTED || BuffFmt.ValueType != VT_UNDEFINED) + GLFormat = TypeToGLTexFormat( BuffFmt.ValueType, BuffFmt.NumComponents, BuffFmt.IsNormalized ); + else + { + GLFormat = GL_R32UI; + } glTexBuffer( GL_TEXTURE_BUFFER, GLFormat, pBuffer->GetGLHandle() ); CHECK_GL_ERROR_AND_THROW( "Failed to create texture buffer" ); diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp index efa485dc..5368281a 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp @@ -152,7 +152,7 @@ void Texture2DArray_OGL::UpdateData(IDeviceContext *pContext, Uint32 MipLevel, U ((DstBox.MaxY % 4) == 0 || DstBox.MaxY == std::max(m_Desc.Height>>MipLevel, 1U)), "Compressed texture update region must be 4 pixel-aligned" ); const auto &FmtAttribs = GetTextureFormatAttribs(m_Desc.Format); - auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * FmtAttribs.ComponentSize; + auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * Uint32{FmtAttribs.ComponentSize}; VERIFY( SubresData.Stride == BlockBytesInRow, "Compressed data stride (", SubresData.Stride, " must match the size of a row of compressed blocks (", BlockBytesInRow, ")" ); diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp index d6bfaa50..f4171812 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp @@ -154,7 +154,7 @@ void Texture2D_OGL::UpdateData( IDeviceContext *pContext, Uint32 MipLevel, Uint3 ((DstBox.MaxY % 4) == 0 || DstBox.MaxY == std::max(m_Desc.Height>>MipLevel, 1U)), "Compressed texture update region must be 4 pixel-aligned" ); const auto &FmtAttribs = GetTextureFormatAttribs(m_Desc.Format); - auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * FmtAttribs.ComponentSize; + auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * Uint32{FmtAttribs.ComponentSize}; VERIFY( SubresData.Stride == BlockBytesInRow, "Compressed data stride (", SubresData.Stride, " must match the size of a row of compressed blocks (", BlockBytesInRow, ")" ); diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp index 945b137d..3851d31f 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp @@ -138,7 +138,7 @@ void TextureCubeArray_OGL::UpdateData( IDeviceContext *pContext, Uint32 MipLevel ((DstBox.MaxY % 4) == 0 || DstBox.MaxY == std::max(m_Desc.Height>>MipLevel, 1U)), "Compressed texture update region must be 4 pixel-aligned" ); const auto &FmtAttribs = GetTextureFormatAttribs(m_Desc.Format); - auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * FmtAttribs.ComponentSize; + auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * Uint32{FmtAttribs.ComponentSize}; VERIFY( SubresData.Stride == BlockBytesInRow, "Compressed data stride (", SubresData.Stride, " must match the size of a row of compressed blocks (", BlockBytesInRow, ")" ); diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp index 52414776..508ee6b2 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp @@ -152,7 +152,7 @@ void TextureCube_OGL::UpdateData( IDeviceContext *pContext, Uint32 MipLevel, Uin ((DstBox.MaxY % 4) == 0 || DstBox.MaxY == std::max(m_Desc.Height>>MipLevel, 1U)), "Compressed texture update region must be 4 pixel-aligned" ); const auto &FmtAttribs = GetTextureFormatAttribs(m_Desc.Format); - auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * FmtAttribs.ComponentSize; + auto BlockBytesInRow = ((DstBox.MaxX - DstBox.MinX + 3)/4) * Uint32{FmtAttribs.ComponentSize}; VERIFY( SubresData.Stride == BlockBytesInRow, "Compressed data stride (", SubresData.Stride, " must match the size of a row of compressed blocks (", BlockBytesInRow, ")" ); -- cgit v1.2.3