Bug 697333 - Update ANGLE to r809 - no review

This is just syncing us with the upstream,

  http://code.google.com/p/angleproject/

This gets us two important fixes, for bug 676071 and bug 694495.
This commit is contained in:
Benoit Jacob 2011-11-02 00:56:35 -04:00
parent da408a739b
commit 37f9e79d9c
24 changed files with 952 additions and 899 deletions

View File

@ -126,7 +126,7 @@ CSRCS = \
tokens.c \
$(NULL)
DEFINES += -DANGLE_USE_NSPR -DANGLE_BUILD
DEFINES += -DANGLE_USE_NSPR -DANGLE_BUILD -DCOMPILER_IMPLEMENTATION
#these defines are from ANGLE's build_angle.gyp
DEFINES += -DANGLE_DISABLE_TRACE

View File

@ -1,6 +1,6 @@
This is the ANGLE project, from http://code.google.com/p/angleproject/
Current revision: r802
Current revision: r809
== Applied local patches ==

View File

@ -1,40 +1,5 @@
# HG changeset patch
# Parent cf38970fcf3b4bee12f09b3747b7b7711bc77ad8
diff --git a/gfx/angle/angle-renaming-debug.patch b/gfx/angle/angle-renaming-debug.patch
--- a/gfx/angle/angle-renaming-debug.patch
+++ b/gfx/angle/angle-renaming-debug.patch
@@ -1,11 +1,10 @@
# HG changeset patch
-# Parent 96359f46b01fdb37e791f564495e8b2755a05233
-
+# Parent 70640278da97b0ca49e21c4bb52766b8af7db4db
diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
--- a/gfx/angle/Makefile.in
+++ b/gfx/angle/Makefile.in
@@ -73,17 +73,17 @@ CPPSRCS = \
parseConst.cpp \
ParseHelper.cpp \
PoolAlloc.cpp \
QualifierAlive.cpp \
@@ -129,17 +128,17 @@ diff --git a/gfx/angle/src/compiler/comp
#include <assert.h>
#ifdef _DEBUG
#define TRACE_ENABLED // define to enable debug message tracing
diff --git a/gfx/angle/src/compiler/osinclude.h b/gfx/angle/src/compiler/osinclude.h
--- a/gfx/angle/src/compiler/osinclude.h
+++ b/gfx/angle/src/compiler/osinclude.h
-@@ -32,17 +32,17 @@
+@@ -30,17 +30,17 @@
#include <windows.h>
#elif defined(ANGLE_OS_POSIX)
#include <pthread.h>
#include <semaphore.h>
#include <errno.h>
#endif // ANGLE_USE_NSPR
# Parent b5604c321da4e3b5d6b0a940d18022a827061579
diff --git a/gfx/angle/src/libGLESv2/Texture.cpp b/gfx/angle/src/libGLESv2/Texture.cpp
--- a/gfx/angle/src/libGLESv2/Texture.cpp
+++ b/gfx/angle/src/libGLESv2/Texture.cpp

View File

