Commit d9e58303 by Jamie Madill

Move Context draw call logic into RendererD3D.

Also move a lot of supporting code. BUG=angle:789 Change-Id: I098bf7d072ece1f414605783c32ec5354ba63e19 Reviewed-on: https://chromium-review.googlesource.com/226061Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org>
parent 4de4fd6e
...@@ -223,19 +223,6 @@ class Context ...@@ -223,19 +223,6 @@ class Context
private: private:
DISALLOW_COPY_AND_ASSIGN(Context); DISALLOW_COPY_AND_ASSIGN(Context);
// TODO: std::array may become unavailable using older versions of GCC
typedef std::array<unsigned int, IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS> FramebufferTextureSerialArray;
Error applyRenderTarget(GLenum drawMode, bool ignoreViewport);
Error applyState(GLenum drawMode);
Error applyShaders(ProgramBinary *programBinary, bool transformFeedbackActive);
Error applyTextures(ProgramBinary *programBinary, SamplerType shaderType, const FramebufferTextureSerialArray &framebufferSerials,
size_t framebufferSerialCount);
Error applyTextures(ProgramBinary *programBinary);
Error applyUniformBuffers();
bool applyTransformFeedbackBuffers();
void markTransformFeedbackUsage();
void detachBuffer(GLuint buffer); void detachBuffer(GLuint buffer);
void detachTexture(GLuint texture); void detachTexture(GLuint texture);
void detachFramebuffer(GLuint framebuffer); void detachFramebuffer(GLuint framebuffer);
...@@ -244,18 +231,9 @@ class Context ...@@ -244,18 +231,9 @@ class Context
void detachTransformFeedback(GLuint transformFeedback); void detachTransformFeedback(GLuint transformFeedback);
void detachSampler(GLuint sampler); void detachSampler(GLuint sampler);
Error generateSwizzles(ProgramBinary *programBinary, SamplerType type);
Error generateSwizzles(ProgramBinary *programBinary);
Texture *getIncompleteTexture(GLenum type);
bool skipDraw(GLenum drawMode);
void initRendererString(); void initRendererString();
void initExtensionStrings(); void initExtensionStrings();
size_t getBoundFramebufferTextureSerials(FramebufferTextureSerialArray *outSerialArray);
void initCaps(GLuint clientVersion); void initCaps(GLuint clientVersion);
// Caps to use for validation // Caps to use for validation
......
...@@ -295,9 +295,9 @@ Texture *ResourceManager::getTexture(unsigned int handle) ...@@ -295,9 +295,9 @@ Texture *ResourceManager::getTexture(unsigned int handle)
} }
} }
Program *ResourceManager::getProgram(unsigned int handle) Program *ResourceManager::getProgram(unsigned int handle) const
{ {
ProgramMap::iterator program = mProgramMap.find(handle); ProgramMap::const_iterator program = mProgramMap.find(handle);
if (program == mProgramMap.end()) if (program == mProgramMap.end())
{ {
......
...@@ -60,7 +60,7 @@ class ResourceManager ...@@ -60,7 +60,7 @@ class ResourceManager
Buffer *getBuffer(GLuint handle); Buffer *getBuffer(GLuint handle);
Shader *getShader(GLuint handle); Shader *getShader(GLuint handle);
Program *getProgram(GLuint handle); Program *getProgram(GLuint handle) const;
Texture *getTexture(GLuint handle); Texture *getTexture(GLuint handle);
Renderbuffer *getRenderbuffer(GLuint handle); Renderbuffer *getRenderbuffer(GLuint handle);
Sampler *getSampler(GLuint handle); Sampler *getSampler(GLuint handle);
......
...@@ -486,7 +486,7 @@ void State::setSampleCoverageParams(GLclampf value, bool invert) ...@@ -486,7 +486,7 @@ void State::setSampleCoverageParams(GLclampf value, bool invert)
mSampleCoverageInvert = invert; mSampleCoverageInvert = invert;
} }
void State::getSampleCoverageParams(GLclampf *value, bool *invert) void State::getSampleCoverageParams(GLclampf *value, bool *invert) const
{ {
ASSERT(value != NULL && invert != NULL); ASSERT(value != NULL && invert != NULL);
......
...@@ -101,7 +101,7 @@ class State ...@@ -101,7 +101,7 @@ class State
bool isSampleCoverageEnabled() const; bool isSampleCoverageEnabled() const;
void setSampleCoverage(bool enabled); void setSampleCoverage(bool enabled);
void setSampleCoverageParams(GLclampf value, bool invert); void setSampleCoverageParams(GLclampf value, bool invert);
void getSampleCoverageParams(GLclampf *value, bool *invert); void getSampleCoverageParams(GLclampf *value, bool *invert) const;
// Scissor test state toggle & query // Scissor test state toggle & query
bool isScissorTestEnabled() const; bool isScissorTestEnabled() const;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "libGLESv2/angletypes.h" #include "libGLESv2/angletypes.h"
#include "libGLESv2/renderer/Workarounds.h" #include "libGLESv2/renderer/Workarounds.h"
#include "common/NativeWindow.h" #include "common/NativeWindow.h"
#include "common/mathutil.h"
#include <cstdint> #include <cstdint>
...@@ -36,6 +37,7 @@ namespace gl ...@@ -36,6 +37,7 @@ namespace gl
{ {
class Buffer; class Buffer;
class Framebuffer; class Framebuffer;
struct Data;
} }
namespace rx namespace rx
...@@ -77,15 +79,18 @@ class Renderer ...@@ -77,15 +79,18 @@ class Renderer
virtual gl::Error sync(bool block) = 0; virtual gl::Error sync(bool block) = 0;
virtual gl::Error drawArrays(const gl::Data &data, GLenum mode,
GLint first, GLsizei count, GLsizei instances) = 0;
virtual gl::Error drawElements(const gl::Data &data, GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei instances,
const RangeUI &indexRange) = 0;
// TODO(jmadill): pass state and essetial params only // TODO(jmadill): pass state and essetial params only
virtual gl::Error drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive) = 0;
virtual gl::Error drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances) = 0;
virtual gl::Error clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer) = 0; virtual gl::Error clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer) = 0;
virtual gl::Error readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, virtual gl::Error readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels) = 0; GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels) = 0;
// TODO(jmadill): caps? // TODO(jmadill): caps? and virtual for egl::Display
virtual bool getShareHandleSupport() const = 0; virtual bool getShareHandleSupport() const = 0;
virtual bool getPostSubBufferSupport() const = 0; virtual bool getPostSubBufferSupport() const = 0;
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
#define LIBGLESV2_RENDERER_RENDERERD3D_H_ #define LIBGLESV2_RENDERER_RENDERERD3D_H_
#include "libGLESv2/renderer/Renderer.h" #include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/Data.h"
//FIXME(jmadill): std::array is currently prohibited by Chromium style guide
#include <array>
namespace gl namespace gl
{ {
...@@ -38,6 +42,15 @@ class RendererD3D : public Renderer ...@@ -38,6 +42,15 @@ class RendererD3D : public Renderer
static RendererD3D *makeRendererD3D(Renderer *renderer); static RendererD3D *makeRendererD3D(Renderer *renderer);
gl::Error drawArrays(const gl::Data &data,
GLenum mode, GLint first,
GLsizei count, GLsizei instances) override;
gl::Error drawElements(const gl::Data &data,
GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei instances,
const RangeUI &indexRange) override;
// Direct3D Specific methods // Direct3D Specific methods
virtual SwapChain *createSwapChain(rx::NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) = 0; virtual SwapChain *createSwapChain(rx::NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) = 0;
...@@ -48,7 +61,7 @@ class RendererD3D : public Renderer ...@@ -48,7 +61,7 @@ class RendererD3D : public Renderer
virtual gl::Error setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]) = 0; virtual gl::Error setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]) = 0;
virtual gl::Error setRasterizerState(const gl::RasterizerState &rasterState) = 0; virtual gl::Error setRasterizerState(const gl::RasterizerState &rasterState) = 0;
virtual gl::Error setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor, virtual gl::Error setBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor,
unsigned int sampleMask) = 0; unsigned int sampleMask) = 0;
virtual gl::Error setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef, virtual gl::Error setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW) = 0; int stencilBackRef, bool frontFaceCCW) = 0;
...@@ -57,7 +70,7 @@ class RendererD3D : public Renderer ...@@ -57,7 +70,7 @@ class RendererD3D : public Renderer
virtual void setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace, virtual void setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace,
bool ignoreViewport) = 0; bool ignoreViewport) = 0;
virtual gl::Error applyRenderTarget(gl::Framebuffer *frameBuffer) = 0; virtual gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) = 0;
virtual gl::Error applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer, virtual gl::Error applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
bool rasterizerDiscard, bool transformFeedbackActive) = 0; bool rasterizerDiscard, bool transformFeedbackActive) = 0;
virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray) = 0; virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray) = 0;
...@@ -130,13 +143,42 @@ class RendererD3D : public Renderer ...@@ -130,13 +143,42 @@ class RendererD3D : public Renderer
virtual VertexBuffer *createVertexBuffer() = 0; virtual VertexBuffer *createVertexBuffer() = 0;
virtual IndexBuffer *createIndexBuffer() = 0; virtual IndexBuffer *createIndexBuffer() = 0;
//TODO(jmadill): Should be private or protected
gl::Error applyRenderTarget(const gl::Data &data, GLenum drawMode, bool ignoreViewport);
protected: protected:
virtual gl::Error drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive) = 0;
virtual gl::Error drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances) = 0;
egl::Display *mDisplay; egl::Display *mDisplay;
private: private:
DISALLOW_COPY_AND_ASSIGN(RendererD3D); DISALLOW_COPY_AND_ASSIGN(RendererD3D);
//FIXME(jmadill): std::array is currently prohibited by Chromium style guide
typedef std::array<unsigned int, gl::IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS> FramebufferTextureSerialArray;
gl::Error generateSwizzles(const gl::Data &data, gl::SamplerType type);
gl::Error generateSwizzles(const gl::Data &data);
gl::Error applyState(const gl::Data &data, GLenum drawMode);
bool applyTransformFeedbackBuffers(const gl::Data &data);
gl::Error applyShaders(const gl::Data &data, bool transformFeedbackActive);
gl::Error applyTextures(const gl::Data &data, gl::SamplerType shaderType,
const FramebufferTextureSerialArray &framebufferSerials, size_t framebufferSerialCount);
gl::Error applyTextures(const gl::Data &data);
gl::Error applyUniformBuffers(const gl::Data &data);
bool skipDraw(const gl::Data &data, GLenum drawMode);
void markTransformFeedbackUsage(const gl::Data &data);
size_t getBoundFramebufferTextureSerials(const gl::Data &data,
FramebufferTextureSerialArray *outSerialArray);
gl::Texture *getIncompleteTexture(GLenum type);
int mCurrentClientVersion; int mCurrentClientVersion;
gl::TextureMap mIncompleteTextures;
}; };
} }
......
...@@ -643,7 +643,7 @@ gl::Error Renderer11::setRasterizerState(const gl::RasterizerState &rasterState) ...@@ -643,7 +643,7 @@ gl::Error Renderer11::setRasterizerState(const gl::RasterizerState &rasterState)
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Renderer11::setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor, gl::Error Renderer11::setBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor,
unsigned int sampleMask) unsigned int sampleMask)
{ {
if (mForceSetBlendState || if (mForceSetBlendState ||
...@@ -858,7 +858,7 @@ void Renderer11::unsetSRVsWithResource(gl::SamplerType samplerType, const ID3D11 ...@@ -858,7 +858,7 @@ void Renderer11::unsetSRVsWithResource(gl::SamplerType samplerType, const ID3D11
} }
} }
gl::Error Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer)
{ {
// Get the color render buffer and serial // Get the color render buffer and serial
// Also extract the render target dimensions and view // Also extract the render target dimensions and view
...@@ -3275,7 +3275,7 @@ void Renderer11::invalidateFBOAttachmentSwizzles(gl::FramebufferAttachment *atta ...@@ -3275,7 +3275,7 @@ void Renderer11::invalidateFBOAttachmentSwizzles(gl::FramebufferAttachment *atta
} }
} }
void Renderer11::invalidateFramebufferSwizzles(gl::Framebuffer *framebuffer) void Renderer11::invalidateFramebufferSwizzles(const gl::Framebuffer *framebuffer)
{ {
for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
{ {
......
...@@ -69,8 +69,8 @@ class Renderer11 : public RendererD3D ...@@ -69,8 +69,8 @@ class Renderer11 : public RendererD3D
virtual gl::Error setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]); virtual gl::Error setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]);
virtual gl::Error setRasterizerState(const gl::RasterizerState &rasterState); virtual gl::Error setRasterizerState(const gl::RasterizerState &rasterState);
virtual gl::Error setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor, gl::Error setBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor,
unsigned int sampleMask); unsigned int sampleMask) override;
virtual gl::Error setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef, virtual gl::Error setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW); int stencilBackRef, bool frontFaceCCW);
...@@ -79,7 +79,7 @@ class Renderer11 : public RendererD3D ...@@ -79,7 +79,7 @@ class Renderer11 : public RendererD3D
bool ignoreViewport); bool ignoreViewport);
virtual bool applyPrimitiveType(GLenum mode, GLsizei count); virtual bool applyPrimitiveType(GLenum mode, GLsizei count);
virtual gl::Error applyRenderTarget(gl::Framebuffer *frameBuffer); gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) override;
virtual gl::Error applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer, virtual gl::Error applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
bool rasterizerDiscard, bool transformFeedbackActive); bool rasterizerDiscard, bool transformFeedbackActive);
...@@ -227,7 +227,7 @@ class Renderer11 : public RendererD3D ...@@ -227,7 +227,7 @@ class Renderer11 : public RendererD3D
void unsetSRVsWithResource(gl::SamplerType shaderType, const ID3D11Resource *resource); void unsetSRVsWithResource(gl::SamplerType shaderType, const ID3D11Resource *resource);
static void invalidateFBOAttachmentSwizzles(gl::FramebufferAttachment *attachment, int mipLevel); static void invalidateFBOAttachmentSwizzles(gl::FramebufferAttachment *attachment, int mipLevel);
static void invalidateFramebufferSwizzles(gl::Framebuffer *framebuffer); static void invalidateFramebufferSwizzles(const gl::Framebuffer *framebuffer);
HMODULE mD3d11Module; HMODULE mD3d11Module;
HMODULE mDxgiModule; HMODULE mDxgiModule;
......
...@@ -797,7 +797,7 @@ gl::Error Renderer9::setRasterizerState(const gl::RasterizerState &rasterState) ...@@ -797,7 +797,7 @@ gl::Error Renderer9::setRasterizerState(const gl::RasterizerState &rasterState)
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Renderer9::setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor, gl::Error Renderer9::setBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor,
unsigned int sampleMask) unsigned int sampleMask)
{ {
bool blendStateChanged = mForceSetBlendState || memcmp(&blendState, &mCurBlendState, sizeof(gl::BlendState)) != 0; bool blendStateChanged = mForceSetBlendState || memcmp(&blendState, &mCurBlendState, sizeof(gl::BlendState)) != 0;
...@@ -1193,7 +1193,7 @@ gl::Error Renderer9::getNullColorbuffer(gl::FramebufferAttachment *depthbuffer, ...@@ -1193,7 +1193,7 @@ gl::Error Renderer9::getNullColorbuffer(gl::FramebufferAttachment *depthbuffer,
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Renderer9::applyRenderTarget(gl::Framebuffer *framebuffer) gl::Error Renderer9::applyRenderTarget(const gl::Framebuffer *framebuffer)
{ {
// if there is no color attachment we must synthesize a NULL colorattachment // if there is no color attachment we must synthesize a NULL colorattachment
// to keep the D3D runtime happy. This should only be possible if depth texturing. // to keep the D3D runtime happy. This should only be possible if depth texturing.
......
...@@ -72,8 +72,8 @@ class Renderer9 : public RendererD3D ...@@ -72,8 +72,8 @@ class Renderer9 : public RendererD3D
virtual gl::Error setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]); virtual gl::Error setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]);
virtual gl::Error setRasterizerState(const gl::RasterizerState &rasterState); virtual gl::Error setRasterizerState(const gl::RasterizerState &rasterState);
virtual gl::Error setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor, gl::Error setBlendState(const gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor,
unsigned int sampleMask); unsigned int sampleMask) override;
virtual gl::Error setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef, virtual gl::Error setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW); int stencilBackRef, bool frontFaceCCW);
...@@ -81,7 +81,7 @@ class Renderer9 : public RendererD3D ...@@ -81,7 +81,7 @@ class Renderer9 : public RendererD3D
virtual void setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace, virtual void setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace,
bool ignoreViewport); bool ignoreViewport);
virtual gl::Error applyRenderTarget(gl::Framebuffer *frameBuffer); gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) override;
virtual gl::Error applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer, virtual gl::Error applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
bool rasterizerDiscard, bool transformFeedbackActive); bool rasterizerDiscard, bool transformFeedbackActive);
virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray); virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray);
......
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