Commit 4c56c607 by Jamie Madill Committed by Commit Bot

D3D: Make draw call translation check non-virtual.

We don't support this call in D3D9, so need for it to be in RendererD3D. In general we want to have as few virtual calls in the hot draw call path as possible. Also rename it to 'drawCallNeedsTranslation' (with inverted condition checks). BUG=angleproject:1393 Change-Id: Ib212ec35aca4b5d45579acec65c20691b5853230 Reviewed-on: https://chromium-review.googlesource.com/584826Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 6caf405c
...@@ -337,10 +337,6 @@ class RendererD3D : public BufferFactoryD3D ...@@ -337,10 +337,6 @@ class RendererD3D : public BufferFactoryD3D
gl::Extensions *outExtensions, gl::Extensions *outExtensions,
gl::Limitations *outLimitations) const = 0; gl::Limitations *outLimitations) const = 0;
virtual bool instancedPointSpritesActive(ProgramD3D *programD3D, GLenum mode) const; virtual bool instancedPointSpritesActive(ProgramD3D *programD3D, GLenum mode) const;
// Support direct drawing with the drawing parameters.
virtual bool supportsDirectDrawing(const gl::Context *context,
GLenum mode,
GLenum type) const = 0;
void cleanup(); void cleanup();
......
...@@ -1802,7 +1802,7 @@ gl::Error Renderer11::drawElementsImpl(const gl::Context *context, ...@@ -1802,7 +1802,7 @@ gl::Error Renderer11::drawElementsImpl(const gl::Context *context,
const auto &data = context->getContextState(); const auto &data = context->getContextState();
TranslatedIndexData indexInfo; TranslatedIndexData indexInfo;
if (supportsDirectDrawing(context, mode, type)) if (!drawCallNeedsTranslation(context, mode, type))
{ {
ANGLE_TRY(applyIndexBuffer(data, nullptr, 0, mode, type, &indexInfo)); ANGLE_TRY(applyIndexBuffer(data, nullptr, 0, mode, type, &indexInfo));
ANGLE_TRY(applyVertexBuffer(context, mode, 0, 0, 0, &indexInfo)); ANGLE_TRY(applyVertexBuffer(context, mode, 0, 0, 0, &indexInfo));
...@@ -1892,7 +1892,9 @@ gl::Error Renderer11::drawElementsImpl(const gl::Context *context, ...@@ -1892,7 +1892,9 @@ gl::Error Renderer11::drawElementsImpl(const gl::Context *context,
return gl::NoError(); return gl::NoError();
} }
bool Renderer11::supportsDirectDrawing(const gl::Context *context, GLenum mode, GLenum type) const bool Renderer11::drawCallNeedsTranslation(const gl::Context *context,
GLenum mode,
GLenum type) const
{ {
const auto &glState = context->getGLState(); const auto &glState = context->getGLState();
const auto &vertexArray = glState.getVertexArray(); const auto &vertexArray = glState.getVertexArray();
...@@ -1902,22 +1904,22 @@ bool Renderer11::supportsDirectDrawing(const gl::Context *context, GLenum mode, ...@@ -1902,22 +1904,22 @@ bool Renderer11::supportsDirectDrawing(const gl::Context *context, GLenum mode,
// either since we need to simulate them in D3D. // either since we need to simulate them in D3D.
if (vertexArray11->hasDynamicAttrib(context) || mode == GL_LINE_LOOP || mode == GL_TRIANGLE_FAN) if (vertexArray11->hasDynamicAttrib(context) || mode == GL_LINE_LOOP || mode == GL_TRIANGLE_FAN)
{ {
return false; return true;
} }
ProgramD3D *programD3D = GetImplAs<ProgramD3D>(glState.getProgram()); ProgramD3D *programD3D = GetImplAs<ProgramD3D>(glState.getProgram());
if (instancedPointSpritesActive(programD3D, mode)) if (instancedPointSpritesActive(programD3D, mode))
{ {
return false; return true;
} }
if (type != GL_NONE) if (type != GL_NONE)
{ {
// Only non-streaming index data can be directly used to draw since they don't // Only non-streaming index data can be directly used to draw since they don't
// need the indices and count informations. // need the indices and count informations.
return !mIndexDataManager->isStreamingIndexData(context, type); return mIndexDataManager->isStreamingIndexData(context, type);
} }
return true; return false;
} }
gl::Error Renderer11::drawArraysIndirectImpl(const gl::Context *context, gl::Error Renderer11::drawArraysIndirectImpl(const gl::Context *context,
...@@ -1936,7 +1938,7 @@ gl::Error Renderer11::drawArraysIndirectImpl(const gl::Context *context, ...@@ -1936,7 +1938,7 @@ gl::Error Renderer11::drawArraysIndirectImpl(const gl::Context *context,
Buffer11 *storage = GetImplAs<Buffer11>(drawIndirectBuffer); Buffer11 *storage = GetImplAs<Buffer11>(drawIndirectBuffer);
uintptr_t offset = reinterpret_cast<uintptr_t>(indirect); uintptr_t offset = reinterpret_cast<uintptr_t>(indirect);
if (supportsDirectDrawing(context, mode, GL_NONE)) if (!drawCallNeedsTranslation(context, mode, GL_NONE))
{ {
applyVertexBuffer(context, mode, 0, 0, 0, nullptr); applyVertexBuffer(context, mode, 0, 0, 0, nullptr);
ID3D11Buffer *buffer = nullptr; ID3D11Buffer *buffer = nullptr;
...@@ -1987,7 +1989,7 @@ gl::Error Renderer11::drawElementsIndirectImpl(const gl::Context *context, ...@@ -1987,7 +1989,7 @@ gl::Error Renderer11::drawElementsIndirectImpl(const gl::Context *context,
uintptr_t offset = reinterpret_cast<uintptr_t>(indirect); uintptr_t offset = reinterpret_cast<uintptr_t>(indirect);
TranslatedIndexData indexInfo; TranslatedIndexData indexInfo;
if (supportsDirectDrawing(context, mode, type)) if (!drawCallNeedsTranslation(context, mode, type))
{ {
ANGLE_TRY(applyIndexBuffer(contextState, nullptr, 0, mode, type, &indexInfo)); ANGLE_TRY(applyIndexBuffer(contextState, nullptr, 0, mode, type, &indexInfo));
ANGLE_TRY(applyVertexBuffer(context, mode, 0, 0, 0, &indexInfo)); ANGLE_TRY(applyVertexBuffer(context, mode, 0, 0, 0, &indexInfo));
......
...@@ -470,10 +470,6 @@ class Renderer11 : public RendererD3D ...@@ -470,10 +470,6 @@ class Renderer11 : public RendererD3D
gl::Error clearRenderTarget(RenderTargetD3D *renderTarget, gl::Error clearRenderTarget(RenderTargetD3D *renderTarget,
const gl::ColorF &clearValues) override; const gl::ColorF &clearValues) override;
protected:
// Support direct drawing with the drawing parameters.
bool supportsDirectDrawing(const gl::Context *context, GLenum mode, GLenum type) const override;
private: private:
gl::Error drawArraysImpl(const gl::Context *context, gl::Error drawArraysImpl(const gl::Context *context,
GLenum mode, GLenum mode,
...@@ -550,6 +546,8 @@ class Renderer11 : public RendererD3D ...@@ -550,6 +546,8 @@ class Renderer11 : public RendererD3D
d3d11::ANGLED3D11DeviceType getDeviceType() const; d3d11::ANGLED3D11DeviceType getDeviceType() const;
bool drawCallNeedsTranslation(const gl::Context *context, GLenum mode, GLenum type) const;
HMODULE mD3d11Module; HMODULE mD3d11Module;
HMODULE mDxgiModule; HMODULE mDxgiModule;
HMODULE mDCompModule; HMODULE mDCompModule;
......
...@@ -3197,13 +3197,6 @@ gl::Error Renderer9::genericDrawArrays(const gl::Context *context, ...@@ -3197,13 +3197,6 @@ gl::Error Renderer9::genericDrawArrays(const gl::Context *context,
return gl::NoError(); return gl::NoError();
} }
bool Renderer9::supportsDirectDrawing(const gl::Context *context, GLenum mode, GLenum type) const
{
// TODO(jiajia.qin@intel.com): Add direct drawing for d3d9
UNIMPLEMENTED();
return false;
}
FramebufferImpl *Renderer9::createDefaultFramebuffer(const gl::FramebufferState &state) FramebufferImpl *Renderer9::createDefaultFramebuffer(const gl::FramebufferState &state)
{ {
return new Framebuffer9(state, this); return new Framebuffer9(state, this);
......
...@@ -397,10 +397,6 @@ class Renderer9 : public RendererD3D ...@@ -397,10 +397,6 @@ class Renderer9 : public RendererD3D
gl::Error clearRenderTarget(RenderTargetD3D *renderTarget, gl::Error clearRenderTarget(RenderTargetD3D *renderTarget,
const gl::ColorF &clearValues) override; const gl::ColorF &clearValues) override;
protected:
// Support direct drawing with the drawing parameters.
bool supportsDirectDrawing(const gl::Context *context, GLenum mode, GLenum type) const override;
private: private:
gl::Error drawArraysImpl(const gl::ContextState &data, gl::Error drawArraysImpl(const gl::ContextState &data,
GLenum mode, GLenum mode,
......
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