@ -1,15 +1,36 @@
# HG changeset patch
# Parent f9415c10c3ebd27856500cca7a0ee0f28a16f53c
diff --git a/gfx/angle/src/compiler/preprocessor/scanner.h b/gfx/angle/src/compiler/preprocessor/scanner.h
--- a/gfx/angle/src/compiler/preprocessor/scanner.h
+++ b/gfx/angle/src/compiler/preprocessor/scanner.h
@@ -44,17 +44,19 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILI
//
// scanner.h
//
# Parent e8b87ef36a1dae3bbd7abb13c4bb0a0bb8f5b58c
diff --git a/gfx/angle/README.mozilla b/gfx/angle/README.mozilla
--- a/gfx/angle/README.mozilla
+++ b/gfx/angle/README.mozilla
@@ -2,16 +2,17 @@ This is the ANGLE project, from http://c
#if !defined(__SCANNER_H)
#define __SCANNER_H 1
Current revision: r802
== Applied local patches ==
In this order:
angle-renaming-debug.patch - rename debug.h to compilerdebug.h to avoid conflict in our makefiles
angle-intrinsic-msvc2005.patch - work around a MSVC 2005 compile error
+ angle-limit-identifiers-to-250-chars.patch - see bug 675625
In addition to these patches, the Makefile.in files are ours, they're not present in upsteam ANGLE.
== How to update this ANGLE copy ==
1. Unapply patches
2. Apply diff with new ANGLE version
3. Reapply patches.
diff --git a/gfx/angle/src/compiler/preprocessor/length_limits.h b/gfx/angle/src/compiler/preprocessor/length_limits.h
--- a/gfx/angle/src/compiler/preprocessor/length_limits.h
+++ b/gfx/angle/src/compiler/preprocessor/length_limits.h
@@ -10,12 +10,14 @@
#if !defined(__LENGTH_LIMITS_H)
#define __LENGTH_LIMITS_H 1
// These constants are factored out from the rest of the headers to
// make it easier to reference them from the compiler sources.
// These lengths do not include the NULL terminator.
-#define MAX_SYMBOL_NAME_LEN 256
@ -18,9 +39,4 @@ diff --git a/gfx/angle/src/compiler/preprocessor/scanner.h b/gfx/angle/src/compi
+#define MAX_SYMBOL_NAME_LEN 250
#define MAX_STRING_LEN 511
#include "compiler/preprocessor/parser.h"
// Not really atom table stuff but needed first...
typedef struct SourceLoc_Rec {
unsigned short file, line;
#endif // !(defined(__LENGTH_LIMITS_H)

View File

@ -1,5 +1,5 @@
# HG changeset patch
# Parent 70640278da97b0ca49e21c4bb52766b8af7db4db
# Parent 0239f15c7212413b5cffe66aee9ae5a4feb28f16
diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
--- a/gfx/angle/Makefile.in
+++ b/gfx/angle/Makefile.in

View File

@ -17,6 +17,9 @@
'.',
'../include',
],
'defines': [
'COMPILER_IMPLEMENTATION',
],
'sources': [
'compiler/BaseTypes.h',
'compiler/BuiltInFunctionEmulator.cpp',
@ -60,7 +63,6 @@
'compiler/QualifierAlive.h',
'compiler/RemoveTree.cpp',
'compiler/RemoveTree.h',
'compiler/ShaderLang.cpp',
'compiler/ShHandle.h',
'compiler/SymbolTable.cpp',
'compiler/SymbolTable.h',
@ -77,6 +79,7 @@
'compiler/preprocessor/cpp.c',
'compiler/preprocessor/cpp.h',
'compiler/preprocessor/cppstruct.c',
'compiler/preprocessor/length_limits.h',
'compiler/preprocessor/memory.c',
'compiler/preprocessor/memory.h',
'compiler/preprocessor/parser.h',
@ -99,12 +102,15 @@
},
{
'target_name': 'translator_glsl',
'type': 'static_library',
'type': '<(component)',
'dependencies': ['translator_common'],
'include_dirs': [
'.',
'../include',
],
'defines': [
'COMPILER_IMPLEMENTATION',
],
'sources': [
'compiler/CodeGenGLSL.cpp',
'compiler/OutputESSL.cpp',
@ -113,6 +119,7 @@
'compiler/OutputGLSLBase.h',
'compiler/OutputGLSL.cpp',
'compiler/OutputGLSL.h',
'compiler/ShaderLang.cpp',
'compiler/TranslatorESSL.cpp',
'compiler/TranslatorESSL.h',
'compiler/TranslatorGLSL.cpp',
@ -123,13 +130,17 @@
},
{
'target_name': 'translator_hlsl',
'type': 'static_library',
'type': '<(component)',
'dependencies': ['translator_common'],
'include_dirs': [
'.',
'../include',
],
'defines': [
'COMPILER_IMPLEMENTATION',
],
'sources': [
'compiler/ShaderLang.cpp',
'compiler/CodeGenHLSL.cpp',
'compiler/OutputHLSL.cpp',
'compiler/OutputHLSL.h',

View File

@ -1,7 +1,7 @@
#define MAJOR_VERSION 0
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 802
#define BUILD_REVISION 809
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2011 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.
//
@ -252,7 +252,7 @@ void TCompiler::mapLongVariableNames(TIntermNode* root)
int TCompiler::getMappedNameMaxLength() const
{
return MAX_IDENTIFIER_NAME_SIZE + 1;
return MAX_SHORTENED_IDENTIFIER_SIZE + 1;
}
const TExtensionBehavior& TCompiler::getExtensionBehavior() const

View File

@ -10,13 +10,13 @@ namespace {
TString mapLongName(int id, const TString& name, bool isVarying)
{
ASSERT(name.size() > MAX_IDENTIFIER_NAME_SIZE);
ASSERT(name.size() > MAX_SHORTENED_IDENTIFIER_SIZE);
TStringStream stream;
stream << "webgl_";
if (isVarying)
stream << "v";
stream << id << "_";
stream << name.substr(0, MAX_IDENTIFIER_NAME_SIZE - stream.str().size());
stream << name.substr(0, MAX_SHORTENED_IDENTIFIER_SIZE - stream.str().size());
return stream.str();
}
@ -31,7 +31,7 @@ MapLongVariableNames::MapLongVariableNames(
void MapLongVariableNames::visitSymbol(TIntermSymbol* symbol)
{
ASSERT(symbol != NULL);
if (symbol->getSymbol().size() > MAX_IDENTIFIER_NAME_SIZE) {
if (symbol->getSymbol().size() > MAX_SHORTENED_IDENTIFIER_SIZE) {
switch (symbol->getQualifier()) {
case EvqVaryingIn:
case EvqVaryingOut:

View File

@ -13,10 +13,10 @@
#include "compiler/VariableInfo.h"
// This size does not include '\0' in the end.
#define MAX_IDENTIFIER_NAME_SIZE 32
#define MAX_SHORTENED_IDENTIFIER_SIZE 32
// Traverses intermediate tree to map attributes and uniforms names that are
// longer than MAX_IDENTIFIER_NAME_SIZE to MAX_IDENTIFIER_NAME_SIZE.
// longer than MAX_SHORTENED_IDENTIFIER_SIZE to MAX_SHORTENED_IDENTIFIER_SIZE.
class MapLongVariableNames : public TIntermTraverser {
public:
MapLongVariableNames(std::map<std::string, std::string>& varyingLongNameMap);

View File

@ -1425,6 +1425,53 @@ TIntermTyped* TParseContext::addConstStruct(TString& identifier, TIntermTyped* n
return typedNode;
}
bool TParseContext::enterStructDeclaration(int line, const TString& identifier)
{
++structNestingLevel;
// Embedded structure definitions are not supported per GLSL ES spec.
// They aren't allowed in GLSL either, but we need to detect this here
// so we don't rely on the GLSL compiler to catch it.
if (structNestingLevel > 1) {
error(line, "", "Embedded struct definitions are not allowed", "");
return true;
}
return false;
}
void TParseContext::exitStructDeclaration()
{
--structNestingLevel;
}
namespace {
const int kWebGLMaxStructNesting = 4;
} // namespace
bool TParseContext::structNestingErrorCheck(TSourceLoc line, const TType& fieldType)
{
if (shaderSpec != SH_WEBGL_SPEC) {
return false;
}
if (fieldType.getBasicType() != EbtStruct) {
return false;
}
// We're already inside a structure definition at this point, so add
// one to the field's struct nesting.
if (1 + fieldType.getDeepestStructNesting() >= kWebGLMaxStructNesting) {
error(line, "", "", "Reference of struct type %s exceeds maximum struct nesting of %d",
fieldType.getTypeName().c_str(), kWebGLMaxStructNesting);
return true;
}
return false;
}
//
// Parse an array of strings using yyparse.
//

View File

@ -31,9 +31,25 @@ struct TPragma {
//
struct TParseContext {
TParseContext(TSymbolTable& symt, TExtensionBehavior& ext, TIntermediate& interm, ShShaderType type, ShShaderSpec spec, int options, bool checksPrecErrors, const char* sourcePath, TInfoSink& is) :
intermediate(interm), symbolTable(symt), extensionBehavior(ext), infoSink(is), shaderType(type), shaderSpec(spec), compileOptions(options), checksPrecisionErrors(checksPrecErrors), sourcePath(sourcePath), treeRoot(0),
numErrors(0), lexAfterType(false), loopNestingLevel(0),
inTypeParen(false), contextPragma(true, false), scanner(NULL) { }
intermediate(interm),
symbolTable(symt),
extensionBehavior(ext),
infoSink(is),
shaderType(type),
shaderSpec(spec),
compileOptions(options),
sourcePath(sourcePath),
treeRoot(0),
numErrors(0),
lexAfterType(false),
loopNestingLevel(0),
structNestingLevel(0),
inTypeParen(false),
currentFunctionType(NULL),
functionReturnsValue(false),
checksPrecisionErrors(checksPrecErrors),
contextPragma(true, false),
scanner(NULL) { }
TIntermediate& intermediate; // to hold and build a parse tree
TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
TExtensionBehavior& extensionBehavior; // mapping between supported extensions and current behavior.
@ -46,6 +62,7 @@ struct TParseContext {
int numErrors;
bool lexAfterType; // true if we've recognized a type, so can only be looking for an identifier
int loopNestingLevel; // 0 if outside all loops
int structNestingLevel; // incremented while parsing a struct declaration
bool inTypeParen; // true if in parentheses, looking only for an identifier
const TType* currentFunctionType; // the return type of the function that's currently being parsed
bool functionReturnsValue; // true if a non-void function has a return
@ -105,6 +122,14 @@ struct TParseContext {
TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);
TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line);
TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
// Performs an error check for embedded struct declarations.
// Returns true if an error was raised due to the declaration of
// this struct.
bool enterStructDeclaration(TSourceLoc line, const TString& identifier);
void exitStructDeclaration();
bool structNestingErrorCheck(TSourceLoc line, const TType& fieldType);
};
int PaParseStrings(int count, const char* const string[], const int length[],

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2011 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.
//
@ -12,6 +12,7 @@
#include "GLSLANG/ShaderLang.h"
#include "compiler/InitializeDll.h"
#include "compiler/preprocessor/length_limits.h"
#include "compiler/ShHandle.h"
//
@ -19,16 +20,21 @@
// and the shading language compiler.
//
static int getVariableMaxLength(const TVariableInfoList& varList)
static bool checkActiveUniformAndAttribMaxLengths(const ShHandle handle,
int expectedValue)
{
TString::size_type maxLen = 0;
for (TVariableInfoList::const_iterator i = varList.begin();
i != varList.end(); ++i)
{
maxLen = std::max(maxLen, i->name.size());
}
// Add 1 to include null-termination character.
return static_cast<int>(maxLen) + 1;
int activeUniformLimit = 0;
ShGetInfo(handle, SH_ACTIVE_UNIFORM_MAX_LENGTH, &activeUniformLimit);
int activeAttribLimit = 0;
ShGetInfo(handle, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, &activeAttribLimit);
return (expectedValue == activeUniformLimit && expectedValue == activeAttribLimit);
}
static bool checkMappedNameMaxLength(const ShHandle handle, int expectedValue)
{
int mappedNameMaxLength = 0;
ShGetInfo(handle, SH_MAPPED_NAME_MAX_LENGTH, &mappedNameMaxLength);
return (expectedValue == mappedNameMaxLength);
}
static void getVariableInfo(ShShaderInfo varType,
@ -59,9 +65,20 @@ static void getVariableInfo(ShShaderInfo varType,
if (length) *length = varInfo.name.size();
*size = varInfo.size;
*type = varInfo.type;
strcpy(name, varInfo.name.c_str());
if (mappedName)
strcpy(mappedName, varInfo.mappedName.c_str());
// This size must match that queried by
// SH_ACTIVE_UNIFORM_MAX_LENGTH and SH_ACTIVE_ATTRIBUTE_MAX_LENGTH
// in ShGetInfo, below.
int activeUniformAndAttribLength = 1 + MAX_SYMBOL_NAME_LEN;
ASSERT(checkActiveUniformAndAttribMaxLengths(handle, activeUniformAndAttribLength));
strncpy(name, varInfo.name.c_str(), activeUniformAndAttribLength);
if (mappedName) {
// This size must match that queried by
// SH_MAPPED_NAME_MAX_LENGTH in ShGetInfo, below.
int maxMappedNameLength = 1 + MAX_SYMBOL_NAME_LEN;
ASSERT(checkMappedNameMaxLength(handle, maxMappedNameLength));
strncpy(mappedName, varInfo.mappedName.c_str(), maxMappedNameLength);
}
}
//
@ -191,16 +208,18 @@ void ShGetInfo(const ShHandle handle, ShShaderInfo pname, int* params)
*params = compiler->getUniforms().size();
break;
case SH_ACTIVE_UNIFORM_MAX_LENGTH:
*params = getVariableMaxLength(compiler->getUniforms());
*params = 1 + MAX_SYMBOL_NAME_LEN;
break;
case SH_ACTIVE_ATTRIBUTES:
*params = compiler->getAttribs().size();
break;
case SH_ACTIVE_ATTRIBUTE_MAX_LENGTH:
*params = getVariableMaxLength(compiler->getAttribs());
*params = 1 + MAX_SYMBOL_NAME_LEN;
break;
case SH_MAPPED_NAME_MAX_LENGTH:
*params = compiler->getMappedNameMaxLength();
// Use longer length than MAX_SHORTENED_IDENTIFIER_SIZE to
// handle array and struct dereferences.
*params = 1 + MAX_SYMBOL_NAME_LEN;
break;
default: UNREACHABLE();
}

View File

@ -13,6 +13,8 @@
#include <stdio.h>
#include <algorithm>
//
// TType helper function needs a place to live.
//
@ -71,6 +73,20 @@ int TType::getStructSize() const
return structureSize;
}
void TType::computeDeepestStructNesting()
{
if (!getStruct()) {
return;
}
int maxNesting = 0;
for (TTypeList::const_iterator tl = getStruct()->begin(); tl != getStruct()->end(); ++tl) {
maxNesting = std::max(maxNesting, ((*tl).type)->getDeepestStructNesting());
}
deepestStructNesting = 1 + maxNesting;
}
//
// Dump functions.
//

View File

@ -85,21 +85,22 @@ public:
TType() {}
TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) :
type(t), precision(p), qualifier(q), size(s), matrix(m), array(a), arraySize(0),
maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), fieldName(0), mangled(0), typeName(0)
maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0)
{
}
explicit TType(const TPublicType &p) :
type(p.type), precision(p.precision), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(p.arraySize),
maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), fieldName(0), mangled(0), typeName(0)
maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0)
{
if (p.userDef) {
structure = p.userDef->getStruct();
typeName = NewPoolTString(p.userDef->getTypeName().c_str());
computeDeepestStructNesting();
}
}
TType(TTypeList* userDef, const TString& n, TPrecision p = EbpUndefined) :
type(EbtStruct), precision(p), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0),
maxArraySize(0), arrayInformationType(0), structure(userDef), structureSize(0), fieldName(0), mangled(0)
maxArraySize(0), arrayInformationType(0), structure(userDef), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0)
{
typeName = NewPoolTString(n.c_str());
}
@ -144,6 +145,7 @@ public:
structureSize = copyOf.structureSize;
maxArraySize = copyOf.maxArraySize;
deepestStructNesting = copyOf.deepestStructNesting;
assert(copyOf.arrayInformationType == 0);
arrayInformationType = 0; // arrayInformationType should not be set for builtIn symbol table level
}
@ -202,7 +204,7 @@ public:
bool isScalar() const { return size == 1 && !matrix && !structure; }
TTypeList* getStruct() const { return structure; }
void setStruct(TTypeList* s) { structure = s; }
void setStruct(TTypeList* s) { structure = s; computeDeepestStructNesting(); }
const TString& getTypeName() const
{
@ -268,9 +270,24 @@ public:
const char* getQualifierString() const { return ::getQualifierString(qualifier); }
TString getCompleteString() const;
// If this type is a struct, returns the deepest struct nesting of
// any field in the struct. For example:
// struct nesting1 {
// vec4 position;
// };
// struct nesting2 {
// nesting1 field1;
// vec4 field2;
// };
// For type "nesting2", this method would return 2 -- the number
// of structures through which indirection must occur to reach the
// deepest field (nesting2.field1.position).
int getDeepestStructNesting() const { return deepestStructNesting; }
protected:
void buildMangledName(TString&);
int getStructSize() const;
void computeDeepestStructNesting();
TBasicType type : 6;
TPrecision precision;
@ -284,6 +301,7 @@ protected:
TTypeList* structure; // 0 unless this is a struct
mutable int structureSize;
int deepestStructNesting;
TString *fieldName; // for structure field names
TString *mangled;

View File

@ -1642,11 +1642,11 @@ type_specifier_nonarray
;
struct_specifier
: STRUCT IDENTIFIER LEFT_BRACE struct_declaration_list RIGHT_BRACE {
: STRUCT IDENTIFIER LEFT_BRACE { if (context->enterStructDeclaration($2.line, *$2.string)) context->recover(); } struct_declaration_list RIGHT_BRACE {
if (context->reservedErrorCheck($2.line, *$2.string))
context->recover();
TType* structure = new TType($4, *$2.string);
TType* structure = new TType($5, *$2.string);
TVariable* userTypeDef = new TVariable($2.string, *structure, true);
if (! context->symbolTable.insert(*userTypeDef)) {
context->error($2.line, "redefinition", $2.string->c_str(), "struct");
@ -1654,11 +1654,13 @@ struct_specifier
}
$$.setBasic(EbtStruct, EvqTemporary, $1.line);
$$.userDef = structure;
context->exitStructDeclaration();
}
| STRUCT LEFT_BRACE struct_declaration_list RIGHT_BRACE {
TType* structure = new TType($3, TString(""));
| STRUCT LEFT_BRACE { if (context->enterStructDeclaration($2.line, *$2.string)) context->recover(); } struct_declaration_list RIGHT_BRACE {
TType* structure = new TType($4, TString(""));
$$.setBasic(EbtStruct, EvqTemporary, $1.line);
$$.userDef = structure;
context->exitStructDeclaration();
}
;
@ -1708,6 +1710,10 @@ struct_declaration
type->setStruct($1.userDef->getStruct());
type->setTypeName($1.userDef->getTypeName());
}
if (context->structNestingErrorCheck($1.line, *type)) {
context->recover();
}
}
}
;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,23 @@
//
// Copyright (c) 2011 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.
//
//
// length_limits.h
//
#if !defined(__LENGTH_LIMITS_H)
#define __LENGTH_LIMITS_H 1
// These constants are factored out from the rest of the headers to
// make it easier to reference them from the compiler sources.
// These lengths do not include the NULL terminator.
// see bug 675625: NVIDIA driver crash with lengths >= 253
// this is only an interim fix, the real fix is name mapping, see ANGLE bug 144 / r619
#define MAX_SYMBOL_NAME_LEN 250
#define MAX_STRING_LEN 511
#endif // !(defined(__LENGTH_LIMITS_H)

View File

@ -48,12 +48,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if !defined(__SCANNER_H)
#define __SCANNER_H 1
// These lengths do not include the NULL terminator.
// see bug 675625: NVIDIA driver crash with lengths >= 253
// this is only an interim fix, the real fix is name mapping, see ANGLE bug 144 / r619
#define MAX_SYMBOL_NAME_LEN 250
#define MAX_STRING_LEN 511
#include "compiler/preprocessor/length_limits.h"
#include "compiler/preprocessor/parser.h"
// Not really atom table stuff but needed first...

View File

@ -40,6 +40,9 @@ namespace gl
{
Context::Context(const egl::Config *config, const gl::Context *shareContext) : mConfig(config)
{
mDisplay = NULL;
mDevice = NULL;
mFenceHandleAllocator.setBaseHandle(0);
setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@ -234,19 +237,20 @@ Context::~Context()
void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
{
IDirect3DDevice9 *device = display->getDevice();
mDisplay = display;
mDevice = mDisplay->getDevice();
if (!mHasBeenCurrent)
{
mDeviceCaps = display->getDeviceCaps();
mDeviceCaps = mDisplay->getDeviceCaps();
mVertexDataManager = new VertexDataManager(this, device);
mIndexDataManager = new IndexDataManager(this, device);
mVertexDataManager = new VertexDataManager(this, mDevice);
mIndexDataManager = new IndexDataManager(this, mDevice);
mBlit = new Blit(this);
mSupportsShaderModel3 = mDeviceCaps.PixelShaderVersion == D3DPS_VERSION(3, 0);
mSupportsVertexTexture = display->getVertexTextureSupport();
mSupportsNonPower2Texture = display->getNonPower2TextureSupport();
mSupportsVertexTexture = mDisplay->getVertexTextureSupport();
mSupportsNonPower2Texture = mDisplay->getNonPower2TextureSupport();
mMaxTextureDimension = std::min(std::min((int)mDeviceCaps.MaxTextureWidth, (int)mDeviceCaps.MaxTextureHeight),
(int)gl::IMPLEMENTATION_MAX_TEXTURE_SIZE);
@ -268,7 +272,7 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
for (int i = 0; i < sizeof(renderBufferFormats) / sizeof(D3DFORMAT); ++i)
{
bool *multisampleArray = new bool[D3DMULTISAMPLE_16_SAMPLES + 1];
display->getMultiSampleSupport(renderBufferFormats[i], multisampleArray);
mDisplay->getMultiSampleSupport(renderBufferFormats[i], multisampleArray);
mMultiSampleSupport[renderBufferFormats[i]] = multisampleArray;
for (int j = D3DMULTISAMPLE_16_SAMPLES; j >= 0; --j)
@ -282,14 +286,14 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
mMaxSupportedSamples = max;
mSupportsEventQueries = display->getEventQuerySupport();
mSupportsDXT1Textures = display->getDXT1TextureSupport();
mSupportsDXT3Textures = display->getDXT3TextureSupport();
mSupportsDXT5Textures = display->getDXT5TextureSupport();
mSupportsFloatTextures = display->getFloatTextureSupport(&mSupportsFloatLinearFilter, &mSupportsFloatRenderableTextures);
mSupportsHalfFloatTextures = display->getHalfFloatTextureSupport(&mSupportsHalfFloatLinearFilter, &mSupportsHalfFloatRenderableTextures);
mSupportsLuminanceTextures = display->getLuminanceTextureSupport();
mSupportsLuminanceAlphaTextures = display->getLuminanceAlphaTextureSupport();
mSupportsEventQueries = mDisplay->getEventQuerySupport();
mSupportsDXT1Textures = mDisplay->getDXT1TextureSupport();
mSupportsDXT3Textures = mDisplay->getDXT3TextureSupport();
mSupportsDXT5Textures = mDisplay->getDXT5TextureSupport();
mSupportsFloatTextures = mDisplay->getFloatTextureSupport(&mSupportsFloatLinearFilter, &mSupportsFloatRenderableTextures);
mSupportsHalfFloatTextures = mDisplay->getHalfFloatTextureSupport(&mSupportsHalfFloatLinearFilter, &mSupportsHalfFloatRenderableTextures);
mSupportsLuminanceTextures = mDisplay->getLuminanceTextureSupport();
mSupportsLuminanceAlphaTextures = mDisplay->getLuminanceAlphaTextureSupport();
mSupports32bitIndices = mDeviceCaps.MaxVertexIndex >= (1 << 16);
@ -1620,8 +1624,6 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
// scissor rectangle to the Direct3D 9 device
bool Context::applyRenderTarget(bool ignoreViewport)
{
IDirect3DDevice9 *device = getDevice();
Framebuffer *framebufferObject = getDrawFramebuffer();
if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE)
@ -1642,7 +1644,7 @@ bool Context::applyRenderTarget(bool ignoreViewport)
{
return false; // Context must be lost
}
device->SetRenderTarget(0, renderTarget);
mDevice->SetRenderTarget(0, renderTarget);
mAppliedRenderTargetSerial = renderTargetSerial;
mScissorStateDirty = true; // Scissor area must be clamped to render target's size-- this is different for different render targets.
renderTargetChanged = true;
@ -1677,7 +1679,7 @@ bool Context::applyRenderTarget(bool ignoreViewport)
stencilbufferSerial != mAppliedStencilbufferSerial ||
!mDepthStencilInitialized)
{
device->SetDepthStencilSurface(depthStencil);
mDevice->SetDepthStencilSurface(depthStencil);
mAppliedDepthbufferSerial = depthbufferSerial;
mAppliedStencilbufferSerial = stencilbufferSerial;
mDepthStencilInitialized = true;
@ -1730,7 +1732,7 @@ bool Context::applyRenderTarget(bool ignoreViewport)
if (!mViewportInitialized || memcmp(&viewport, &mSetViewport, sizeof mSetViewport) != 0)
{
device->SetViewport(&viewport);
mDevice->SetViewport(&viewport);
mSetViewport = viewport;
mViewportInitialized = true;
mDxUniformsDirty = true;
@ -1745,12 +1747,12 @@ bool Context::applyRenderTarget(bool ignoreViewport)
rect.top = clamp(rect.top, 0L, static_cast<LONG>(mRenderTargetDesc.Height));
rect.right = clamp(rect.right, 0L, static_cast<LONG>(mRenderTargetDesc.Width));
rect.bottom = clamp(rect.bottom, 0L, static_cast<LONG>(mRenderTargetDesc.Height));
device->SetScissorRect(&rect);
device->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
mDevice->SetScissorRect(&rect);
mDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
}
else
{
device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
mDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
}
mScissorStateDirty = false;
@ -1786,7 +1788,6 @@ bool Context::applyRenderTarget(bool ignoreViewport)
// Applies the fixed-function state (culling, depth test, alpha blending, stenciling, etc) to the Direct3D 9 device
void Context::applyState(GLenum drawMode)
{
IDirect3DDevice9 *device = getDevice();
Program *programObject = getCurrentProgram();
Framebuffer *framebufferObject = getDrawFramebuffer();
@ -1801,8 +1802,7 @@ void Context::applyState(GLenum drawMode)
GLint alwaysFront = !isTriangleMode(drawMode);
programObject->setUniform1iv(pointsOrLines, 1, &alwaysFront);
egl::Display *display = getDisplay();
D3DADAPTER_IDENTIFIER9 *identifier = display->getAdapterIdentifier();
D3DADAPTER_IDENTIFIER9 *identifier = mDisplay->getAdapterIdentifier();
bool zeroColorMaskAllowed = identifier->VendorId != 0x1002;
// Apparently some ATI cards have a bug where a draw with a zero color
// write mask can cause later draws to have incorrect results. Instead,
@ -1814,11 +1814,11 @@ void Context::applyState(GLenum drawMode)
{
if (mState.cullFace)
{
device->SetRenderState(D3DRS_CULLMODE, es2dx::ConvertCullMode(mState.cullMode, adjustedFrontFace));
mDevice->SetRenderState(D3DRS_CULLMODE, es2dx::ConvertCullMode(mState.cullMode, adjustedFrontFace));
}
else
{
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
mDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
}
mCullStateDirty = false;
@ -1828,12 +1828,12 @@ void Context::applyState(GLenum drawMode)
{
if (mState.depthTest)
{
device->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
device->SetRenderState(D3DRS_ZFUNC, es2dx::ConvertComparison(mState.depthFunc));
mDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
mDevice->SetRenderState(D3DRS_ZFUNC, es2dx::ConvertComparison(mState.depthFunc));
}
else
{
device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
mDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
}
mDepthStateDirty = false;
@ -1849,43 +1849,43 @@ void Context::applyState(GLenum drawMode)
{
if (mState.blend)
{
device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
if (mState.sourceBlendRGB != GL_CONSTANT_ALPHA && mState.sourceBlendRGB != GL_ONE_MINUS_CONSTANT_ALPHA &&
mState.destBlendRGB != GL_CONSTANT_ALPHA && mState.destBlendRGB != GL_ONE_MINUS_CONSTANT_ALPHA)
{
device->SetRenderState(D3DRS_BLENDFACTOR, es2dx::ConvertColor(mState.blendColor));
mDevice->SetRenderState(D3DRS_BLENDFACTOR, es2dx::ConvertColor(mState.blendColor));
}
else
{
device->SetRenderState(D3DRS_BLENDFACTOR, D3DCOLOR_RGBA(unorm<8>(mState.blendColor.alpha),
mDevice->SetRenderState(D3DRS_BLENDFACTOR, D3DCOLOR_RGBA(unorm<8>(mState.blendColor.alpha),
unorm<8>(mState.blendColor.alpha),
unorm<8>(mState.blendColor.alpha),
unorm<8>(mState.blendColor.alpha)));
}
device->SetRenderState(D3DRS_SRCBLEND, es2dx::ConvertBlendFunc(mState.sourceBlendRGB));
device->SetRenderState(D3DRS_DESTBLEND, es2dx::ConvertBlendFunc(mState.destBlendRGB));
device->SetRenderState(D3DRS_BLENDOP, es2dx::ConvertBlendOp(mState.blendEquationRGB));
mDevice->SetRenderState(D3DRS_SRCBLEND, es2dx::ConvertBlendFunc(mState.sourceBlendRGB));
mDevice->SetRenderState(D3DRS_DESTBLEND, es2dx::ConvertBlendFunc(mState.destBlendRGB));
mDevice->SetRenderState(D3DRS_BLENDOP, es2dx::ConvertBlendOp(mState.blendEquationRGB));
if (mState.sourceBlendRGB != mState.sourceBlendAlpha ||
mState.destBlendRGB != mState.destBlendAlpha ||
mState.blendEquationRGB != mState.blendEquationAlpha)
{
device->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
mDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
device->SetRenderState(D3DRS_SRCBLENDALPHA, es2dx::ConvertBlendFunc(mState.sourceBlendAlpha));
device->SetRenderState(D3DRS_DESTBLENDALPHA, es2dx::ConvertBlendFunc(mState.destBlendAlpha));
device->SetRenderState(D3DRS_BLENDOPALPHA, es2dx::ConvertBlendOp(mState.blendEquationAlpha));
mDevice->SetRenderState(D3DRS_SRCBLENDALPHA, es2dx::ConvertBlendFunc(mState.sourceBlendAlpha));
mDevice->SetRenderState(D3DRS_DESTBLENDALPHA, es2dx::ConvertBlendFunc(mState.destBlendAlpha));
mDevice->SetRenderState(D3DRS_BLENDOPALPHA, es2dx::ConvertBlendOp(mState.blendEquationAlpha));
}
else
{
device->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, FALSE);
mDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, FALSE);
}
}
else
{
device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
}
mBlendStateDirty = false;
@ -1895,8 +1895,8 @@ void Context::applyState(GLenum drawMode)
{
if (mState.stencilTest && framebufferObject->hasStencil())
{
device->SetRenderState(D3DRS_STENCILENABLE, TRUE);
device->SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, TRUE);
mDevice->SetRenderState(D3DRS_STENCILENABLE, TRUE);
mDevice->SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, TRUE);
// FIXME: Unsupported by D3D9
const D3DRENDERSTATETYPE D3DRS_CCW_STENCILREF = D3DRS_STENCILREF;
@ -1914,37 +1914,37 @@ void Context::applyState(GLenum drawMode)
gl::DepthStencilbuffer *stencilbuffer = framebufferObject->getStencilbuffer();
GLuint maxStencil = (1 << stencilbuffer->getStencilSize()) - 1;
device->SetRenderState(adjustedFrontFace == GL_CCW ? D3DRS_STENCILWRITEMASK : D3DRS_CCW_STENCILWRITEMASK, mState.stencilWritemask);
device->SetRenderState(adjustedFrontFace == GL_CCW ? D3DRS_STENCILFUNC : D3DRS_CCW_STENCILFUNC,
mDevice->SetRenderState(adjustedFrontFace == GL_CCW ? D3DRS_STENCILWRITEMASK : D3DRS_CCW_STENCILWRITEMASK, mState.stencilWritemask);
mDevice->SetRenderState(adjustedFrontFace == GL_CCW ? D3DRS_STENCILFUNC : D3DRS_CCW_STENCILFUNC,
es2dx::ConvertComparison(mState.stencilFunc));
device->SetRenderState(adjustedFrontFace == GL_CCW ? D3DRS_STENCILREF : D3DRS_CCW_STENCILREF, (mState.stencilRef < (GLint)maxStencil) ? mState.stencilRef : maxStencil);
device->SetRenderState(adjustedFrontFace == GL_CCW ? D3DRS_STENCILMASK : D3DRS_CCW_STENCILMASK, mState.stencilMask);
mDevice->SetRenderState(adjustedFrontFace == GL_CCW ? D3DRS_STENCILREF : D3DRS_CCW_STENCILREF, (mState.stencilRef < (GLint)maxStencil) ? mState.stencilRef : maxStencil);
mDevice->SetRenderState(adjustedFrontFace == GL_CCW ? D3DRS_STENCILMASK : D3DRS_CCW_STENCILMASK, mState.stencilMask);
device->SetRenderState(adjustedFrontFace == GL_CCW ? D3DRS_STENCILFAIL : D3DRS_CCW_STENCILFAIL,
mDevice->SetRenderState(adjustedFrontFace == GL_CCW ? D3DRS_STENCILFAIL : D3DRS_CCW_STENCILFAIL,
es2dx::ConvertStencilOp(mState.stencilFail));
device->SetRenderState(adjustedFrontFace == GL_CCW ? D3DRS_STENCILZFAIL : D3DRS_CCW_STENCILZFAIL,
mDevice->SetRenderState(adjustedFrontFace == GL_CCW ? D3DRS_STENCILZFAIL : D3DRS_CCW_STENCILZFAIL,
es2dx::ConvertStencilOp(mState.stencilPassDepthFail));
device->SetRenderState(adjustedFrontFace == GL_CCW ? D3DRS_STENCILPASS : D3DRS_CCW_STENCILPASS,
mDevice->SetRenderState(adjustedFrontFace == GL_CCW ? D3DRS_STENCILPASS : D3DRS_CCW_STENCILPASS,
es2dx::ConvertStencilOp(mState.stencilPassDepthPass));
device->SetRenderState(adjustedFrontFace == GL_CW ? D3DRS_STENCILWRITEMASK : D3DRS_CCW_STENCILWRITEMASK, mState.stencilBackWritemask);
device->SetRenderState(adjustedFrontFace == GL_CW ? D3DRS_STENCILFUNC : D3DRS_CCW_STENCILFUNC,
mDevice->SetRenderState(adjustedFrontFace == GL_CW ? D3DRS_STENCILWRITEMASK : D3DRS_CCW_STENCILWRITEMASK, mState.stencilBackWritemask);
mDevice->SetRenderState(adjustedFrontFace == GL_CW ? D3DRS_STENCILFUNC : D3DRS_CCW_STENCILFUNC,
es2dx::ConvertComparison(mState.stencilBackFunc));
device->SetRenderState(adjustedFrontFace == GL_CW ? D3DRS_STENCILREF : D3DRS_CCW_STENCILREF, (mState.stencilBackRef < (GLint)maxStencil) ? mState.stencilBackRef : maxStencil);
device->SetRenderState(adjustedFrontFace == GL_CW ? D3DRS_STENCILMASK : D3DRS_CCW_STENCILMASK, mState.stencilBackMask);
mDevice->SetRenderState(adjustedFrontFace == GL_CW ? D3DRS_STENCILREF : D3DRS_CCW_STENCILREF, (mState.stencilBackRef < (GLint)maxStencil) ? mState.stencilBackRef : maxStencil);
mDevice->SetRenderState(adjustedFrontFace == GL_CW ? D3DRS_STENCILMASK : D3DRS_CCW_STENCILMASK, mState.stencilBackMask);
device->SetRenderState(adjustedFrontFace == GL_CW ? D3DRS_STENCILFAIL : D3DRS_CCW_STENCILFAIL,
mDevice->SetRenderState(adjustedFrontFace == GL_CW ? D3DRS_STENCILFAIL : D3DRS_CCW_STENCILFAIL,
es2dx::ConvertStencilOp(mState.stencilBackFail));
device->SetRenderState(adjustedFrontFace == GL_CW ? D3DRS_STENCILZFAIL : D3DRS_CCW_STENCILZFAIL,
mDevice->SetRenderState(adjustedFrontFace == GL_CW ? D3DRS_STENCILZFAIL : D3DRS_CCW_STENCILZFAIL,
es2dx::ConvertStencilOp(mState.stencilBackPassDepthFail));
device->SetRenderState(adjustedFrontFace == GL_CW ? D3DRS_STENCILPASS : D3DRS_CCW_STENCILPASS,
mDevice->SetRenderState(adjustedFrontFace == GL_CW ? D3DRS_STENCILPASS : D3DRS_CCW_STENCILPASS,
es2dx::ConvertStencilOp(mState.stencilBackPassDepthPass));
}
else
{
device->SetRenderState(D3DRS_STENCILENABLE, FALSE);
mDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
}
mStencilStateDirty = false;
@ -1958,18 +1958,18 @@ void Context::applyState(GLenum drawMode)
if (colorMask == 0 && !zeroColorMaskAllowed)
{
// Enable green channel, but set blending so nothing will be drawn.
device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_GREEN);
device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
mDevice->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_GREEN);
mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
device->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
mDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
mDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
mDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
}
else
{
device->SetRenderState(D3DRS_COLORWRITEENABLE, colorMask);
mDevice->SetRenderState(D3DRS_COLORWRITEENABLE, colorMask);
}
device->SetRenderState(D3DRS_ZWRITEENABLE, mState.depthMask ? TRUE : FALSE);
mDevice->SetRenderState(D3DRS_ZWRITEENABLE, mState.depthMask ? TRUE : FALSE);
mMaskStateDirty = false;
}
@ -1981,15 +1981,15 @@ void Context::applyState(GLenum drawMode)
gl::DepthStencilbuffer *depthbuffer = framebufferObject->getDepthbuffer();
if (depthbuffer)
{
device->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, *((DWORD*)&mState.polygonOffsetFactor));
mDevice->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, *((DWORD*)&mState.polygonOffsetFactor));
float depthBias = ldexp(mState.polygonOffsetUnits, -(int)(depthbuffer->getDepthSize()));
device->SetRenderState(D3DRS_DEPTHBIAS, *((DWORD*)&depthBias));
mDevice->SetRenderState(D3DRS_DEPTHBIAS, *((DWORD*)&depthBias));
}
}
else
{
device->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, 0);
device->SetRenderState(D3DRS_DEPTHBIAS, 0);
mDevice->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, 0);
mDevice->SetRenderState(D3DRS_DEPTHBIAS, 0);
}
mPolygonOffsetStateDirty = false;
@ -2002,7 +2002,7 @@ void Context::applyState(GLenum drawMode)
FIXME("Sample alpha to coverage is unimplemented.");
}
device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);
mDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);
if (mState.sampleCoverage)
{
unsigned int mask = 0;
@ -2027,11 +2027,11 @@ void Context::applyState(GLenum drawMode)
mask = ~mask;
}
device->SetRenderState(D3DRS_MULTISAMPLEMASK, mask);
mDevice->SetRenderState(D3DRS_MULTISAMPLEMASK, mask);
}
else
{
device->SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
mDevice->SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
}
mSampleStateDirty = false;
@ -2039,7 +2039,7 @@ void Context::applyState(GLenum drawMode)
if (mDitherStateDirty)
{
device->SetRenderState(D3DRS_DITHERENABLE, mState.dither ? TRUE : FALSE);
mDevice->SetRenderState(D3DRS_DITHERENABLE, mState.dither ? TRUE : FALSE);
mDitherStateDirty = false;
}
@ -2055,20 +2055,19 @@ GLenum Context::applyVertexBuffer(GLint first, GLsizei count)
return err;
}
return mVertexDeclarationCache.applyDeclaration(attributes, getCurrentProgram());
return mVertexDeclarationCache.applyDeclaration(mDevice, attributes, getCurrentProgram());
}
// Applies the indices and element array bindings to the Direct3D 9 device
GLenum Context::applyIndexBuffer(const void *indices, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo)
{
IDirect3DDevice9 *device = getDevice();
GLenum err = mIndexDataManager->prepareIndexData(type, count, mState.elementArrayBuffer.get(), indices, indexInfo);
if (err == GL_NO_ERROR)
{
if (indexInfo->serial != mAppliedIBSerial)
{
device->SetIndices(indexInfo->indexBuffer);
mDevice->SetIndices(indexInfo->indexBuffer);
mAppliedIBSerial = indexInfo->serial;
}
}
@ -2079,15 +2078,14 @@ GLenum Context::applyIndexBuffer(const void *indices, GLsizei count, GLenum mode
// Applies the shaders and shader constants to the Direct3D 9 device
void Context::applyShaders()
{
IDirect3DDevice9 *device = getDevice();
Program *programObject = getCurrentProgram();
if (programObject->getSerial() != mAppliedProgramSerial)
{
IDirect3DVertexShader9 *vertexShader = programObject->getVertexShader();
IDirect3DPixelShader9 *pixelShader = programObject->getPixelShader();
device->SetPixelShader(pixelShader);
device->SetVertexShader(vertexShader);
mDevice->SetPixelShader(pixelShader);
mDevice->SetVertexShader(vertexShader);
programObject->dirtyAllUniforms();
mAppliedProgramSerial = programObject->getSerial();
}
@ -2111,7 +2109,6 @@ void Context::applyTextures()
// and sets the texture and its addressing/filtering state (or NULL when inactive).
void Context::applyTextures(SamplerType type)
{
IDirect3DDevice9 *device = getDevice();
Program *programObject = getCurrentProgram();
int samplerCount = (type == SAMPLER_PIXEL) ? MAX_TEXTURE_IMAGE_UNITS : MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF; // Range of Direct3D 9 samplers of given sampler type
@ -2143,24 +2140,24 @@ void Context::applyTextures(SamplerType type)
GLenum minFilter = texture->getMinFilter();
GLenum magFilter = texture->getMagFilter();
device->SetSamplerState(d3dSampler, D3DSAMP_ADDRESSU, es2dx::ConvertTextureWrap(wrapS));
device->SetSamplerState(d3dSampler, D3DSAMP_ADDRESSV, es2dx::ConvertTextureWrap(wrapT));
mDevice->SetSamplerState(d3dSampler, D3DSAMP_ADDRESSU, es2dx::ConvertTextureWrap(wrapS));
mDevice->SetSamplerState(d3dSampler, D3DSAMP_ADDRESSV, es2dx::ConvertTextureWrap(wrapT));
device->SetSamplerState(d3dSampler, D3DSAMP_MAGFILTER, es2dx::ConvertMagFilter(magFilter));
mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAGFILTER, es2dx::ConvertMagFilter(magFilter));
D3DTEXTUREFILTERTYPE d3dMinFilter, d3dMipFilter;
es2dx::ConvertMinFilter(minFilter, &d3dMinFilter, &d3dMipFilter);
device->SetSamplerState(d3dSampler, D3DSAMP_MINFILTER, d3dMinFilter);
device->SetSamplerState(d3dSampler, D3DSAMP_MIPFILTER, d3dMipFilter);
mDevice->SetSamplerState(d3dSampler, D3DSAMP_MINFILTER, d3dMinFilter);
mDevice->SetSamplerState(d3dSampler, D3DSAMP_MIPFILTER, d3dMipFilter);
}
if (appliedTextureSerial[samplerIndex] != texture->getSerial() || texture->isDirtyImage())
{
device->SetTexture(d3dSampler, d3dTexture);
mDevice->SetTexture(d3dSampler, d3dTexture);
}
}
else
{
device->SetTexture(d3dSampler, getIncompleteTexture(textureType)->getTexture());
mDevice->SetTexture(d3dSampler, getIncompleteTexture(textureType)->getTexture());
}
appliedTextureSerial[samplerIndex] = texture->getSerial();
@ -2171,7 +2168,7 @@ void Context::applyTextures(SamplerType type)
{
if (appliedTextureSerial[samplerIndex] != 0)
{
device->SetTexture(d3dSampler, NULL);
mDevice->SetTexture(d3dSampler, NULL);
appliedTextureSerial[samplerIndex] = 0;
}
}
@ -2181,7 +2178,7 @@ void Context::applyTextures(SamplerType type)
{
if (appliedTextureSerial[samplerIndex] != 0)
{
device->SetTexture(samplerIndex + d3dSamplerOffset, NULL);
mDevice->SetTexture(samplerIndex + d3dSamplerOffset, NULL);
appliedTextureSerial[samplerIndex] = 0;
}
}
@ -2208,13 +2205,11 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
return; // Context must be lost, return silently
}
IDirect3DDevice9 *device = getDevice();
D3DSURFACE_DESC desc;
renderTarget->GetDesc(&desc);
IDirect3DSurface9 *systemSurface;
HRESULT result = device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &systemSurface, NULL);
HRESULT result = mDevice->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &systemSurface, NULL);
if (FAILED(result))
{
@ -2228,7 +2223,7 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
return error(GL_OUT_OF_MEMORY);
}
result = device->GetRenderTargetData(renderTarget, systemSurface);
result = mDevice->GetRenderTargetData(renderTarget, systemSurface);
if (FAILED(result))
{
@ -2457,8 +2452,6 @@ void Context::clear(GLbitfield mask)
return error(GL_INVALID_FRAMEBUFFER_OPERATION);
}
egl::Display *display = getDisplay();
IDirect3DDevice9 *device = getDevice();
DWORD flags = 0;
if (mask & GL_COLOR_BUFFER_BIT)
@ -2550,32 +2543,32 @@ void Context::clear(GLbitfield mask)
HRESULT hr;
if (mMaskedClearSavedState == NULL)
{
hr = device->BeginStateBlock();
hr = mDevice->BeginStateBlock();
ASSERT(SUCCEEDED(hr) || hr == D3DERR_OUTOFVIDEOMEMORY || hr == E_OUTOFMEMORY);
device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
device->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
device->SetRenderState(D3DRS_ZENABLE, FALSE);
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
device->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
device->SetRenderState(D3DRS_STENCILENABLE, FALSE);
device->SetPixelShader(NULL);
device->SetVertexShader(NULL);
device->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
device->SetStreamSource(0, NULL, 0, 0);
device->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
device->SetRenderState(D3DRS_TEXTUREFACTOR, color);
device->SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
mDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
mDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
mDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
mDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
mDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
mDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
mDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
mDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
mDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
mDevice->SetPixelShader(NULL);
mDevice->SetVertexShader(NULL);
mDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
mDevice->SetStreamSource(0, NULL, 0, 0);
mDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
mDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
mDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
mDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
mDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
mDevice->SetRenderState(D3DRS_TEXTUREFACTOR, color);
mDevice->SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
hr = device->EndStateBlock(&mMaskedClearSavedState);
hr = mDevice->EndStateBlock(&mMaskedClearSavedState);
ASSERT(SUCCEEDED(hr) || hr == D3DERR_OUTOFVIDEOMEMORY || hr == E_OUTOFMEMORY);
}
@ -2587,51 +2580,51 @@ void Context::clear(GLbitfield mask)
ASSERT(SUCCEEDED(hr));
}
device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
device->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
device->SetRenderState(D3DRS_ZENABLE, FALSE);
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
mDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
mDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
mDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
mDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
mDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
mDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
mDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
if (flags & D3DCLEAR_TARGET)
{
device->SetRenderState(D3DRS_COLORWRITEENABLE, es2dx::ConvertColorMask(mState.colorMaskRed, mState.colorMaskGreen, mState.colorMaskBlue, mState.colorMaskAlpha));
mDevice->SetRenderState(D3DRS_COLORWRITEENABLE, es2dx::ConvertColorMask(mState.colorMaskRed, mState.colorMaskGreen, mState.colorMaskBlue, mState.colorMaskAlpha));
}
else
{
device->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
mDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
}
if (stencilUnmasked != 0x0 && (flags & D3DCLEAR_STENCIL))
{
device->SetRenderState(D3DRS_STENCILENABLE, TRUE);
device->SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, FALSE);
device->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
device->SetRenderState(D3DRS_STENCILREF, stencil);
device->SetRenderState(D3DRS_STENCILWRITEMASK, mState.stencilWritemask);
device->SetRenderState(D3DRS_STENCILFAIL, D3DSTENCILOP_REPLACE);
device->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_REPLACE);
device->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_REPLACE);
mDevice->SetRenderState(D3DRS_STENCILENABLE, TRUE);
mDevice->SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, FALSE);
mDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
mDevice->SetRenderState(D3DRS_STENCILREF, stencil);
mDevice->SetRenderState(D3DRS_STENCILWRITEMASK, mState.stencilWritemask);
mDevice->SetRenderState(D3DRS_STENCILFAIL, D3DSTENCILOP_REPLACE);
mDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_REPLACE);
mDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_REPLACE);
mStencilStateDirty = true;
}
else
{
device->SetRenderState(D3DRS_STENCILENABLE, FALSE);
mDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
}
device->SetPixelShader(NULL);
device->SetVertexShader(NULL);
device->SetFVF(D3DFVF_XYZRHW);
device->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
device->SetRenderState(D3DRS_TEXTUREFACTOR, color);
device->SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
mDevice->SetPixelShader(NULL);
mDevice->SetVertexShader(NULL);
mDevice->SetFVF(D3DFVF_XYZRHW);
mDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
mDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
mDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
mDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
mDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
mDevice->SetRenderState(D3DRS_TEXTUREFACTOR, color);
mDevice->SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
float quad[4][4]; // A quadrilateral covering the target, aligned to match the edges
quad[0][0] = -0.5f;
@ -2654,14 +2647,14 @@ void Context::clear(GLbitfield mask)
quad[3][2] = 0.0f;
quad[3][3] = 1.0f;
display->startScene();
device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, quad, sizeof(float[4]));
mDisplay->startScene();
mDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, quad, sizeof(float[4]));
if (flags & D3DCLEAR_ZBUFFER)
{
device->SetRenderState(D3DRS_ZENABLE, TRUE);
device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
device->Clear(0, NULL, D3DCLEAR_ZBUFFER, color, depth, stencil);
mDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
mDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
mDevice->Clear(0, NULL, D3DCLEAR_ZBUFFER, color, depth, stencil);
}
if (mMaskedClearSavedState != NULL)
@ -2671,7 +2664,7 @@ void Context::clear(GLbitfield mask)
}
else if (flags)
{
device->Clear(0, NULL, flags, color, depth, stencil);
mDevice->Clear(0, NULL, flags, color, depth, stencil);
}
}
@ -2682,8 +2675,6 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count)
return error(GL_INVALID_OPERATION);
}
egl::Display *display = getDisplay();
IDirect3DDevice9 *device = getDevice();
D3DPRIMITIVETYPE primitiveType;
int primitiveCount;
@ -2718,9 +2709,9 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count)
if (!cullSkipsDraw(mode))
{
display->startScene();
mDisplay->startScene();
device->DrawPrimitive(primitiveType, 0, primitiveCount);
mDevice->DrawPrimitive(primitiveType, 0, primitiveCount);
if (mode == GL_LINE_LOOP) // Draw the last segment separately
{
@ -2741,8 +2732,6 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void *
return error(GL_INVALID_OPERATION);
}
egl::Display *display = getDisplay();
IDirect3DDevice9 *device = getDevice();
D3DPRIMITIVETYPE primitiveType;
int primitiveCount;
@ -2785,9 +2774,9 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void *
if (!cullSkipsDraw(mode))
{
display->startScene();
mDisplay->startScene();
device->DrawIndexedPrimitive(primitiveType, -(INT)indexInfo.minIndex, indexInfo.minIndex, vertexCount, indexInfo.startIndex, primitiveCount);
mDevice->DrawIndexedPrimitive(primitiveType, -(INT)indexInfo.minIndex, indexInfo.minIndex, vertexCount, indexInfo.startIndex, primitiveCount);
if (mode == GL_LINE_LOOP) // Draw the last segment separately
{
@ -2796,92 +2785,13 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void *
}
}
void Context::finish()
// Implements glFlush when block is false, glFinish when block is true
void Context::sync(bool block)
{
egl::Display *display = getDisplay();
IDirect3DDevice9 *device = getDevice();
IDirect3DQuery9 *occlusionQuery = NULL;
HRESULT result;
result = device->CreateQuery(D3DQUERYTYPE_OCCLUSION, &occlusionQuery);
if (FAILED(result))
{
ERR("CreateQuery failed hr=%x\n", result);
if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
{
return error(GL_OUT_OF_MEMORY);
}
ASSERT(false);
return;
}
IDirect3DStateBlock9 *savedState = NULL;
result = device->CreateStateBlock(D3DSBT_ALL, &savedState);
if (FAILED(result))
{
ERR("CreateStateBlock failed hr=%x\n", result);
occlusionQuery->Release();
if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
{
return error(GL_OUT_OF_MEMORY);
}
ASSERT(false);
return;
}
result = occlusionQuery->Issue(D3DISSUE_BEGIN);
if (FAILED(result))
{
ERR("occlusionQuery->Issue(BEGIN) failed hr=%x\n", result);
occlusionQuery->Release();
savedState->Release();
ASSERT(false);
return;
}
// Render something outside the render target
device->SetPixelShader(NULL);
device->SetVertexShader(NULL);
device->SetFVF(D3DFVF_XYZRHW);
float data[4] = {-1.0f, -1.0f, -1.0f, 1.0f};
display->startScene();
device->DrawPrimitiveUP(D3DPT_POINTLIST, 1, data, sizeof(data));
result = occlusionQuery->Issue(D3DISSUE_END);
if (FAILED(result))
{
ERR("occlusionQuery->Issue(END) failed hr=%x\n", result);
occlusionQuery->Release();
savedState->Apply();
savedState->Release();
ASSERT(false);
return;
}
while ((result = occlusionQuery->GetData(NULL, 0, D3DGETDATA_FLUSH)) == S_FALSE)
{
// Keep polling, but allow other threads to do something useful first
Sleep(0);
}
occlusionQuery->Release();
savedState->Apply();
savedState->Release();
if (result == D3DERR_DEVICELOST)
{
error(GL_OUT_OF_MEMORY);
}
}
void Context::flush()
{
IDirect3DDevice9 *device = getDevice();
IDirect3DQuery9 *eventQuery = NULL;
HRESULT result;
result = device->CreateQuery(D3DQUERYTYPE_EVENT, &eventQuery);
result = mDevice->CreateQuery(D3DQUERYTYPE_EVENT, &eventQuery);
if (FAILED(result))
{
ERR("CreateQuery failed hr=%x\n", result);
@ -2902,7 +2812,18 @@ void Context::flush()
return;
}
result = eventQuery->GetData(NULL, 0, D3DGETDATA_FLUSH);
do
{
result = eventQuery->GetData(NULL, 0, D3DGETDATA_FLUSH);
if(block && result == S_FALSE)
{
// Keep polling, but allow other threads to do something useful first
Sleep(0);
}
}
while(block && result == S_FALSE);
eventQuery->Release();
if (result == D3DERR_DEVICELOST)
@ -2913,7 +2834,6 @@ void Context::flush()
void Context::drawClosingLine(unsigned int first, unsigned int last)
{
IDirect3DDevice9 *device = getDevice();
IDirect3DIndexBuffer9 *indexBuffer = NULL;
bool succeeded = false;
UINT offset;
@ -2924,7 +2844,7 @@ void Context::drawClosingLine(unsigned int first, unsigned int last)
if (!mClosingIB)
{
mClosingIB = new StreamingIndexBuffer(device, CLOSING_INDEX_BUFFER_SIZE, D3DFMT_INDEX32);
mClosingIB = new StreamingIndexBuffer(mDevice, CLOSING_INDEX_BUFFER_SIZE, D3DFMT_INDEX32);
}
mClosingIB->reserveSpace(spaceNeeded, GL_UNSIGNED_INT);
@ -2945,7 +2865,7 @@ void Context::drawClosingLine(unsigned int first, unsigned int last)
if (!mClosingIB)
{
mClosingIB = new StreamingIndexBuffer(device, CLOSING_INDEX_BUFFER_SIZE, D3DFMT_INDEX16);
mClosingIB = new StreamingIndexBuffer(mDevice, CLOSING_INDEX_BUFFER_SIZE, D3DFMT_INDEX16);
}
mClosingIB->reserveSpace(spaceNeeded, GL_UNSIGNED_SHORT);
@ -2963,10 +2883,10 @@ void Context::drawClosingLine(unsigned int first, unsigned int last)
if (succeeded)
{
device->SetIndices(mClosingIB->getBuffer());
mDevice->SetIndices(mClosingIB->getBuffer());
mAppliedIBSerial = mClosingIB->getSerial();
device->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, last, offset, 1);
mDevice->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, last, offset, 1);
}
else
{
@ -3493,8 +3413,7 @@ const char *Context::getExtensionString() const
void Context::initRendererString()
{
egl::Display *display = getDisplay();
D3DADAPTER_IDENTIFIER9 *identifier = display->getAdapterIdentifier();
D3DADAPTER_IDENTIFIER9 *identifier = mDisplay->getAdapterIdentifier();
mRendererString = "ANGLE (";
mRendererString += identifier->Description;
@ -3510,8 +3429,6 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask)
{
IDirect3DDevice9 *device = getDevice();
Framebuffer *readFramebuffer = getReadFramebuffer();
Framebuffer *drawFramebuffer = getDrawFramebuffer();
@ -3752,12 +3669,11 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1
if (blitRenderTarget || blitDepthStencil)
{
egl::Display *display = getDisplay();
display->endScene();
mDisplay->endScene();
if (blitRenderTarget)
{
HRESULT result = device->StretchRect(readFramebuffer->getRenderTarget(), &sourceTrimmedRect,
HRESULT result = mDevice->StretchRect(readFramebuffer->getRenderTarget(), &sourceTrimmedRect,
drawFramebuffer->getRenderTarget(), &destTrimmedRect, D3DTEXF_NONE);
if (FAILED(result))
@ -3769,7 +3685,7 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1
if (blitDepthStencil)
{
HRESULT result = device->StretchRect(readFramebuffer->getDepthStencil(), NULL, drawFramebuffer->getDepthStencil(), NULL, D3DTEXF_NONE);
HRESULT result = mDevice->StretchRect(readFramebuffer->getDepthStencil(), NULL, drawFramebuffer->getDepthStencil(), NULL, D3DTEXF_NONE);
if (FAILED(result))
{
@ -3800,10 +3716,8 @@ VertexDeclarationCache::~VertexDeclarationCache()
}
}
GLenum VertexDeclarationCache::applyDeclaration(TranslatedAttribute attributes[], Program *program)
GLenum VertexDeclarationCache::applyDeclaration(IDirect3DDevice9 *device, TranslatedAttribute attributes[], Program *program)
{
IDirect3DDevice9 *device = getDevice();
D3DVERTEXELEMENT9 elements[MAX_VERTEX_ATTRIBS + 1];
D3DVERTEXELEMENT9 *element = &elements[0];

View File

@ -228,7 +228,7 @@ class VertexDeclarationCache
VertexDeclarationCache();
~VertexDeclarationCache();
GLenum applyDeclaration(TranslatedAttribute attributes[], Program *program);
GLenum applyDeclaration(IDirect3DDevice9 *device, TranslatedAttribute attributes[], Program *program);
void markStateDirty();
@ -421,8 +421,7 @@ class Context
void clear(GLbitfield mask);
void drawArrays(GLenum mode, GLint first, GLsizei count);
void drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices);
void finish();
void flush();
void sync(bool block); // flush/finish
// Draw the last segment of a line loop
void drawClosingLine(unsigned int first, unsigned int last);
@ -497,6 +496,8 @@ class Context
void initRendererString();
const egl::Config *const mConfig;
egl::Display *mDisplay;
IDirect3DDevice9 *mDevice;
State mState;

View File

@ -59,6 +59,7 @@ UniformLocation::UniformLocation(const std::string &_name, unsigned int element,
Program::Program(ResourceManager *manager, GLuint handle) : mResourceManager(manager), mHandle(handle), mSerial(issueSerial())
{
mDevice = getDevice();
mFragmentShader = NULL;
mVertexShader = NULL;
@ -1675,9 +1676,8 @@ void Program::link()
if (vertexBinary && pixelBinary)
{
IDirect3DDevice9 *device = getDevice();
HRESULT vertexResult = device->CreateVertexShader((DWORD*)vertexBinary->GetBufferPointer(), &mVertexExecutable);
HRESULT pixelResult = device->CreatePixelShader((DWORD*)pixelBinary->GetBufferPointer(), &mPixelExecutable);
HRESULT vertexResult = mDevice->CreateVertexShader((DWORD*)vertexBinary->GetBufferPointer(), &mVertexExecutable);
HRESULT pixelResult = mDevice->CreatePixelShader((DWORD*)pixelBinary->GetBufferPointer(), &mPixelExecutable);
if (vertexResult == D3DERR_OUTOFVIDEOMEMORY || vertexResult == E_OUTOFMEMORY || pixelResult == D3DERR_OUTOFVIDEOMEMORY || pixelResult == E_OUTOFMEMORY)
{
@ -2051,8 +2051,6 @@ std::string Program::undecorateUniform(const std::string &_name)
void Program::applyUniformnbv(Uniform *targetUniform, GLsizei count, int width, const GLboolean *v)
{
IDirect3DDevice9 *device = getDevice();
float *vector = NULL;
BOOL *boolVector = NULL;
@ -2091,11 +2089,11 @@ void Program::applyUniformnbv(Uniform *targetUniform, GLsizei count, int width,
{
if (targetUniform->ps.registerSet == D3DXRS_FLOAT4)
{
device->SetPixelShaderConstantF(targetUniform->ps.registerIndex, vector, targetUniform->ps.registerCount);
mDevice->SetPixelShaderConstantF(targetUniform->ps.registerIndex, vector, targetUniform->ps.registerCount);
}
else if (targetUniform->ps.registerSet == D3DXRS_BOOL)
{
device->SetPixelShaderConstantB(targetUniform->ps.registerIndex, boolVector, targetUniform->ps.registerCount);
mDevice->SetPixelShaderConstantB(targetUniform->ps.registerIndex, boolVector, targetUniform->ps.registerCount);
}
else UNREACHABLE();
}
@ -2104,11 +2102,11 @@ void Program::applyUniformnbv(Uniform *targetUniform, GLsizei count, int width,
{
if (targetUniform->vs.registerSet == D3DXRS_FLOAT4)
{
device->SetVertexShaderConstantF(targetUniform->vs.registerIndex, vector, targetUniform->vs.registerCount);
mDevice->SetVertexShaderConstantF(targetUniform->vs.registerIndex, vector, targetUniform->vs.registerCount);
}
else if (targetUniform->vs.registerSet == D3DXRS_BOOL)
{
device->SetVertexShaderConstantB(targetUniform->vs.registerIndex, boolVector, targetUniform->vs.registerCount);
mDevice->SetVertexShaderConstantB(targetUniform->vs.registerIndex, boolVector, targetUniform->vs.registerCount);
}
else UNREACHABLE();
}
@ -2119,16 +2117,14 @@ void Program::applyUniformnbv(Uniform *targetUniform, GLsizei count, int width,
bool Program::applyUniformnfv(Uniform *targetUniform, const GLfloat *v)
{
IDirect3DDevice9 *device = getDevice();
if (targetUniform->ps.registerCount)
{
device->SetPixelShaderConstantF(targetUniform->ps.registerIndex, v, targetUniform->ps.registerCount);
mDevice->SetPixelShaderConstantF(targetUniform->ps.registerIndex, v, targetUniform->ps.registerCount);
}
if (targetUniform->vs.registerCount)
{
device->SetVertexShaderConstantF(targetUniform->vs.registerIndex, v, targetUniform->vs.registerCount);
mDevice->SetVertexShaderConstantF(targetUniform->vs.registerIndex, v, targetUniform->vs.registerCount);
}
return true;
@ -2143,8 +2139,6 @@ bool Program::applyUniform1iv(Uniform *targetUniform, GLsizei count, const GLint
vector[i] = D3DXVECTOR4((float)v[i], 0, 0, 0);
}
IDirect3DDevice9 *device = getDevice();
if (targetUniform->ps.registerCount)
{
if (targetUniform->ps.registerSet == D3DXRS_SAMPLER)
@ -2165,7 +2159,7 @@ bool Program::applyUniform1iv(Uniform *targetUniform, GLsizei count, const GLint
else
{
ASSERT(targetUniform->ps.registerSet == D3DXRS_FLOAT4);
device->SetPixelShaderConstantF(targetUniform->ps.registerIndex, (const float*)vector, targetUniform->ps.registerCount);
mDevice->SetPixelShaderConstantF(targetUniform->ps.registerIndex, (const float*)vector, targetUniform->ps.registerCount);
}
}
@ -2189,7 +2183,7 @@ bool Program::applyUniform1iv(Uniform *targetUniform, GLsizei count, const GLint
else
{
ASSERT(targetUniform->vs.registerSet == D3DXRS_FLOAT4);
device->SetVertexShaderConstantF(targetUniform->vs.registerIndex, (const float *)vector, targetUniform->vs.registerCount);
mDevice->SetVertexShaderConstantF(targetUniform->vs.registerIndex, (const float *)vector, targetUniform->vs.registerCount);
}
}
@ -2254,18 +2248,16 @@ bool Program::applyUniform4iv(Uniform *targetUniform, GLsizei count, const GLint
void Program::applyUniformniv(Uniform *targetUniform, GLsizei count, const D3DXVECTOR4 *vector)
{
IDirect3DDevice9 *device = getDevice();
if (targetUniform->ps.registerCount)
{
ASSERT(targetUniform->ps.registerSet == D3DXRS_FLOAT4);
device->SetPixelShaderConstantF(targetUniform->ps.registerIndex, (const float *)vector, targetUniform->ps.registerCount);
mDevice->SetPixelShaderConstantF(targetUniform->ps.registerIndex, (const float *)vector, targetUniform->ps.registerCount);
}
if (targetUniform->vs.registerCount)
{
ASSERT(targetUniform->vs.registerSet == D3DXRS_FLOAT4);
device->SetVertexShaderConstantF(targetUniform->vs.registerIndex, (const float *)vector, targetUniform->vs.registerCount);
mDevice->SetVertexShaderConstantF(targetUniform->vs.registerIndex, (const float *)vector, targetUniform->vs.registerCount);
}
}

View File

@ -172,6 +172,7 @@ class Program
static unsigned int issueSerial();
IDirect3DDevice9 *mDevice;
FragmentShader *mFragmentShader;
VertexShader *mVertexShader;

View File

@ -1951,7 +1951,7 @@ void __stdcall glFinish(void)
if (context)
{
context->finish();
context->sync(true);
}
}
catch(std::bad_alloc&)
@ -1970,7 +1970,7 @@ void __stdcall glFlush(void)
if (context)
{
context->flush();
context->sync(false);
}
}
catch(std::bad_alloc&)