Commit 76b10c9a by Geoff Lang

Use dynamically sized containers for texture and sampler bindings.

BUG=angle:685 Change-Id: I7af97a95deee69fbdebca2b57403244f45516e67 Reviewed-on: https://chromium-review.googlesource.com/216564Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent ac7579c2
......@@ -115,10 +115,7 @@ class Context
void bindArrayBuffer(GLuint buffer);
void bindElementArrayBuffer(GLuint buffer);
void bindTexture2D(GLuint texture);
void bindTextureCubeMap(GLuint texture);
void bindTexture3D(GLuint texture);
void bindTexture2DArray(GLuint texture);
void bindTexture(GLenum target, GLuint texture);
void bindReadFramebuffer(GLuint framebuffer);
void bindDrawFramebuffer(GLuint framebuffer);
void bindRenderbuffer(GLuint renderbuffer);
......@@ -170,7 +167,7 @@ class Context
Texture3D *getTexture3D() const;
Texture2DArray *getTexture2DArray() const;
Texture *getSamplerTexture(unsigned int sampler, TextureType type) const;
Texture *getSamplerTexture(unsigned int sampler, GLenum type) const;
bool isSampler(GLuint samplerName) const;
......@@ -237,9 +234,9 @@ class Context
void applyRenderTarget(GLenum drawMode, bool ignoreViewport);
void applyState(GLenum drawMode);
void applyShaders(ProgramBinary *programBinary, bool transformFeedbackActive);
void applyTextures(SamplerType shaderType, Texture *textures[], TextureType *textureTypes, SamplerState *samplers,
size_t textureCount, const FramebufferTextureSerialArray& framebufferSerials,
void applyTextures(ProgramBinary *programBinary, SamplerType shaderType, const FramebufferTextureSerialArray &framebufferSerials,
size_t framebufferSerialCount);
void applyTextures(ProgramBinary *programBinary);
bool applyUniformBuffers();
bool applyTransformFeedbackBuffers();
void markTransformFeedbackUsage();
......@@ -252,10 +249,10 @@ class Context
void detachTransformFeedback(GLuint transformFeedback);
void detachSampler(GLuint sampler);
void generateSwizzles(Texture *textures[], size_t count);
size_t getCurrentTexturesAndSamplerStates(ProgramBinary *programBinary, SamplerType type, Texture **outTextures,
TextureType *outTextureTypes, SamplerState *outSamplers);
Texture *getIncompleteTexture(TextureType type);
void generateSwizzles(ProgramBinary *programBinary, SamplerType type);
void generateSwizzles(ProgramBinary *programBinary);
Texture *getIncompleteTexture(GLenum type);
bool skipDraw(GLenum drawMode);
......@@ -276,10 +273,9 @@ class Context
int mClientVersion;
BindingPointer<Texture2D> mTexture2DZero;
BindingPointer<TextureCubeMap> mTextureCubeMapZero;
BindingPointer<Texture3D> mTexture3DZero;
BindingPointer<Texture2DArray> mTexture2DArrayZero;
typedef std::map< GLenum, BindingPointer<Texture> > TextureMap;
TextureMap mZeroTextures;
TextureMap mIncompleteTextures;
typedef std::unordered_map<GLuint, Framebuffer*> FramebufferMap;
FramebufferMap mFramebufferMap;
......@@ -306,8 +302,6 @@ class Context
std::string mExtensionString;
std::vector<std::string> mExtensionStrings;
BindingPointer<Texture> mIncompleteTextures[TEXTURE_TYPE_COUNT];
// Recorded errors
typedef std::set<GLenum> ErrorSet;
ErrorSet mErrors;
......
......@@ -110,7 +110,7 @@ class ProgramBinary : public RefCountObject
int getSemanticIndex(int attributeIndex);
GLint getSamplerMapping(SamplerType type, unsigned int samplerIndex, const Caps &caps);
TextureType getSamplerTextureType(SamplerType type, unsigned int samplerIndex);
GLenum getSamplerTextureType(SamplerType type, unsigned int samplerIndex);
GLint getUsedSamplerRange(SamplerType type);
bool usesPointSize() const;
bool usesPointSpriteEmulation() const;
......@@ -205,7 +205,7 @@ class ProgramBinary : public RefCountObject
bool active;
GLint logicalTextureUnit;
TextureType textureType;
GLenum textureType;
};
void reset();
......@@ -227,7 +227,7 @@ class ProgramBinary : public RefCountObject
bool indexSamplerUniform(const LinkedUniform &uniform, InfoLog &infoLog, const Caps &caps);
bool indexUniforms(InfoLog &infoLog, const Caps &caps);
static bool assignSamplers(unsigned int startSamplerIndex, GLenum samplerType, unsigned int samplerCount,
Sampler *outArray, GLuint *usedRange, unsigned int limit);
std::vector<Sampler> &outSamplers, GLuint *outUsedRange);
bool areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock, const sh::InterfaceBlock &fragmentInterfaceBlock);
bool linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShader, const Shader &fragmentShader, const Caps &caps);
bool gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, const std::vector<LinkedVarying> &linkedVaryings,
......@@ -303,8 +303,8 @@ class ProgramBinary : public RefCountObject
GLenum mTransformFeedbackBufferMode;
std::vector<LinkedVarying> mTransformFeedbackLinkedVaryings;
Sampler mSamplersPS[MAX_TEXTURE_IMAGE_UNITS];
Sampler mSamplersVS[IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
std::vector<Sampler> mSamplersPS;
std::vector<Sampler> mSamplersVS;
GLuint mUsedVertexSamplerRange;
GLuint mUsedPixelSamplerRange;
bool mUsesPointSize;
......
......@@ -366,25 +366,25 @@ void ResourceManager::checkBufferAllocation(unsigned int buffer)
}
}
void ResourceManager::checkTextureAllocation(GLuint texture, TextureType type)
void ResourceManager::checkTextureAllocation(GLuint texture, GLenum type)
{
if (!getTexture(texture) && texture != 0)
{
Texture *textureObject;
if (type == TEXTURE_2D)
if (type == GL_TEXTURE_2D)
{
textureObject = new Texture2D(mRenderer->createTexture(GL_TEXTURE_2D), texture);
}
else if (type == TEXTURE_CUBE)
else if (type == GL_TEXTURE_CUBE_MAP)
{
textureObject = new TextureCubeMap(mRenderer->createTexture(GL_TEXTURE_CUBE_MAP), texture);
}
else if (type == TEXTURE_3D)
else if (type == GL_TEXTURE_3D)
{
textureObject = new Texture3D(mRenderer->createTexture(GL_TEXTURE_3D), texture);
}
else if (type == TEXTURE_2D_ARRAY)
else if (type == GL_TEXTURE_2D_ARRAY)
{
textureObject = new Texture2DArray(mRenderer->createTexture(GL_TEXTURE_2D_ARRAY), texture);
}
......
......@@ -69,7 +69,7 @@ class ResourceManager
void setRenderbuffer(GLuint handle, Renderbuffer *renderbuffer);
void checkBufferAllocation(unsigned int buffer);
void checkTextureAllocation(GLuint texture, TextureType type);
void checkTextureAllocation(GLuint texture, GLenum type);
void checkRenderbufferAllocation(GLuint renderbuffer);
void checkSamplerAllocation(GLuint sampler);
......
......@@ -9,6 +9,7 @@
#include "libGLESv2/State.h"
#include "libGLESv2/Context.h"
#include "libGLESv2/Caps.h"
#include "libGLESv2/VertexArray.h"
#include "libGLESv2/Query.h"
#include "libGLESv2/Framebuffer.h"
......@@ -18,8 +19,18 @@
namespace gl
{
State::State()
{
}
State::~State()
{
reset();
}
void State::initialize(const Caps& caps, GLuint clientVersion)
{
mContext = NULL;
setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
......@@ -65,7 +76,7 @@ State::State()
mDepthStencil.stencilMask = -1;
mDepthStencil.stencilWritemask = -1;
mDepthStencil.stencilBackFunc = GL_ALWAYS;
mDepthStencil.stencilBackMask = - 1;
mDepthStencil.stencilBackMask = -1;
mDepthStencil.stencilBackWritemask = -1;
mDepthStencil.stencilFail = GL_KEEP;
mDepthStencil.stencilPassDepthFail = GL_KEEP;
......@@ -97,18 +108,24 @@ State::State()
mBlend.colorMaskBlue = true;
mBlend.colorMaskAlpha = true;
mActiveSampler = 0;
const GLfloat defaultFloatValues[] = { 0.0f, 0.0f, 0.0f, 1.0f };
for (int attribIndex = 0; attribIndex < MAX_VERTEX_ATTRIBS; attribIndex++)
{
mVertexAttribCurrentValues[attribIndex].setFloatValues(defaultFloatValues);
}
for (unsigned int textureUnit = 0; textureUnit < ArraySize(mSamplers); textureUnit++)
mSamplerTextures[GL_TEXTURE_2D].resize(caps.maxCombinedTextureImageUnits);
mSamplerTextures[GL_TEXTURE_CUBE_MAP].resize(caps.maxCombinedTextureImageUnits);
if (clientVersion >= 3)
{
mSamplers[textureUnit].set(NULL);
// TODO: These could also be enabled via extension
mSamplerTextures[GL_TEXTURE_2D_ARRAY].resize(caps.maxCombinedTextureImageUnits);
mSamplerTextures[GL_TEXTURE_3D].resize(caps.maxCombinedTextureImageUnits);
}
mActiveSampler = 0;
mSamplers.resize(caps.maxCombinedTextureImageUnits);
mActiveQueries[GL_ANY_SAMPLES_PASSED].set(NULL);
mActiveQueries[GL_ANY_SAMPLES_PASSED_CONSERVATIVE].set(NULL);
......@@ -121,14 +138,19 @@ State::State()
mDrawFramebuffer = NULL;
}
State::~State()
void State::reset()
{
for (int type = 0; type < TEXTURE_TYPE_COUNT; type++)
for (TextureBindingMap::iterator bindingVec = mSamplerTextures.begin(); bindingVec != mSamplerTextures.end(); bindingVec++)
{
for (int sampler = 0; sampler < IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS; sampler++)
TextureBindingVector &textureVector = bindingVec->second;
for (size_t textureIdx = 0; textureIdx < textureVector.size(); textureIdx++)
{
mSamplerTexture[type][sampler].set(NULL);
textureVector[textureIdx].set(NULL);
}
}
for (size_t samplerIdx = 0; samplerIdx < mSamplers.size(); samplerIdx++)
{
mSamplers[samplerIdx].set(NULL);
}
const GLfloat defaultFloatValues[] = { 0.0f, 0.0f, 0.0f, 1.0f };
......@@ -583,26 +605,26 @@ unsigned int State::getActiveSampler() const
return mActiveSampler;
}
void State::setSamplerTexture(TextureType type, Texture *texture)
void State::setSamplerTexture(GLenum type, Texture *texture)
{
mSamplerTexture[type][mActiveSampler].set(texture);
mSamplerTextures[type][mActiveSampler].set(texture);
}
Texture *State::getSamplerTexture(unsigned int sampler, TextureType type) const
Texture *State::getSamplerTexture(unsigned int sampler, GLenum type) const
{
GLuint texid = mSamplerTexture[type][sampler].id();
const BindingPointer<Texture>& binding = mSamplerTextures.at(type)[sampler];
if (texid == 0) // Special case: 0 refers to default textures held by Context
if (binding.id() == 0) // Special case: 0 refers to default textures held by Context
{
return NULL;
}
return mSamplerTexture[type][sampler].get();
return binding.get();
}
GLuint State::getSamplerTextureId(unsigned int sampler, TextureType type) const
GLuint State::getSamplerTextureId(unsigned int sampler, GLenum type) const
{
return mSamplerTexture[type][sampler].id();
return mSamplerTextures.at(type)[sampler].id();
}
void State::detachTexture(GLuint texture)
......@@ -616,13 +638,15 @@ void State::detachTexture(GLuint texture)
// If a texture object is deleted, it is as if all texture units which are bound to that texture object are
// rebound to texture object zero
for (int type = 0; type < TEXTURE_TYPE_COUNT; type++)
for (TextureBindingMap::iterator bindingVec = mSamplerTextures.begin(); bindingVec != mSamplerTextures.end(); bindingVec++)
{
for (int sampler = 0; sampler < IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS; sampler++)
TextureBindingVector &textureVector = bindingVec->second;
for (size_t textureIdx = 0; textureIdx < textureVector.size(); textureIdx++)
{
if (mSamplerTexture[type][sampler].id() == texture)
BindingPointer<Texture> &binding = textureVector[textureIdx];
if (binding.id() == texture)
{
mSamplerTexture[type][sampler].set(NULL);
binding.set(NULL);
}
}
}
......@@ -650,7 +674,7 @@ void State::setSamplerBinding(GLuint textureUnit, Sampler *sampler)
GLuint State::getSamplerId(GLuint textureUnit) const
{
ASSERT(textureUnit < ArraySize(mSamplers));
ASSERT(textureUnit < mSamplers.size());
return mSamplers[textureUnit].id();
}
......@@ -665,11 +689,12 @@ void State::detachSampler(GLuint sampler)
// If a sampler object that is currently bound to one or more texture units is
// deleted, it is as though BindSampler is called once for each texture unit to
// which the sampler is bound, with unit set to the texture unit and sampler set to zero.
for (unsigned int textureUnit = 0; textureUnit < ArraySize(mSamplers); textureUnit++)
for (size_t textureUnit = 0; textureUnit < mSamplers.size(); textureUnit++)
{
if (mSamplers[textureUnit].id() == sampler)
BindingPointer<Sampler> &samplerBinding = mSamplers[textureUnit];
if (samplerBinding.id() == sampler)
{
mSamplers[textureUnit].set(NULL);
samplerBinding.set(NULL);
}
}
}
......@@ -1308,19 +1333,19 @@ void State::getIntegerv(GLenum pname, GLint *params)
break;
case GL_TEXTURE_BINDING_2D:
ASSERT(mActiveSampler < mContext->getCaps().maxCombinedTextureImageUnits);
*params = mSamplerTexture[TEXTURE_2D][mActiveSampler].id();
*params = mSamplerTextures.at(GL_TEXTURE_2D)[mActiveSampler].id();
break;
case GL_TEXTURE_BINDING_CUBE_MAP:
ASSERT(mActiveSampler < mContext->getCaps().maxCombinedTextureImageUnits);
*params = mSamplerTexture[TEXTURE_CUBE][mActiveSampler].id();
*params = mSamplerTextures.at(GL_TEXTURE_CUBE_MAP)[mActiveSampler].id();
break;
case GL_TEXTURE_BINDING_3D:
ASSERT(mActiveSampler <mContext->getCaps().maxCombinedTextureImageUnits);
*params = mSamplerTexture[TEXTURE_3D][mActiveSampler].id();
*params = mSamplerTextures.at(GL_TEXTURE_3D)[mActiveSampler].id();
break;
case GL_TEXTURE_BINDING_2D_ARRAY:
ASSERT(mActiveSampler < mContext->getCaps().maxCombinedTextureImageUnits);
*params = mSamplerTexture[TEXTURE_2D_ARRAY][mActiveSampler].id();
*params = mSamplerTextures.at(GL_TEXTURE_2D_ARRAY)[mActiveSampler].id();
break;
case GL_UNIFORM_BUFFER_BINDING:
*params = mGenericUniformBuffer.id();
......
......@@ -24,6 +24,7 @@ namespace gl
class Query;
class VertexArray;
class Context;
struct Caps;
class State
{
......@@ -31,6 +32,9 @@ class State
State();
~State();
void initialize(const Caps& caps, GLuint clientVersion);
void reset();
void setContext(Context *context) { mContext = context; }
// State chunk getters
......@@ -126,9 +130,9 @@ class State
// Texture binding & active texture unit manipulation
void setActiveSampler(unsigned int active);
unsigned int getActiveSampler() const;
void setSamplerTexture(TextureType type, Texture *texture);
Texture *getSamplerTexture(unsigned int sampler, TextureType type) const;
GLuint getSamplerTextureId(unsigned int sampler, TextureType type) const;
void setSamplerTexture(GLenum type, Texture *texture);
Texture *getSamplerTexture(unsigned int sampler, GLenum type) const;
GLuint getSamplerTextureId(unsigned int sampler, GLenum type) const;
void detachTexture(GLuint texture);
// Sampler object binding manipulation
......@@ -272,7 +276,6 @@ class State
float mNearZ;
float mFarZ;
unsigned int mActiveSampler; // Active texture unit selector - GL_TEXTURE0
BindingPointer<Buffer> mArrayBuffer;
Framebuffer *mReadFramebuffer;
Framebuffer *mDrawFramebuffer;
......@@ -283,8 +286,15 @@ class State
VertexAttribCurrentValueData mVertexAttribCurrentValues[MAX_VERTEX_ATTRIBS]; // From glVertexAttrib
VertexArray *mVertexArray;
BindingPointer<Texture> mSamplerTexture[TEXTURE_TYPE_COUNT][IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS];
BindingPointer<Sampler> mSamplers[IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS];
// Texture and sampler bindings
size_t mActiveSampler; // Active texture unit selector - GL_TEXTURE0
typedef std::vector< BindingPointer<Texture> > TextureBindingVector;
typedef std::map<GLenum, TextureBindingVector> TextureBindingMap;
TextureBindingMap mSamplerTextures;
typedef std::vector< BindingPointer<Sampler> > SamplerBindingVector;
SamplerBindingVector mSamplers;
typedef std::map< GLenum, BindingPointer<Query> > ActiveQueryMap;
ActiveQueryMap mActiveQueries;
......
......@@ -19,17 +19,6 @@ class ProgramBinary;
struct VertexAttribute;
struct VertexAttribCurrentValueData;
enum TextureType
{
TEXTURE_2D,
TEXTURE_CUBE,
TEXTURE_3D,
TEXTURE_2D_ARRAY,
TEXTURE_TYPE_COUNT,
TEXTURE_UNKNOWN
};
enum SamplerType
{
SAMPLER_PIXEL,
......
......@@ -15,12 +15,8 @@ namespace gl
enum
{
MAX_VERTEX_ATTRIBS = 16,
MAX_TEXTURE_IMAGE_UNITS = 16,
// Implementation upper limits, real maximums depend on the hardware
IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 16,
IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS = MAX_TEXTURE_IMAGE_UNITS + IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS,
IMPLEMENTATION_MAX_VARYING_VECTORS = 32,
IMPLEMENTATION_MAX_DRAW_BUFFERS = 8,
IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS = IMPLEMENTATION_MAX_DRAW_BUFFERS + 2, // 2 extra for depth and/or stencil buffers
......
......@@ -265,35 +265,24 @@ void __stdcall glBindTexture(GLenum target, GLuint texture)
switch (target)
{
case GL_TEXTURE_2D:
context->bindTexture2D(texture);
return;
case GL_TEXTURE_CUBE_MAP:
context->bindTextureCubeMap(texture);
return;
break;
case GL_TEXTURE_3D:
if (context->getClientVersion() < 3)
{
context->recordError(gl::Error(GL_INVALID_ENUM));
return;
}
context->bindTexture3D(texture);
return;
case GL_TEXTURE_2D_ARRAY:
if (context->getClientVersion() < 3)
{
context->recordError(gl::Error(GL_INVALID_ENUM));
return;
}
context->bindTexture2DArray(texture);
return;
break;
default:
context->recordError(gl::Error(GL_INVALID_ENUM));
return;
}
context->bindTexture(target, texture);
}
}
......
......@@ -315,6 +315,17 @@ void Renderer11::initializeDevice()
ASSERT(!mPixelTransfer);
mPixelTransfer = new PixelTransfer11(this);
const gl::Caps &rendererCaps = getRendererCaps();
mForceSetVertexSamplerStates.resize(rendererCaps.maxVertexTextureImageUnits);
mCurVertexSamplerStates.resize(rendererCaps.maxVertexTextureImageUnits);
mForceSetPixelSamplerStates.resize(rendererCaps.maxTextureImageUnits);
mCurPixelSamplerStates.resize(rendererCaps.maxTextureImageUnits);
mCurVertexSRVs.resize(rendererCaps.maxVertexTextureImageUnits);
mCurPixelSRVs.resize(rendererCaps.maxTextureImageUnits);
markAllStateDirty();
}
......@@ -1556,12 +1567,15 @@ void Renderer11::markAllStateDirty()
mDepthStencilInitialized = false;
mRenderTargetDescInitialized = false;
for (int i = 0; i < gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS; i++)
ASSERT(mForceSetVertexSamplerStates.size() == mCurVertexSRVs.size());
for (int i = 0; i < mForceSetVertexSamplerStates.size(); i++)
{
mForceSetVertexSamplerStates[i] = true;
mCurVertexSRVs[i] = NULL;
}
for (int i = 0; i < gl::MAX_TEXTURE_IMAGE_UNITS; i++)
ASSERT(mForceSetPixelSamplerStates.size() == mCurPixelSRVs.size());
for (int i = 0; i < mForceSetPixelSamplerStates.size(); i++)
{
mForceSetPixelSamplerStates[i] = true;
mCurPixelSRVs[i] = NULL;
......
......@@ -245,15 +245,15 @@ class Renderer11 : public Renderer
rx::RenderTarget::Desc mRenderTargetDesc;
// Currently applied sampler states
bool mForceSetVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
gl::SamplerState mCurVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
std::vector<bool> mForceSetVertexSamplerStates;
std::vector<gl::SamplerState> mCurVertexSamplerStates;
bool mForceSetPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
gl::SamplerState mCurPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
std::vector<bool> mForceSetPixelSamplerStates;
std::vector<gl::SamplerState> mCurPixelSamplerStates;
// Currently applied textures
ID3D11ShaderResourceView *mCurVertexSRVs[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
ID3D11ShaderResourceView *mCurPixelSRVs[gl::MAX_TEXTURE_IMAGE_UNITS];
std::vector<ID3D11ShaderResourceView*> mCurVertexSRVs;
std::vector<ID3D11ShaderResourceView*> mCurPixelSRVs;
// Currently applied blend state
bool mForceSetBlendState;
......
......@@ -944,7 +944,7 @@ void GenerateCaps(ID3D11Device *device, gl::Caps *caps, gl::TextureCapsMap *text
static_cast<GLint64>(caps->maxFragmentUniformComponents);
caps->maxVaryingComponents = GetMaximumVertexOutputVectors(featureLevel) * 4;
caps->maxVaryingVectors = GetMaximumVertexOutputVectors(featureLevel);
caps->maxCombinedTextureImageUnits = caps->maxVertexTextureImageUnits + caps->maxFragmentInputComponents;
caps->maxCombinedTextureImageUnits = caps->maxVertexTextureImageUnits + caps->maxTextureImageUnits;
// Transform feedback limits
caps->maxTransformFeedbackInterleavedComponents = GetMaximumStreamOutputInterleavedComponenets(featureLevel);
......
......@@ -379,6 +379,17 @@ void Renderer9::initializeDevice()
mDevice->SetRenderState(D3DRS_POINTSIZE_MAX, 0x3F800000); // 1.0f
}
const gl::Caps &rendererCaps = getRendererCaps();
mForceSetVertexSamplerStates.resize(rendererCaps.maxVertexTextureImageUnits);
mCurVertexSamplerStates.resize(rendererCaps.maxVertexTextureImageUnits);
mForceSetPixelSamplerStates.resize(rendererCaps.maxTextureImageUnits);
mCurPixelSamplerStates.resize(rendererCaps.maxTextureImageUnits);
mCurVertexTextureSerials.resize(rendererCaps.maxVertexTextureImageUnits);
mCurPixelTextureSerials.resize(rendererCaps.maxTextureImageUnits);
markAllStateDirty();
mSceneStarted = false;
......@@ -633,8 +644,8 @@ void Renderer9::generateSwizzle(gl::Texture *texture)
void Renderer9::setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &samplerState)
{
bool *forceSetSamplers = (type == gl::SAMPLER_PIXEL) ? mForceSetPixelSamplerStates : mForceSetVertexSamplerStates;
gl::SamplerState *appliedSamplers = (type == gl::SAMPLER_PIXEL) ? mCurPixelSamplerStates: mCurVertexSamplerStates;
std::vector<bool> &forceSetSamplers = (type == gl::SAMPLER_PIXEL) ? mForceSetPixelSamplerStates : mForceSetVertexSamplerStates;
std::vector<gl::SamplerState> &appliedSamplers = (type == gl::SAMPLER_PIXEL) ? mCurPixelSamplerStates: mCurVertexSamplerStates;
if (forceSetSamplers[index] || memcmp(&samplerState, &appliedSamplers[index], sizeof(gl::SamplerState)) != 0)
{
......@@ -668,7 +679,7 @@ void Renderer9::setTexture(gl::SamplerType type, int index, gl::Texture *texture
unsigned int serial = 0;
bool forceSetTexture = false;
unsigned int *appliedSerials = (type == gl::SAMPLER_PIXEL) ? mCurPixelTextureSerials : mCurVertexTextureSerials;
std::vector<unsigned int> &appliedSerials = (type == gl::SAMPLER_PIXEL) ? mCurPixelTextureSerials : mCurVertexTextureSerials;
if (texture)
{
......@@ -2022,12 +2033,15 @@ void Renderer9::markAllStateDirty()
mForceSetViewport = true;
mForceSetBlendState = true;
for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS; i++)
ASSERT(mForceSetVertexSamplerStates.size() == mCurVertexTextureSerials.size());
for (unsigned int i = 0; i < mForceSetVertexSamplerStates.size(); i++)
{
mForceSetVertexSamplerStates[i] = true;
mCurVertexTextureSerials[i] = 0;
}
for (unsigned int i = 0; i < gl::MAX_TEXTURE_IMAGE_UNITS; i++)
ASSERT(mForceSetPixelSamplerStates.size() == mCurPixelTextureSerials.size());
for (unsigned int i = 0; i < mForceSetPixelSamplerStates.size(); i++)
{
mForceSetPixelSamplerStates[i] = true;
mCurPixelTextureSerials[i] = 0;
......@@ -3084,10 +3098,7 @@ TextureImpl *Renderer9::createTexture(GLenum target)
{
case GL_TEXTURE_2D: return new TextureD3D_2D(this);
case GL_TEXTURE_CUBE_MAP: return new TextureD3D_Cube(this);
case GL_TEXTURE_3D: return new TextureD3D_3D(this);
case GL_TEXTURE_2D_ARRAY: return new TextureD3D_2DArray(this);
default:
UNREACHABLE();
default: UNREACHABLE();
}
return NULL;
......
......@@ -295,15 +295,15 @@ class Renderer9 : public Renderer
GLuint mCurSampleMask;
// Currently applied sampler states
bool mForceSetVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
gl::SamplerState mCurVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
std::vector<bool> mForceSetVertexSamplerStates;
std::vector<gl::SamplerState> mCurVertexSamplerStates;
bool mForceSetPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
gl::SamplerState mCurPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
std::vector<bool> mForceSetPixelSamplerStates;
std::vector<gl::SamplerState> mCurPixelSamplerStates;
// Currently applied textures
unsigned int mCurVertexTextureSerials[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
unsigned int mCurPixelTextureSerials[gl::MAX_TEXTURE_IMAGE_UNITS];
std::vector<unsigned int> mCurVertexTextureSerials;
std::vector<unsigned int> mCurPixelTextureSerials;
unsigned int mAppliedIBSerial;
IDirect3DVertexShader9 *mAppliedVertexShader;
......
......@@ -436,7 +436,7 @@ void GenerateCaps(IDirect3D9 *d3d9, IDirect3DDevice9 *device, D3DDEVTYPE deviceT
// Aggregate shader limits
caps->maxVaryingVectors = caps->maxVertexOutputComponents / 4;
caps->maxCombinedTextureImageUnits = caps->maxVertexTextureImageUnits + caps->maxFragmentInputComponents;
caps->maxCombinedTextureImageUnits = caps->maxVertexTextureImageUnits + caps->maxTextureImageUnits;
// Transform feedback limits
caps->maxTransformFeedbackInterleavedComponents = 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