Commit 89a0bf50 by Jamie Madill

Add initial implementation for PixelTransfer11, which will enable GPU buffer to…

Add initial implementation for PixelTransfer11, which will enable GPU buffer to texture and texture to buffer copies. This is necessary for fast implementation of ES3 PBOs. TRAC #23841 Signed-off-by: Geoff Lang Signed-off-by: Shannon Woods
parent d3f0f1ec
...@@ -326,6 +326,8 @@ ...@@ -326,6 +326,8 @@
'libGLESv2/renderer/loadimage.cpp', 'libGLESv2/renderer/loadimage.cpp',
'libGLESv2/renderer/loadimageSSE2.cpp', 'libGLESv2/renderer/loadimageSSE2.cpp',
'libGLESv2/renderer/loadimage.h', 'libGLESv2/renderer/loadimage.h',
'libGLESv2/renderer/PixelTransfer11.cpp',
'libGLESv2/renderer/PixelTransfer11.h',
'libGLESv2/renderer/QueryImpl.h', 'libGLESv2/renderer/QueryImpl.h',
'libGLESv2/renderer/Query9.cpp', 'libGLESv2/renderer/Query9.cpp',
'libGLESv2/renderer/Query9.h', 'libGLESv2/renderer/Query9.h',
......
...@@ -35,7 +35,7 @@ typedef std::pair<GLenum, GLenum> FormatTypePair; ...@@ -35,7 +35,7 @@ typedef std::pair<GLenum, GLenum> FormatTypePair;
typedef std::pair<FormatTypePair, FormatTypeInfo> FormatPair; typedef std::pair<FormatTypePair, FormatTypeInfo> FormatPair;
typedef std::map<FormatTypePair, FormatTypeInfo> FormatMap; typedef std::map<FormatTypePair, FormatTypeInfo> FormatMap;
// A helper function to insert data into the D3D11LoadFunctionMap with fewer characters. // A helper function to insert data into the format map with fewer characters.
static inline void InsertFormatMapping(FormatMap *map, GLenum format, GLenum type, GLint internalFormat, ColorWriteFunction writeFunc) static inline void InsertFormatMapping(FormatMap *map, GLenum format, GLenum type, GLint internalFormat, ColorWriteFunction writeFunc)
{ {
map->insert(FormatPair(FormatTypePair(format, type), FormatTypeInfo(internalFormat, writeFunc))); map->insert(FormatPair(FormatTypePair(format, type), FormatTypeInfo(internalFormat, writeFunc)));
...@@ -1584,4 +1584,9 @@ ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type, GLuint clie ...@@ -1584,4 +1584,9 @@ ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type, GLuint clie
return (iter != formats.end()) ? iter->second.mColorWriteFunction : NULL; return (iter != formats.end()) ? iter->second.mColorWriteFunction : NULL;
} }
bool IsFastCopyBufferToTextureSupported(GLint internalFormat, GLuint clientVersion)
{
return false;
}
} }
...@@ -88,6 +88,8 @@ GLuint GetCompressedBlockHeight(GLint internalFormat, GLuint clientVersion); ...@@ -88,6 +88,8 @@ GLuint GetCompressedBlockHeight(GLint internalFormat, GLuint clientVersion);
ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type, GLuint clientVersion); ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type, GLuint clientVersion);
bool IsFastCopyBufferToTextureSupported(GLint internalFormat, GLuint clientVersion);
} }
#endif LIBGLESV2_FORMATUTILS_H_ #endif LIBGLESV2_FORMATUTILS_H_
...@@ -272,6 +272,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -272,6 +272,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<ClCompile Include="renderer\Blit11.cpp" /> <ClCompile Include="renderer\Blit11.cpp" />
<ClCompile Include="renderer\Blit9.cpp" /> <ClCompile Include="renderer\Blit9.cpp" />
<ClCompile Include="renderer\Clear11.cpp" /> <ClCompile Include="renderer\Clear11.cpp" />
<ClCompile Include="renderer\PixelTransfer11.cpp" />
<ClCompile Include="renderer\copyimage.cpp" /> <ClCompile Include="renderer\copyimage.cpp" />
<ClCompile Include="renderer\Fence11.cpp" /> <ClCompile Include="renderer\Fence11.cpp" />
<ClCompile Include="renderer\Fence9.cpp" /> <ClCompile Include="renderer\Fence9.cpp" />
...@@ -356,6 +357,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -356,6 +357,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<ClInclude Include="renderer\Blit11.h" /> <ClInclude Include="renderer\Blit11.h" />
<ClInclude Include="renderer\Blit9.h" /> <ClInclude Include="renderer\Blit9.h" />
<ClInclude Include="renderer\Clear11.h" /> <ClInclude Include="renderer\Clear11.h" />
<ClInclude Include="renderer\PixelTransfer11.h" />
<ClInclude Include="renderer\copyimage.h" /> <ClInclude Include="renderer\copyimage.h" />
<ClInclude Include="renderer\Fence11.h" /> <ClInclude Include="renderer\Fence11.h" />
<ClInclude Include="renderer\Fence9.h" /> <ClInclude Include="renderer\Fence9.h" />
......
...@@ -266,6 +266,9 @@ ...@@ -266,6 +266,9 @@
<ClCompile Include="angletypes.cpp"> <ClCompile Include="angletypes.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="renderer\PixelTransfer11.cpp">
<Filter>Source Files\Renderer11</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="BinaryStream.h"> <ClInclude Include="BinaryStream.h">
...@@ -682,6 +685,9 @@ ...@@ -682,6 +685,9 @@
<ClInclude Include="renderer\shaders\compiled\clearfloat11vs.h"> <ClInclude Include="renderer\shaders\compiled\clearfloat11vs.h">
<Filter>Shaders\Compiled</Filter> <Filter>Shaders\Compiled</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="renderer\PixelTransfer11.h">
<Filter>Header Files\Renderer11</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="renderer\shaders\Blit.ps"> <None Include="renderer\shaders\Blit.ps">
...@@ -707,4 +713,4 @@ ...@@ -707,4 +713,4 @@
<ItemGroup> <ItemGroup>
<ResourceCompile Include="libGLESv2.rc" /> <ResourceCompile Include="libGLESv2.rc" />
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -266,6 +266,11 @@ ID3D11Buffer *BufferStorage11::getBuffer(GLenum usage) ...@@ -266,6 +266,11 @@ ID3D11Buffer *BufferStorage11::getBuffer(GLenum usage)
return directBuffer->getD3DBuffer(); return directBuffer->getD3DBuffer();
} }
ID3D11ShaderResourceView *BufferStorage11::getSRV(DXGI_FORMAT srvFormat)
{
return NULL;
}
DirectBufferStorage11::DirectBufferStorage11(Renderer11 *renderer, const GLenum target) DirectBufferStorage11::DirectBufferStorage11(Renderer11 *renderer, const GLenum target)
: mRenderer(renderer) : mRenderer(renderer)
, mTarget(target) , mTarget(target)
......
...@@ -33,6 +33,7 @@ class BufferStorage11 : public BufferStorage ...@@ -33,6 +33,7 @@ class BufferStorage11 : public BufferStorage
virtual bool supportsDirectBinding() const; virtual bool supportsDirectBinding() const;
ID3D11Buffer *getBuffer(GLenum usage); ID3D11Buffer *getBuffer(GLenum usage);
ID3D11ShaderResourceView *getSRV(DXGI_FORMAT srvFormat);
private: private:
Renderer11 *mRenderer; Renderer11 *mRenderer;
......
//
// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// PixelTransfer11.h:
// Buffer-to-Texture and Texture-to-Buffer data transfers.
// Used to implement pixel unpack and pixel pack buffers in ES3.
#ifndef LIBGLESV2_PIXELTRANSFER11_H_
#define LIBGLESV2_PIXELTRANSFER11_H_
namespace gl
{
class Buffer;
struct Box;
struct Extents;
struct PixelUnpackState;
}
namespace rx
{
class Renderer11;
class RenderTarget;
class PixelTransfer11
{
public:
explicit PixelTransfer11(Renderer11 *renderer);
~PixelTransfer11();
static bool supportsBufferToTextureCopy(GLenum internalFormat);
// unpack: the source buffer is stored in the unpack state, and buffer strides
// offset: the start of the data within the unpack buffer
// destRenderTarget: individual slice/layer of a target texture
// destinationFormat/sourcePixelsType: determines shaders + shader parameters
// destArea: the sub-section of destRenderTarget to copy to
bool copyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea);
private:
struct CopyShaderDesc
{
GLenum mSourceFormat;
bool mSignedInteger;
// For sorting keys in a std::map
bool operator<(const CopyShaderDesc &other) const;
};
struct CopyShaderParams
{
unsigned int FirstPixelOffset;
unsigned int PixelsPerRow;
unsigned int RowStride;
unsigned int RowsPerSlice;
float PositionOffset[2];
float PositionScale[2];
int TexLocationOffset[2];
int TexLocationScale[2];
};
static void setBufferToTextureCopyParams(const gl::Box &destArea, const gl::Extents &destSize, GLenum internalFormat,
const gl::PixelUnpackState &unpack, unsigned int offset, CopyShaderParams *parametersOut);
void addBufferToTextureShader(GLenum sourceFormat, bool signedInteger, ID3D11PixelShader *pixelShader);
void buildShaderMap();
ID3D11PixelShader *findBufferToTexturePS(GLenum internalFormat) const;
Renderer11 *mRenderer;
std::map<CopyShaderDesc, ID3D11PixelShader *> mBufferToTexturePSMap;
ID3D11VertexShader *mBufferToTextureVS;
ID3D11GeometryShader *mBufferToTextureGS;
ID3D11Buffer *mParamsConstantBuffer;
CopyShaderParams mParamsData;
ID3D11RasterizerState *mCopyRasterizerState;
ID3D11DepthStencilState *mCopyDepthStencilState;
};
}
#endif // LIBGLESV2_PIXELTRANSFER11_H_
...@@ -138,6 +138,19 @@ inline ID3D11PixelShader *CompilePS(ID3D11Device *device, const BYTE (&byteCode) ...@@ -138,6 +138,19 @@ inline ID3D11PixelShader *CompilePS(ID3D11Device *device, const BYTE (&byteCode)
return ps; return ps;
} }
// Copy data to small D3D11 buffers, such as for small constant buffers, which use one struct to
// represent an entire buffer.
template <class T>
inline void SetBufferData(ID3D11DeviceContext *context, ID3D11Buffer *constantBuffer, const T &value)
{
D3D11_MAPPED_SUBRESOURCE mappedResource;
context->Map(constantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
memcpy(mappedResource.pData, &value, sizeof(T));
context->Unmap(constantBuffer, 0);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment