Bug 1076020. Update to ANGLE 2182 + fixes.

This corresponds to ANGLE commit 9a2e6ac98a10907b1241bd5709597912e08f63fb

It vastly improves D3D11 performance on Intel GPUs by
avoiding write to multiple render targets when unneeded.
This commit is contained in:
Jeff Muizelaar 2014-10-09 15:08:59 -04:00
Родитель 774e7108b3
Коммит 20abd56cbd
213 изменённых файлов: 16623 добавлений и 15892 удалений

Просмотреть файл

@ -14,6 +14,7 @@ TransGaming Inc.
Adobe Systems Inc.
Autodesk, Inc.
BlackBerry Limited
Borbitsoft
Cable Television Laboratories, Inc.
Cloud Party, Inc.
Intel Corporation

Просмотреть файл

@ -53,10 +53,9 @@ component("translator") {
"//build/config/compiler:no_chromium_code",
]
deps = [
public_deps = [
":translator_lib",
]
forward_dependent_configs_from = [ ":translator_lib" ]
}
# Holds the shared includes so we only need to list them once.
@ -99,7 +98,7 @@ static_library("translator_lib") {
":translator_static_config",
"//build/config/compiler:no_chromium_code",
]
direct_dependent_configs = [ ":external_config" ]
public_configs = [ ":external_config" ]
deps = [
":includes",
@ -118,12 +117,11 @@ static_library("translator_static") {
":internal_config",
"//build/config/compiler:no_chromium_code",
]
direct_dependent_configs = [ ":translator_static_config" ]
public_configs = [ ":translator_static_config" ]
deps = [
public_deps = [
":translator_lib",
]
forward_dependent_configs_from = [ ":translator_lib" ]
}
config("commit_id_config") {
@ -142,7 +140,7 @@ action("commit_id") {
rebase_path(output_file, root_build_dir),
]
direct_dependent_configs = [ ":commit_id_config" ]
public_configs = [ ":commit_id_config" ]
}
if (is_win) {
@ -150,7 +148,12 @@ if (is_win) {
angle_enable_d3d11 = true
shared_library("libGLESv2") {
sources = rebase_path(gles_gypi.angle_libglesv2_sources, ".", "src")
sources = rebase_path(gles_gypi.angle_libangle_sources, ".", "src")
sources += [
"src/libGLESv2/libGLESv2.cpp",
"src/libGLESv2/libGLESv2.def",
"src/libGLESv2/libGLESv2.rc",
]
defines = [
"ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ " +

Просмотреть файл

@ -49,6 +49,9 @@ Adobe Systems Inc.
Autodesk, Inc.
Ranger Harke
Borbitsoft
Tibor den Ouden
Cloud Party, Inc.
Conor Dickinson
@ -78,6 +81,7 @@ Turbulenz
Ulrik Persson (ddefrostt)
Mark Banner (standard8mbp)
David Kilzer
Jacek Caban
Microsoft Open Technologies, Inc.
Cooper Partin

Просмотреть файл

@ -1,6 +1,6 @@
deps = {
"third_party/gyp":
"http://gyp.googlecode.com/svn/trunk@1806",
"http://gyp.googlecode.com/svn/trunk@1987",
"tests/third_party/googletest":
"http://googletest.googlecode.com/svn/trunk@629",

Просмотреть файл

@ -2,6 +2,7 @@
# Please note this file is autogenerated from generate_mozbuild.py, so do not modify it directly
UNIFIED_SOURCES += [
'src/common/angleutils.cpp',
'src/common/blocklayout.cpp',
'src/common/debug.cpp',
'src/common/event_tracer.cpp',

Просмотреть файл

@ -26,6 +26,7 @@
{
'target_name': 'copy_scripts',
'type': 'none',
'hard_dependency': 1,
'copies':
[
{
@ -46,6 +47,7 @@
'type': 'none',
'includes': [ '../build/common_defines.gypi', ],
'dependencies': [ 'copy_scripts', ],
'hard_dependency': 1,
'actions':
[
{
@ -61,7 +63,7 @@
],
},
],
'direct_dependent_settings':
'all_dependent_settings':
{
'include_dirs':
[
@ -77,6 +79,7 @@
{
'target_name': 'commit_id',
'type': 'none',
'hard_dependency': 1,
'copies':
[
{
@ -84,7 +87,7 @@
'files': [ '<(angle_id_header_base)' ]
}
],
'direct_dependent_settings':
'all_dependent_settings':
{
'include_dirs':
[

Просмотреть файл

@ -1,3 +1,3 @@
#define ANGLE_COMMIT_HASH "9a22db4058f8"
#define ANGLE_COMMIT_HASH "fc329b4537cf"
#define ANGLE_COMMIT_HASH_SIZE 12
#define ANGLE_COMMIT_DATE "2014-09-19 12:49:11 -0700"
#define ANGLE_COMMIT_DATE "2014-10-09 15:05:59 -0400"

Просмотреть файл

@ -0,0 +1,53 @@
//
// Copyright (c) 2002-2014 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.
//
// NativeWindow.h: Defines NativeWindow, a class for managing and
// performing operations on an EGLNativeWindowType.
// It is used for HWND (Desktop Windows) and IInspectable objects
//(Windows Store Applications).
#ifndef COMMON_NATIVEWINDOW_H_
#define COMMON_NATIVEWINDOW_H_
#include <EGL/eglplatform.h>
#include "common/debug.h"
#include "common/platform.h"
// DXGISwapChain and DXGIFactory are typedef'd to specific required
// types. The HWND NativeWindow implementation requires IDXGISwapChain
// and IDXGIFactory and the Windows Store NativeWindow
// implementation requires IDXGISwapChain1 and IDXGIFactory2.
typedef IDXGISwapChain DXGISwapChain;
typedef IDXGIFactory DXGIFactory;
namespace rx
{
class NativeWindow
{
public:
explicit NativeWindow(EGLNativeWindowType window);
// The HWND NativeWindow implementation can benefit
// by having inline versions of these methods to
// reduce the calling overhead.
inline bool initialize() { return true; }
inline bool getClientRect(LPRECT rect) { return GetClientRect(mWindow, rect) == TRUE; }
inline bool isIconic() { return IsIconic(mWindow) == TRUE; }
HRESULT createSwapChain(ID3D11Device* device, DXGIFactory* factory,
DXGI_FORMAT format, UINT width, UINT height,
DXGISwapChain** swapChain);
inline EGLNativeWindowType getNativeWindow() const { return mWindow; }
private:
EGLNativeWindowType mWindow;
};
}
bool isValidEGLNativeWindowType(EGLNativeWindowType window);
#endif // COMMON_NATIVEWINDOW_H_

Просмотреть файл

@ -24,7 +24,7 @@ std::string FormatString(const char *fmt, va_list vararg)
vsnprintf(&buffer[0], buffer.size(), fmt, vararg);
}
return std::string(buffer.data(), len);
return std::string(&buffer[0], len);
}
std::string FormatString(const char *fmt, ...)

Просмотреть файл

@ -87,7 +87,6 @@ bool perfActive()
ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...)
{
#if defined(ANGLE_ENABLE_PERF)
#if !defined(ANGLE_ENABLE_TRACE)
if (!perfActive())
{
@ -96,9 +95,12 @@ ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...)
#endif // !ANGLE_ENABLE_TRACE
va_list vararg;
va_start(vararg, format);
#if defined(ANGLE_ENABLE_PERF)
output(true, reinterpret_cast<PerfOutputFunction>(D3DPERF_BeginEvent), format, vararg);
va_end(vararg);
#else
output(true, NULL, format, vararg);
#endif // ANGLE_ENABLE_PERF
va_end(vararg);
}
ScopedPerfEventHelper::~ScopedPerfEventHelper()

Просмотреть файл

@ -91,6 +91,10 @@ namespace gl
// A macro to indicate unimplemented functionality
#if defined (ANGLE_TEST_CONFIG)
#define NOASSERT_UNIMPLEMENTED 1
#endif
// Define NOASSERT_UNIMPLEMENTED to non zero to skip the assert fail in the unimplemented checks
// This will allow us to test with some automated test suites (eg dEQP) without crashing
#ifndef NOASSERT_UNIMPLEMENTED

Просмотреть файл

@ -507,12 +507,12 @@ template <typename T>
struct Range
{
Range() {}
Range(T lo, T hi) : start(lo), end(hi) { }
Range(T lo, T hi) : start(lo), end(hi) { ASSERT(lo <= hi); }
T start;
T end;
T length() const { return (end > start ? (end - start) : 0); }
T length() const { return end - start; }
};
typedef Range<int> RangeI;

Просмотреть файл

@ -0,0 +1,51 @@
//
// Copyright (c) 2002-2014 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.
//
// NativeWindow.cpp: Handler for managing HWND native window types.
#include "common/NativeWindow.h"
#include "common/debug.h"
bool isValidEGLNativeWindowType(EGLNativeWindowType window)
{
return (IsWindow(window) == TRUE);
}
namespace rx
{
NativeWindow::NativeWindow(EGLNativeWindowType window) : mWindow(window)
{
}
HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory,
DXGI_FORMAT format, unsigned int width, unsigned int height,
DXGISwapChain** swapChain)
{
if (device == NULL || factory == NULL || swapChain == NULL || width == 0 || height == 0)
{
return E_INVALIDARG;
}
DXGI_SWAP_CHAIN_DESC swapChainDesc = { 0 };
swapChainDesc.BufferCount = 1;
swapChainDesc.BufferDesc.Format = format;
swapChainDesc.BufferDesc.Width = width;
swapChainDesc.BufferDesc.Height = height;
swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_BACK_BUFFER;
swapChainDesc.Flags = 0;
swapChainDesc.OutputWindow = mWindow;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.Windowed = TRUE;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
return factory->CreateSwapChain(device, &swapChainDesc, swapChain);
}
};

Просмотреть файл

@ -24,6 +24,7 @@
'common/RefCountObject.cpp',
'common/RefCountObject.h',
'common/angleutils.h',
'common/angleutils.cpp',
'common/blocklayout.cpp',
'common/blocklayout.h',
'common/debug.cpp',

Просмотреть файл

@ -502,18 +502,18 @@ bool TCompiler::enforceVertexShaderTimingRestrictions(TIntermNode* root)
void TCompiler::collectVariables(TIntermNode* root)
{
CollectVariables collect(&attributes,
&outputVariables,
&uniforms,
&varyings,
&interfaceBlocks,
hashFunction);
sh::CollectVariables collect(&attributes,
&outputVariables,
&uniforms,
&varyings,
&interfaceBlocks,
hashFunction);
root->traverse(&collect);
// For backwards compatiblity with ShGetVariableInfo, expand struct
// uniforms and varyings into separate variables for each field.
ExpandVariables(uniforms, &expandedUniforms);
ExpandVariables(varyings, &expandedVaryings);
sh::ExpandVariables(uniforms, &expandedUniforms);
sh::ExpandVariables(varyings, &expandedVaryings);
}
bool TCompiler::enforcePackingRestrictions()

Просмотреть файл

@ -83,6 +83,9 @@ class TCompiler : public TShHandleBase
ShShaderOutput getOutputType() const { return outputType; }
std::string getBuiltInResourcesString() const { return builtInResourcesString; }
// Get the resources set by InitBuiltInSymbolTable
const ShBuiltInResources& getResources() const;
protected:
sh::GLenum getShaderType() const { return shaderType; }
// Initialize symbol-table with built-in symbols.
@ -128,8 +131,6 @@ class TCompiler : public TShHandleBase
bool limitExpressionComplexity(TIntermNode* root);
// Get built-in extensions with default behavior.
const TExtensionBehavior& getExtensionBehavior() const;
// Get the resources set by InitBuiltInSymbolTable
const ShBuiltInResources& getResources() const;
const ArrayBoundsClamper& getArrayBoundsClamper() const;
ShArrayIndexClampingStrategy getArrayIndexClampingStrategy() const;

Просмотреть файл

@ -21,6 +21,7 @@
#include "compiler/translator/util.h"
#include "compiler/translator/UniformHLSL.h"
#include "compiler/translator/StructureHLSL.h"
#include "compiler/translator/TranslatorHLSL.h"
#include <algorithm>
#include <cfloat>
@ -29,18 +30,6 @@
namespace sh
{
static sh::Attribute MakeAttributeFromType(const TType &type, const TString &name)
{
sh::Attribute attributeVar;
attributeVar.type = GLVariableType(type);
attributeVar.precision = GLVariablePrecision(type);
attributeVar.name = name.c_str();
attributeVar.arraySize = static_cast<unsigned int>(type.getArraySize());
attributeVar.location = type.getLayoutQualifier().location;
return attributeVar;
}
TString OutputHLSL::TextureFunction::name() const
{
TString name = "gl_texture";
@ -105,8 +94,10 @@ bool OutputHLSL::TextureFunction::operator<(const TextureFunction &rhs) const
return false;
}
OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resources, ShShaderOutput outputType)
: TIntermTraverser(true, true, true), mContext(context), mOutputType(outputType)
OutputHLSL::OutputHLSL(TParseContext &context, TranslatorHLSL *parentTranslator)
: TIntermTraverser(true, true, true),
mContext(context),
mOutputType(parentTranslator->getOutputType())
{
mUnfoldShortCircuit = new UnfoldShortCircuit(context, this);
mInsideFunction = false;
@ -138,6 +129,7 @@ OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resourc
mUsesDiscardRewriting = false;
mUsesNestedBreak = false;
const ShBuiltInResources &resources = parentTranslator->getResources();
mNumRenderTargets = resources.EXT_draw_buffers ? resources.MaxDrawBuffers : 1;
mUniqueIndex = 0;
@ -150,7 +142,7 @@ OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resourc
mExcessiveLoopIndex = NULL;
mStructureHLSL = new StructureHLSL;
mUniformHLSL = new UniformHLSL(mStructureHLSL, mOutputType);
mUniformHLSL = new UniformHLSL(mStructureHLSL, parentTranslator);
if (mOutputType == SH_HLSL9_OUTPUT)
{
@ -224,31 +216,6 @@ TInfoSinkBase &OutputHLSL::getBodyStream()
return mBody;
}
const std::vector<sh::Uniform> &OutputHLSL::getUniforms()
{
return mUniformHLSL->getUniforms();
}
const std::vector<sh::InterfaceBlock> &OutputHLSL::getInterfaceBlocks() const
{
return mUniformHLSL->getInterfaceBlocks();
}
const std::vector<sh::Attribute> &OutputHLSL::getOutputVariables() const
{
return mActiveOutputVariables;
}
const std::vector<sh::Attribute> &OutputHLSL::getAttributes() const
{
return mActiveAttributes;
}
const std::vector<sh::Varying> &OutputHLSL::getVaryings() const
{
return mActiveVaryings;
}
const std::map<std::string, unsigned int> &OutputHLSL::getInterfaceBlockRegisterMap() const
{
return mUniformHLSL->getInterfaceBlockRegisterMap();
@ -336,8 +303,6 @@ void OutputHLSL::header()
// Program linking depends on this exact format
varyings += "static " + InterpolationString(type.getQualifier()) + " " + TypeString(type) + " " +
Decorate(name) + ArrayString(type) + " = " + initializer(type) + ";\n";
declareVaryingToList(type, type.getQualifier(), name, mActiveVaryings);
}
for (ReferencedSymbols::const_iterator attribute = mReferencedAttributes.begin(); attribute != mReferencedAttributes.end(); attribute++)
@ -346,9 +311,6 @@ void OutputHLSL::header()
const TString &name = attribute->second->getSymbol();
attributes += "static " + TypeString(type) + " " + Decorate(name) + ArrayString(type) + " = " + initializer(type) + ";\n";
sh::Attribute attributeVar = MakeAttributeFromType(type, name);
mActiveAttributes.push_back(attributeVar);
}
out << mStructureHLSL->structsHeader();
@ -384,9 +346,6 @@ void OutputHLSL::header()
out << "static " + TypeString(variableType) + " out_" + variableName + ArrayString(variableType) +
" = " + initializer(variableType) + ";\n";
sh::Attribute outputVar = MakeAttributeFromType(variableType, variableName);
mActiveOutputVariables.push_back(outputVar);
}
}
else
@ -2922,12 +2881,4 @@ const ConstantUnion *OutputHLSL::writeConstantUnion(const TType &type, const Con
return constUnion;
}
void OutputHLSL::declareVaryingToList(const TType &type, TQualifier baseTypeQualifier,
const TString &name, std::vector<Varying> &fieldsOut)
{
GetVariableTraverser traverser;
traverser.traverse(type, name, &fieldsOut);
fieldsOut.back().interpolation = GetInterpolationType(baseTypeQualifier);
}
}

Просмотреть файл

@ -27,17 +27,12 @@ typedef std::map<TString, TIntermSymbol*> ReferencedSymbols;
class OutputHLSL : public TIntermTraverser
{
public:
OutputHLSL(TParseContext &context, const ShBuiltInResources& resources, ShShaderOutput outputType);
OutputHLSL(TParseContext &context, TranslatorHLSL *parentTranslator);
~OutputHLSL();
void output();
TInfoSinkBase &getBodyStream();
const std::vector<sh::Uniform> &getUniforms();
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const;
const std::vector<sh::Attribute> &getOutputVariables() const;
const std::vector<sh::Attribute> &getAttributes() const;
const std::vector<sh::Varying> &getVaryings() const;
const std::map<std::string, unsigned int> &getInterfaceBlockRegisterMap() const;
const std::map<std::string, unsigned int> &getUniformRegisterMap() const;
@ -155,13 +150,8 @@ class OutputHLSL : public TIntermTraverser
TIntermSymbol *mExcessiveLoopIndex;
void declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector<sh::Varying>& fieldsOut);
TString structInitializerString(int indent, const TStructure &structure, const TString &rhsStructName);
std::vector<sh::Attribute> mActiveOutputVariables;
std::vector<sh::Attribute> mActiveAttributes;
std::vector<sh::Varying> mActiveVaryings;
std::map<TIntermTyped*, TString> mFlaggedStructMappedNames;
std::map<TIntermTyped*, TString> mFlaggedStructOriginalNames;

Просмотреть файл

@ -17,16 +17,10 @@ TranslatorHLSL::TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutpu
void TranslatorHLSL::translate(TIntermNode *root)
{
TParseContext& parseContext = *GetGlobalParseContext();
sh::OutputHLSL outputHLSL(parseContext, getResources(), getOutputType());
sh::OutputHLSL outputHLSL(parseContext, this);
outputHLSL.output();
attributes = outputHLSL.getAttributes();
outputVariables = outputHLSL.getOutputVariables();
uniforms = outputHLSL.getUniforms();
varyings = outputHLSL.getVaryings();
interfaceBlocks = outputHLSL.getInterfaceBlocks();
mInterfaceBlockRegisterMap = outputHLSL.getInterfaceBlockRegisterMap();
mUniformRegisterMap = outputHLSL.getUniformRegisterMap();
}

Просмотреть файл

@ -14,6 +14,7 @@
#include "compiler/translator/StructureHLSL.h"
#include "compiler/translator/util.h"
#include "compiler/translator/UtilsHLSL.h"
#include "compiler/translator/TranslatorHLSL.h"
namespace sh
{
@ -60,12 +61,13 @@ static TString InterfaceBlockStructName(const TInterfaceBlock &interfaceBlock)
return DecoratePrivate(interfaceBlock.name()) + "_type";
}
UniformHLSL::UniformHLSL(StructureHLSL *structureHLSL, ShShaderOutput outputType)
UniformHLSL::UniformHLSL(StructureHLSL *structureHLSL, TranslatorHLSL *translator)
: mUniformRegister(0),
mInterfaceBlockRegister(0),
mSamplerRegister(0),
mStructureHLSL(structureHLSL),
mOutputType(outputType)
mOutputType(translator->getOutputType()),
mUniforms(translator->getUniforms())
{}
void UniformHLSL::reserveUniformRegisters(unsigned int registerCount)
@ -78,18 +80,32 @@ void UniformHLSL::reserveInterfaceBlockRegisters(unsigned int registerCount)
mInterfaceBlockRegister = registerCount;
}
const Uniform *UniformHLSL::findUniformByName(const TString &name) const
{
for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); ++uniformIndex)
{
if (mUniforms[uniformIndex].name == name.c_str())
{
return &mUniforms[uniformIndex];
}
}
UNREACHABLE();
return NULL;
}
unsigned int UniformHLSL::declareUniformAndAssignRegister(const TType &type, const TString &name)
{
unsigned int registerIndex = (IsSampler(type.getBasicType()) ? mSamplerRegister : mUniformRegister);
GetVariableTraverser traverser;
traverser.traverse(type, name, &mActiveUniforms);
const Uniform *uniform = findUniformByName(name);
ASSERT(uniform);
const sh::Uniform &activeUniform = mActiveUniforms.back();
mUniformRegisterMap[activeUniform.name] = registerIndex;
mUniformRegisterMap[uniform->name] = registerIndex;
unsigned int registerCount = HLSLVariableRegisterCount(activeUniform, mOutputType);
if (IsSampler(type.getBasicType()))
unsigned int registerCount = HLSLVariableRegisterCount(*uniform, mOutputType);
if (gl::IsSampler(uniform->type))
{
mSamplerRegister += registerCount;
}
@ -154,23 +170,10 @@ TString UniformHLSL::interfaceBlocksHeader(const ReferencedSymbols &referencedIn
unsigned int arraySize = static_cast<unsigned int>(interfaceBlock.arraySize());
unsigned int activeRegister = mInterfaceBlockRegister;
InterfaceBlock activeBlock;
activeBlock.name = interfaceBlock.name().c_str();
activeBlock.arraySize = arraySize;
GetInterfaceBlockFields(interfaceBlock, &activeBlock.fields);
mInterfaceBlockRegisterMap[activeBlock.name] = activeRegister;
mInterfaceBlockRegisterMap[interfaceBlock.name().c_str()] = activeRegister;
mInterfaceBlockRegister += std::max(1u, arraySize);
activeBlock.layout = GetBlockLayoutType(interfaceBlock.blockStorage());
if (interfaceBlock.matrixPacking() == EmpRowMajor)
{
activeBlock.isRowMajorLayout = true;
}
mActiveInterfaceBlocks.push_back(activeBlock);
// FIXME: interface block field names
if (interfaceBlock.hasInstanceName())
{

Просмотреть файл

@ -19,7 +19,7 @@ class StructureHLSL;
class UniformHLSL
{
public:
UniformHLSL(StructureHLSL *structureHLSL, ShShaderOutput outputType);
UniformHLSL(StructureHLSL *structureHLSL, TranslatorHLSL *translator);
void reserveUniformRegisters(unsigned int registerCount);
void reserveInterfaceBlockRegisters(unsigned int registerCount);
@ -29,8 +29,6 @@ class UniformHLSL
// Used for direct index references
static TString interfaceBlockInstanceString(const TInterfaceBlock& interfaceBlock, unsigned int arrayIndex);
const std::vector<Uniform> &getUniforms() const { return mActiveUniforms; }
const std::vector<InterfaceBlock> &getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
const std::map<std::string, unsigned int> &getInterfaceBlockRegisterMap() const
{
return mInterfaceBlockRegisterMap;
@ -44,6 +42,7 @@ class UniformHLSL
TString interfaceBlockString(const TInterfaceBlock &interfaceBlock, unsigned int registerIndex, unsigned int arrayIndex);
TString interfaceBlockMembersString(const TInterfaceBlock &interfaceBlock, TLayoutBlockStorage blockStorage);
TString interfaceBlockStructString(const TInterfaceBlock &interfaceBlock);
const Uniform *findUniformByName(const TString &name) const;
// Returns the uniform's register index
unsigned int declareUniformAndAssignRegister(const TType &type, const TString &name);
@ -54,8 +53,7 @@ class UniformHLSL
StructureHLSL *mStructureHLSL;
ShShaderOutput mOutputType;
std::vector<Uniform> mActiveUniforms;
std::vector<InterfaceBlock> mActiveInterfaceBlocks;
const std::vector<Uniform> &mUniforms;
std::map<std::string, unsigned int> mInterfaceBlockRegisterMap;
std::map<std::string, unsigned int> mUniformRegisterMap;
};

Просмотреть файл

@ -9,17 +9,46 @@
#include "compiler/translator/util.h"
#include "common/utilities.h"
static void ExpandUserDefinedVariable(const sh::ShaderVariable &variable,
const std::string &name,
const std::string &mappedName,
bool markStaticUse,
std::vector<sh::ShaderVariable> *expanded);
namespace sh
{
static void ExpandVariable(const sh::ShaderVariable &variable,
const std::string &name,
const std::string &mappedName,
bool markStaticUse,
std::vector<sh::ShaderVariable> *expanded)
namespace
{
TString InterfaceBlockFieldName(const TInterfaceBlock &interfaceBlock, const TField &field)
{
if (interfaceBlock.hasInstanceName())
{
return interfaceBlock.name() + "." + field.name();
}
else
{
return field.name();
}
}
BlockLayoutType GetBlockLayoutType(TLayoutBlockStorage blockStorage)
{
switch (blockStorage)
{
case EbsPacked: return BLOCKLAYOUT_PACKED;
case EbsShared: return BLOCKLAYOUT_SHARED;
case EbsStd140: return BLOCKLAYOUT_STANDARD;
default: UNREACHABLE(); return BLOCKLAYOUT_SHARED;
}
}
void ExpandUserDefinedVariable(const ShaderVariable &variable,
const std::string &name,
const std::string &mappedName,
bool markStaticUse,
std::vector<ShaderVariable> *expanded);
void ExpandVariable(const ShaderVariable &variable,
const std::string &name,
const std::string &mappedName,
bool markStaticUse,
std::vector<ShaderVariable> *expanded)
{
if (variable.isStruct())
{
@ -27,8 +56,8 @@ static void ExpandVariable(const sh::ShaderVariable &variable,
{
for (size_t elementIndex = 0; elementIndex < variable.elementCount(); elementIndex++)
{
std::string lname = name + ArrayString(elementIndex);
std::string lmappedName = mappedName + ArrayString(elementIndex);
std::string lname = name + ::ArrayString(elementIndex);
std::string lmappedName = mappedName + ::ArrayString(elementIndex);
ExpandUserDefinedVariable(variable, lname, lmappedName, markStaticUse, expanded);
}
}
@ -39,7 +68,7 @@ static void ExpandVariable(const sh::ShaderVariable &variable,
}
else
{
sh::ShaderVariable expandedVar = variable;
ShaderVariable expandedVar = variable;
expandedVar.name = name;
expandedVar.mappedName = mappedName;
@ -60,19 +89,19 @@ static void ExpandVariable(const sh::ShaderVariable &variable,
}
}
static void ExpandUserDefinedVariable(const sh::ShaderVariable &variable,
const std::string &name,
const std::string &mappedName,
bool markStaticUse,
std::vector<sh::ShaderVariable> *expanded)
void ExpandUserDefinedVariable(const ShaderVariable &variable,
const std::string &name,
const std::string &mappedName,
bool markStaticUse,
std::vector<ShaderVariable> *expanded)
{
ASSERT(variable.isStruct());
const std::vector<sh::ShaderVariable> &fields = variable.fields;
const std::vector<ShaderVariable> &fields = variable.fields;
for (size_t fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++)
{
const sh::ShaderVariable &field = fields[fieldIndex];
const ShaderVariable &field = fields[fieldIndex];
ExpandVariable(field,
name + "." + field.name,
mappedName + "." + field.mappedName,
@ -82,8 +111,8 @@ static void ExpandUserDefinedVariable(const sh::ShaderVariable &variable,
}
template <class VarT>
static VarT *FindVariable(const TString &name,
std::vector<VarT> *infoList)
VarT *FindVariable(const TString &name,
std::vector<VarT> *infoList)
{
// TODO(zmo): optimize this function.
for (size_t ii = 0; ii < infoList->size(); ++ii)
@ -95,6 +124,8 @@ static VarT *FindVariable(const TString &name,
return NULL;
}
}
CollectVariables::CollectVariables(std::vector<sh::Attribute> *attribs,
std::vector<sh::Attribute> *outputVariables,
std::vector<sh::Uniform> *uniforms,
@ -121,10 +152,10 @@ CollectVariables::CollectVariables(std::vector<sh::Attribute> *attribs,
void CollectVariables::visitSymbol(TIntermSymbol *symbol)
{
ASSERT(symbol != NULL);
sh::ShaderVariable *var = NULL;
ShaderVariable *var = NULL;
const TString &symbolName = symbol->getSymbol();
if (sh::IsVarying(symbol->getQualifier()))
if (IsVarying(symbol->getQualifier()))
{
var = FindVariable(symbolName, mVaryings);
}
@ -148,7 +179,7 @@ void CollectVariables::visitSymbol(TIntermSymbol *symbol)
const TInterfaceBlock *interfaceBlock = symbol->getType().getInterfaceBlock();
if (interfaceBlock)
{
sh::InterfaceBlock *namedBlock = FindVariable(interfaceBlock->name(), mInterfaceBlocks);
InterfaceBlock *namedBlock = FindVariable(interfaceBlock->name(), mInterfaceBlocks);
ASSERT(namedBlock);
var = FindVariable(symbolName, &namedBlock->fields);
@ -168,7 +199,7 @@ void CollectVariables::visitSymbol(TIntermSymbol *symbol)
case EvqFragCoord:
if (!mFragCoordAdded)
{
sh::Varying info;
Varying info;
info.name = "gl_FragCoord";
info.mappedName = "gl_FragCoord";
info.type = GL_FLOAT_VEC4;
@ -182,7 +213,7 @@ void CollectVariables::visitSymbol(TIntermSymbol *symbol)
case EvqFrontFacing:
if (!mFrontFacingAdded)
{
sh::Varying info;
Varying info;
info.name = "gl_FrontFacing";
info.mappedName = "gl_FrontFacing";
info.type = GL_BOOL;
@ -196,7 +227,7 @@ void CollectVariables::visitSymbol(TIntermSymbol *symbol)
case EvqPointCoord:
if (!mPointCoordAdded)
{
sh::Varying info;
Varying info;
info.name = "gl_PointCoord";
info.mappedName = "gl_PointCoord";
info.type = GL_FLOAT_VEC2;
@ -217,7 +248,7 @@ void CollectVariables::visitSymbol(TIntermSymbol *symbol)
}
}
class NameHashingTraverser : public sh::GetVariableTraverser
class NameHashingTraverser : public GetVariableTraverser
{
public:
NameHashingTraverser(ShHashFunction64 hashFunction)
@ -227,7 +258,7 @@ class NameHashingTraverser : public sh::GetVariableTraverser
private:
DISALLOW_COPY_AND_ASSIGN(NameHashingTraverser);
virtual void visitVariable(sh::ShaderVariable *variable)
virtual void visitVariable(ShaderVariable *variable)
{
TString stringName = TString(variable->name.c_str());
variable->mappedName = TIntermTraverser::hash(stringName, mHashFunction).c_str();
@ -239,16 +270,16 @@ class NameHashingTraverser : public sh::GetVariableTraverser
// Attributes, which cannot have struct fields, are a special case
template <>
void CollectVariables::visitVariable(const TIntermSymbol *variable,
std::vector<sh::Attribute> *infoList) const
std::vector<Attribute> *infoList) const
{
ASSERT(variable);
const TType &type = variable->getType();
ASSERT(!type.getStruct());
sh::Attribute attribute;
Attribute attribute;
attribute.type = sh::GLVariableType(type);
attribute.precision = sh::GLVariablePrecision(type);
attribute.type = GLVariableType(type);
attribute.precision = GLVariablePrecision(type);
attribute.name = variable->getSymbol().c_str();
attribute.arraySize = static_cast<unsigned int>(type.getArraySize());
attribute.mappedName = TIntermTraverser::hash(variable->getSymbol(), mHashFunction).c_str();
@ -259,9 +290,9 @@ void CollectVariables::visitVariable(const TIntermSymbol *variable,
template <>
void CollectVariables::visitVariable(const TIntermSymbol *variable,
std::vector<sh::InterfaceBlock> *infoList) const
std::vector<InterfaceBlock> *infoList) const
{
sh::InterfaceBlock interfaceBlock;
InterfaceBlock interfaceBlock;
const TInterfaceBlock *blockType = variable->getType().getInterfaceBlock();
ASSERT(blockType);
@ -270,10 +301,22 @@ void CollectVariables::visitVariable(const TIntermSymbol *variable,
interfaceBlock.instanceName = (blockType->hasInstanceName() ? blockType->instanceName().c_str() : "");
interfaceBlock.arraySize = variable->getArraySize();
interfaceBlock.isRowMajorLayout = (blockType->matrixPacking() == EmpRowMajor);
interfaceBlock.layout = sh::GetBlockLayoutType(blockType->blockStorage());
interfaceBlock.layout = GetBlockLayoutType(blockType->blockStorage());
// Gather field information
sh::GetInterfaceBlockFields(*blockType, &interfaceBlock.fields);
const TFieldList &fieldList = blockType->fields();
for (size_t fieldIndex = 0; fieldIndex < fieldList.size(); ++fieldIndex)
{
const TField &field = *fieldList[fieldIndex];
const TString &fullFieldName = InterfaceBlockFieldName(*blockType, field);
const TType &fieldType = *field.type();
GetVariableTraverser traverser;
traverser.traverse(fieldType, fullFieldName, &interfaceBlock.fields);
interfaceBlock.fields.back().isRowMajorLayout = (fieldType.getLayoutQualifier().matrixPacking == EmpRowMajor);
}
infoList->push_back(interfaceBlock);
}
@ -324,7 +367,7 @@ bool CollectVariables::visitAggregate(Visit, TIntermAggregate *node)
}
else if (qualifier == EvqAttribute || qualifier == EvqVertexIn ||
qualifier == EvqFragmentOut || qualifier == EvqUniform ||
sh::IsVarying(qualifier))
IsVarying(qualifier))
{
switch (qualifier)
{
@ -365,7 +408,7 @@ bool CollectVariables::visitBinary(Visit, TIntermBinary *binaryNode)
ASSERT(constantUnion);
const TInterfaceBlock *interfaceBlock = blockNode->getType().getInterfaceBlock();
sh::InterfaceBlock *namedBlock = FindVariable(interfaceBlock->name(), mInterfaceBlocks);
InterfaceBlock *namedBlock = FindVariable(interfaceBlock->name(), mInterfaceBlocks);
ASSERT(namedBlock);
namedBlock->staticUse = true;
@ -380,14 +423,16 @@ bool CollectVariables::visitBinary(Visit, TIntermBinary *binaryNode)
template <typename VarT>
void ExpandVariables(const std::vector<VarT> &compact,
std::vector<sh::ShaderVariable> *expanded)
std::vector<ShaderVariable> *expanded)
{
for (size_t variableIndex = 0; variableIndex < compact.size(); variableIndex++)
{
const sh::ShaderVariable &variable = compact[variableIndex];
const ShaderVariable &variable = compact[variableIndex];
ExpandVariable(variable, variable.name, variable.mappedName, variable.staticUse, expanded);
}
}
template void ExpandVariables(const std::vector<sh::Uniform> &, std::vector<sh::ShaderVariable> *);
template void ExpandVariables(const std::vector<sh::Varying> &, std::vector<sh::ShaderVariable> *);
template void ExpandVariables(const std::vector<Uniform> &, std::vector<ShaderVariable> *);
template void ExpandVariables(const std::vector<Varying> &, std::vector<ShaderVariable> *);
}

Просмотреть файл

@ -11,15 +11,18 @@
#include "compiler/translator/IntermNode.h"
namespace sh
{
// Traverses intermediate tree to collect all attributes, uniforms, varyings.
class CollectVariables : public TIntermTraverser
{
public:
CollectVariables(std::vector<sh::Attribute> *attribs,
std::vector<sh::Attribute> *outputVariables,
std::vector<sh::Uniform> *uniforms,
std::vector<sh::Varying> *varyings,
std::vector<sh::InterfaceBlock> *interfaceBlocks,
CollectVariables(std::vector<Attribute> *attribs,
std::vector<Attribute> *outputVariables,
std::vector<Uniform> *uniforms,
std::vector<Varying> *varyings,
std::vector<InterfaceBlock> *interfaceBlocks,
ShHashFunction64 hashFunction);
virtual void visitSymbol(TIntermSymbol *symbol);
@ -33,13 +36,13 @@ class CollectVariables : public TIntermTraverser
template <typename VarT>
void visitInfoList(const TIntermSequence &sequence, std::vector<VarT> *infoList) const;
std::vector<sh::Attribute> *mAttribs;
std::vector<sh::Attribute> *mOutputVariables;
std::vector<sh::Uniform> *mUniforms;
std::vector<sh::Varying> *mVaryings;
std::vector<sh::InterfaceBlock> *mInterfaceBlocks;
std::vector<Attribute> *mAttribs;
std::vector<Attribute> *mOutputVariables;
std::vector<Uniform> *mUniforms;
std::vector<Varying> *mVaryings;
std::vector<InterfaceBlock> *mInterfaceBlocks;
std::map<std::string, sh::InterfaceBlockField *> mInterfaceBlockFields;
std::map<std::string, InterfaceBlockField *> mInterfaceBlockFields;
bool mPointCoordAdded;
bool mFrontFacingAdded;
@ -51,6 +54,8 @@ class CollectVariables : public TIntermTraverser
// Expand struct variables to flattened lists of split variables
template <typename VarT>
void ExpandVariables(const std::vector<VarT> &compact,
std::vector<sh::ShaderVariable> *expanded);
std::vector<ShaderVariable> *expanded);
}
#endif // COMPILER_VARIABLE_INFO_H_

Просмотреть файл

@ -320,44 +320,4 @@ template void GetVariableTraverser::traverse(const TType &, const TString &, std
template void GetVariableTraverser::traverse(const TType &, const TString &, std::vector<Varying> *);
template void GetVariableTraverser::traverse(const TType &, const TString &, std::vector<InterfaceBlockField> *);
BlockLayoutType GetBlockLayoutType(TLayoutBlockStorage blockStorage)
{
switch (blockStorage)
{
case EbsPacked: return BLOCKLAYOUT_PACKED;
case EbsShared: return BLOCKLAYOUT_SHARED;
case EbsStd140: return BLOCKLAYOUT_STANDARD;
default: UNREACHABLE(); return BLOCKLAYOUT_SHARED;
}
}
static TString InterfaceBlockFieldName(const TInterfaceBlock &interfaceBlock, const TField &field)
{
if (interfaceBlock.hasInstanceName())
{
return interfaceBlock.name() + "." + field.name();
}
else
{
return field.name();
}
}
void GetInterfaceBlockFields(const TInterfaceBlock &interfaceBlock, std::vector<InterfaceBlockField> *fieldsOut)
{
const TFieldList &fieldList = interfaceBlock.fields();
for (size_t fieldIndex = 0; fieldIndex < fieldList.size(); ++fieldIndex)
{
const TField &field = *fieldList[fieldIndex];
const TString &fullFieldName = InterfaceBlockFieldName(interfaceBlock, field);
const TType &fieldType = *field.type();
GetVariableTraverser traverser;
traverser.traverse(fieldType, fullFieldName, fieldsOut);
fieldsOut->back().isRowMajorLayout = (fieldType.getLayoutQualifier().matrixPacking == EmpRowMajor);
}
}
}

Просмотреть файл

@ -33,7 +33,6 @@ bool IsVaryingIn(TQualifier qualifier);
bool IsVaryingOut(TQualifier qualifier);
bool IsVarying(TQualifier qualifier);
InterpolationType GetInterpolationType(TQualifier qualifier);
BlockLayoutType GetBlockLayoutType(TLayoutBlockStorage blockStorage);
TString ArrayString(const TType &type);
class GetVariableTraverser
@ -52,8 +51,6 @@ class GetVariableTraverser
DISALLOW_COPY_AND_ASSIGN(GetVariableTraverser);
};
void GetInterfaceBlockFields(const TInterfaceBlock &interfaceBlock, std::vector<InterfaceBlockField> *fieldsOut);
}
#endif // COMPILER_UTIL_H

Просмотреть файл

@ -34,11 +34,13 @@
'common/mathutil.cpp',
'common/mathutil.h',
'common/platform.h',
'common/NativeWindow.h',
'common/tls.cpp',
'common/tls.h',
'common/utilities.cpp',
'common/utilities.h',
'common/version.h',
'common/win32/NativeWindow.cpp',
'libEGL/Config.cpp',
'libEGL/Config.h',
'libEGL/Display.cpp',

Просмотреть файл

@ -193,7 +193,7 @@ bool Display::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value)
EGLSurface Display::createWindowSurface(HWND window, EGLConfig config, const EGLint *attribList)
EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig config, const EGLint *attribList)
{
const Config *configuration = mConfigSet.get(config);
EGLint postSubBufferSupported = EGL_FALSE;
@ -494,7 +494,7 @@ bool Display::isValidSurface(egl::Surface *surface)
return mSurfaceSet.find(surface) != mSurfaceSet.end();
}
bool Display::hasExistingWindowSurface(HWND window)
bool Display::hasExistingWindowSurface(EGLNativeWindowType window)
{
for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
{
@ -552,8 +552,10 @@ void Display::initDisplayExtensionString()
extensions.push_back("EGL_NV_post_sub_buffer");
}
#if defined (ANGLE_TEST_CONFIG)
// TODO: complete support for the EGL_KHR_create_context extension
extensions.push_back("EGL_KHR_create_context");
#endif
std::ostringstream stream;
std::copy(extensions.begin(), extensions.end(), std::ostream_iterator<std::string>(stream, " "));

Просмотреть файл

@ -43,7 +43,7 @@ class Display
bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig);
bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value);
EGLSurface createWindowSurface(HWND window, EGLConfig config, const EGLint *attribList);
EGLSurface createWindowSurface(EGLNativeWindowType window, EGLConfig config, const EGLint *attribList);
EGLSurface createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList);
EGLContext createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets, bool robustAccess);
@ -54,7 +54,7 @@ class Display
bool isValidConfig(EGLConfig config);
bool isValidContext(gl::Context *context);
bool isValidSurface(egl::Surface *surface);
bool hasExistingWindowSurface(HWND window);
bool hasExistingWindowSurface(EGLNativeWindowType window);
rx::Renderer *getRenderer() { return mRenderer; };

Просмотреть файл

@ -22,11 +22,13 @@
#include "libEGL/main.h"
#include "libEGL/Display.h"
#include "common/NativeWindow.h"
namespace egl
{
Surface::Surface(Display *display, const Config *config, HWND window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported)
: mDisplay(display), mConfig(config), mWindow(window), mPostSubBufferSupported(postSubBufferSupported)
Surface::Surface(Display *display, const Config *config, EGLNativeWindowType window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported)
: mDisplay(display), mConfig(config), mNativeWindow(window), mPostSubBufferSupported(postSubBufferSupported)
{
mRenderer = mDisplay->getRenderer();
mSwapChain = NULL;
@ -48,7 +50,7 @@ Surface::Surface(Display *display, const Config *config, HWND window, EGLint fix
}
Surface::Surface(Display *display, const Config *config, HANDLE shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureType)
: mDisplay(display), mWindow(NULL), mConfig(config), mShareHandle(shareHandle), mWidth(width), mHeight(height), mPostSubBufferSupported(EGL_FALSE)
: mDisplay(display), mNativeWindow(NULL), mConfig(config), mShareHandle(shareHandle), mWidth(width), mHeight(height), mPostSubBufferSupported(EGL_FALSE)
{
mRenderer = mDisplay->getRenderer();
mSwapChain = NULL;
@ -74,6 +76,14 @@ Surface::~Surface()
bool Surface::initialize()
{
if (mNativeWindow.getNativeWindow())
{
if (!mNativeWindow.initialize())
{
return false;
}
}
if (!resetSwapChain())
return false;
@ -102,7 +112,7 @@ bool Surface::resetSwapChain()
if (!mFixedSize)
{
RECT windowRect;
if (!GetClientRect(getWindowHandle(), &windowRect))
if (!mNativeWindow.getClientRect(&windowRect))
{
ASSERT(false);
@ -120,7 +130,7 @@ bool Surface::resetSwapChain()
height = mHeight;
}
mSwapChain = mRenderer->createSwapChain(mWindow, mShareHandle,
mSwapChain = mRenderer->createSwapChain(mNativeWindow, mShareHandle,
mConfig->mRenderTargetFormat,
mConfig->mDepthStencilFormat);
if (!mSwapChain)
@ -224,9 +234,9 @@ bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
return true;
}
HWND Surface::getWindowHandle()
EGLNativeWindowType Surface::getWindowHandle()
{
return mWindow;
return mNativeWindow.getNativeWindow();
}
@ -249,28 +259,29 @@ static LRESULT CALLBACK SurfaceWindowProc(HWND hwnd, UINT message, WPARAM wparam
void Surface::subclassWindow()
{
if (!mWindow)
HWND window = mNativeWindow.getNativeWindow();
if (!window)
{
return;
}
DWORD processId;
DWORD threadId = GetWindowThreadProcessId(mWindow, &processId);
DWORD threadId = GetWindowThreadProcessId(window, &processId);
if (processId != GetCurrentProcessId() || threadId != GetCurrentThreadId())
{
return;
}
SetLastError(0);
LONG_PTR oldWndProc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(SurfaceWindowProc));
LONG_PTR oldWndProc = SetWindowLongPtr(window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(SurfaceWindowProc));
if(oldWndProc == 0 && GetLastError() != ERROR_SUCCESS)
{
mWindowSubclassed = false;
return;
}
SetProp(mWindow, kSurfaceProperty, reinterpret_cast<HANDLE>(this));
SetProp(mWindow, kParentWndProc, reinterpret_cast<HANDLE>(oldWndProc));
SetProp(window, kSurfaceProperty, reinterpret_cast<HANDLE>(this));
SetProp(window, kParentWndProc, reinterpret_cast<HANDLE>(oldWndProc));
mWindowSubclassed = true;
}
@ -281,8 +292,14 @@ void Surface::unsubclassWindow()
return;
}
HWND window = mNativeWindow.getNativeWindow();
if (!window)
{
return;
}
// un-subclass
LONG_PTR parentWndFunc = reinterpret_cast<LONG_PTR>(GetProp(mWindow, kParentWndProc));
LONG_PTR parentWndFunc = reinterpret_cast<LONG_PTR>(GetProp(window, kParentWndProc));
// Check the windowproc is still SurfaceWindowProc.
// If this assert fails, then it is likely the application has subclassed the
@ -291,13 +308,13 @@ void Surface::unsubclassWindow()
// EGL context, or to unsubclass before destroying the EGL context.
if(parentWndFunc)
{
LONG_PTR prevWndFunc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, parentWndFunc);
LONG_PTR prevWndFunc = SetWindowLongPtr(window, GWLP_WNDPROC, parentWndFunc);
UNUSED_ASSERTION_VARIABLE(prevWndFunc);
ASSERT(prevWndFunc == reinterpret_cast<LONG_PTR>(SurfaceWindowProc));
}
RemoveProp(mWindow, kSurfaceProperty);
RemoveProp(mWindow, kParentWndProc);
RemoveProp(window, kSurfaceProperty);
RemoveProp(window, kParentWndProc);
mWindowSubclassed = false;
}
@ -307,11 +324,11 @@ bool Surface::checkForOutOfDateSwapChain()
int clientWidth = getWidth();
int clientHeight = getHeight();
bool sizeDirty = false;
if (!mFixedSize && !IsIconic(getWindowHandle()))
if (!mFixedSize && !mNativeWindow.isIconic())
{
// The window is automatically resized to 150x22 when it's minimized, but the swapchain shouldn't be resized
// because that's not a useful size to render to.
if (!GetClientRect(getWindowHandle(), &client))
if (!mNativeWindow.getClientRect(&client))
{
ASSERT(false);
return false;

Просмотреть файл

@ -14,6 +14,7 @@
#include <EGL/egl.h>
#include "common/angleutils.h"
#include "common/NativeWindow.h"
namespace gl
{
@ -33,7 +34,7 @@ class Config;
class Surface
{
public:
Surface(Display *display, const egl::Config *config, HWND window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported);
Surface(Display *display, const egl::Config *config, EGLNativeWindowType window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported);
Surface(Display *display, const egl::Config *config, HANDLE shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget);
virtual ~Surface();
@ -42,7 +43,7 @@ class Surface
void release();
bool resetSwapChain();
HWND getWindowHandle();
EGLNativeWindowType getWindowHandle();
bool swap();
bool postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height);
@ -83,7 +84,7 @@ private:
bool resetSwapChain(int backbufferWidth, int backbufferHeight);
bool swapRect(EGLint x, EGLint y, EGLint width, EGLint height);
const HWND mWindow; // Window that the surface is created for.
rx::NativeWindow mNativeWindow; // Handler for the Window that the surface is created for.
bool mWindowSubclassed; // Indicates whether we successfully subclassed mWindow for WM_RESIZE hooking
const egl::Config *mConfig; // EGL config surface was created with
EGLint mHeight; // Height of surface

Просмотреть файл

@ -19,6 +19,8 @@
#include "libEGL/Display.h"
#include "libEGL/Surface.h"
#include "common/NativeWindow.h"
bool validateDisplay(egl::Display *display)
{
if (display == EGL_NO_DISPLAY)
@ -324,14 +326,12 @@ EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EG
return EGL_NO_SURFACE;
}
HWND window = (HWND)win;
if (!IsWindow(window))
if (!isValidEGLNativeWindowType(win))
{
return egl::error(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
}
return display->createWindowSurface(window, config, attrib_list);
return display->createWindowSurface(win, config, attrib_list);
}
EGLSurface __stdcall eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)

Просмотреть файл

@ -9,6 +9,7 @@ UNIFIED_SOURCES += [
'../common/RefCountObject.cpp',
'../common/tls.cpp',
'../common/utilities.cpp',
'../common/win32/NativeWindow.cpp',
'Config.cpp',
'Display.cpp',
'libEGL.cpp',
@ -54,6 +55,7 @@ DISABLE_STL_WRAPPING = True
LOCAL_INCLUDES += [ '../../include', '../../src' ]
USE_LIBS += [ 'libGLESv2' ]
EXTRA_DSO_LDOPTS += [ '../libGLESv2/libGLESv2.lib' ]
SharedLibrary('libEGL')

Просмотреть файл

@ -8,7 +8,7 @@
'angle_enable_d3d9%': 1,
'angle_enable_d3d11%': 1,
# These file lists are shared with the GN build.
'angle_libglesv2_sources':
'angle_libangle_sources':
[
'../include/EGL/egl.h',
'../include/EGL/eglext.h',
@ -36,11 +36,13 @@
'common/mathutil.cpp',
'common/mathutil.h',
'common/platform.h',
'common/NativeWindow.h',
'common/tls.cpp',
'common/tls.h',
'common/utilities.cpp',
'common/utilities.h',
'common/version.h',
'common/win32/NativeWindow.cpp',
'libGLESv2/BinaryStream.h',
'libGLESv2/Buffer.cpp',
'libGLESv2/Buffer.h',
@ -60,6 +62,8 @@
'libGLESv2/FramebufferAttachment.h',
'libGLESv2/HandleAllocator.cpp',
'libGLESv2/HandleAllocator.h',
'libGLESv2/ImageIndex.h',
'libGLESv2/ImageIndex.cpp',
'libGLESv2/Program.cpp',
'libGLESv2/Program.h',
'libGLESv2/ProgramBinary.cpp',
@ -90,9 +94,6 @@
'libGLESv2/angletypes.h',
'libGLESv2/formatutils.cpp',
'libGLESv2/formatutils.h',
'libGLESv2/libGLESv2.cpp',
'libGLESv2/libGLESv2.def',
'libGLESv2/libGLESv2.rc',
'libGLESv2/main.cpp',
'libGLESv2/main.h',
'libGLESv2/queryconversions.cpp',
@ -103,6 +104,7 @@
'libGLESv2/renderer/Image.h',
'libGLESv2/renderer/IndexRangeCache.cpp',
'libGLESv2/renderer/IndexRangeCache.h',
'libGLESv2/renderer/ProgramImpl.h',
'libGLESv2/renderer/QueryImpl.h',
'libGLESv2/renderer/RenderTarget.h',
'libGLESv2/renderer/Renderer.cpp',
@ -113,6 +115,7 @@
'libGLESv2/renderer/TextureImpl.h',
'libGLESv2/renderer/TransformFeedbackImpl.h',
'libGLESv2/renderer/VertexArrayImpl.h',
'libGLESv2/renderer/Workarounds.h',
'libGLESv2/renderer/copyimage.cpp',
'libGLESv2/renderer/copyimage.h',
'libGLESv2/renderer/copyimage.inl',
@ -154,6 +157,8 @@
'libGLESv2/renderer/d3d/IndexDataManager.h',
'libGLESv2/renderer/d3d/MemoryBuffer.cpp',
'libGLESv2/renderer/d3d/MemoryBuffer.h',
'libGLESv2/renderer/d3d/ProgramD3D.cpp',
'libGLESv2/renderer/d3d/ProgramD3D.h',
'libGLESv2/renderer/d3d/ShaderD3D.cpp',
'libGLESv2/renderer/d3d/ShaderD3D.h',
'libGLESv2/renderer/d3d/TextureD3D.cpp',
@ -308,8 +313,9 @@
'targets':
[
{
'target_name': 'libGLESv2',
'type': 'shared_library',
'target_name': 'libANGLE',
#TODO(jamdill/geofflang): support shared
'type': 'static_library',
'dependencies': [ 'translator', 'commit_id', 'copy_compiler_dll' ],
'includes': [ '../build/common_defines.gypi', ],
'include_dirs':
@ -320,7 +326,7 @@
],
'sources':
[
'<@(angle_libglesv2_sources)',
'<@(angle_libangle_sources)',
],
'defines':
[
@ -329,6 +335,22 @@
'EGLAPI=',
'ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ "d3dcompiler_46.dll", "d3dcompiler_43.dll" }',
],
'direct_dependent_settings':
{
'include_dirs':
[
'.',
'../include',
'libGLESv2',
],
'defines':
[
'GL_APICALL=',
'GL_GLEXT_PROTOTYPES=',
'EGLAPI=',
'ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ "d3dcompiler_46.dll", "d3dcompiler_43.dll" }',
],
},
'conditions':
[
['angle_enable_d3d9==1 or angle_enable_d3d11==1',
@ -348,15 +370,18 @@
[
'ANGLE_ENABLE_D3D9',
],
'msvs_settings':
'link_settings':
{
'VCLinkerTool':
'msvs_settings':
{
'AdditionalDependencies':
[
'd3d9.lib',
]
}
'VCLinkerTool':
{
'AdditionalDependencies':
[
'd3d9.lib',
]
}
},
},
}],
['angle_enable_d3d11==1',
@ -369,14 +394,17 @@
[
'ANGLE_ENABLE_D3D11',
],
'msvs_settings':
'link_settings':
{
'VCLinkerTool':
'msvs_settings':
{
'AdditionalDependencies':
[
'dxguid.lib',
],
'VCLinkerTool':
{
'AdditionalDependencies':
[
'dxguid.lib',
]
}
},
},
}],
@ -404,30 +432,28 @@
},
},
{
# This target supports angle_implementation_unittests.
# It only executes cross-platform code and therefore
# doesn't need any Direct3D DLLs.
'target_name': 'libGLESv2_static',
'type': 'static_library',
'dependencies': [ 'translator', 'commit_id' ],
'target_name': 'libGLESv2',
'type': 'shared_library',
'dependencies': [ 'libANGLE' ],
'includes': [ '../build/common_defines.gypi', ],
'include_dirs':
[
'.',
'../include',
'libGLESv2',
],
'sources':
[
'<@(angle_libglesv2_sources)',
'libGLESv2/libGLESv2.cpp',
'libGLESv2/libGLESv2.def',
'libGLESv2/libGLESv2.rc',
],
'defines':
},
{
'target_name': 'libGLESv2_static',
'type': 'static_library',
# make sure we depend on commit_id as a hard dependency, otherwise
# we will try to build the static_lib in parallel
'dependencies': [ 'libANGLE', 'commit_id' ],
'includes': [ '../build/common_defines.gypi', ],
'sources':
[
'GL_APICALL=',
'GL_GLEXT_PROTOTYPES=',
'EGLAPI=',
# Workaround for D3D-specific code in Renderer.h
'ANGLE_COMPILE_OPTIMIZATION_LEVEL=0',
'libGLESv2/libGLESv2.cpp',
'libGLESv2/libGLESv2.rc',
],
},
],

Просмотреть файл

@ -15,6 +15,7 @@
#include <cstddef>
#include <string>
#include <vector>
#include <stdint.h>
namespace gl
{
@ -26,7 +27,7 @@ class BinaryInputStream
{
mError = false;
mOffset = 0;
mData = static_cast<const char*>(data);
mData = static_cast<const uint8_t*>(data);
mLength = length;
}
@ -85,7 +86,7 @@ class BinaryInputStream
return;
}
v->assign(mData + mOffset, length);
v->assign(reinterpret_cast<const char *>(mData) + mOffset, length);
mOffset += length;
}
@ -115,11 +116,16 @@ class BinaryInputStream
return mOffset == mLength;
}
const uint8_t *data()
{
return mData;
}
private:
DISALLOW_COPY_AND_ASSIGN(BinaryInputStream);
bool mError;
size_t mOffset;
const char *mData;
const uint8_t *mData;
size_t mLength;
template <typename T>

Просмотреть файл

@ -33,35 +33,60 @@ Buffer::~Buffer()
SafeDelete(mBuffer);
}
void Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage)
Error Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage)
{
gl::Error error = mBuffer->setData(data, size, usage);
if (error.isError())
{
return error;
}
mIndexRangeCache.clear();
mUsage = usage;
mSize = size;
mBuffer->setData(data, size, usage);
return error;
}
void Buffer::bufferSubData(const void *data, GLsizeiptr size, GLintptr offset)
Error Buffer::bufferSubData(const void *data, GLsizeiptr size, GLintptr offset)
{
gl::Error error = mBuffer->setSubData(data, size, offset);
if (error.isError())
{
return error;
}
mIndexRangeCache.invalidateRange(offset, size);
mBuffer->setSubData(data, size, offset);
return error;
}
void Buffer::copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size)
Error Buffer::copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size)
{
gl::Error error = mBuffer->copySubData(source->getImplementation(), sourceOffset, destOffset, size);
if (error.isError())
{
return error;
}
mIndexRangeCache.invalidateRange(destOffset, size);
mBuffer->copySubData(source->getImplementation(), sourceOffset, destOffset, size);
return error;
}
GLvoid *Buffer::mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access)
Error Buffer::mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access)
{
ASSERT(!mMapped);
ASSERT(offset + length <= mSize);
void *dataPointer = mBuffer->map(offset, length, access);
Error error = mBuffer->map(offset, length, access, &mMapPointer);
if (error.isError())
{
mMapPointer = NULL;
return error;
}
mMapped = GL_TRUE;
mMapPointer = static_cast<GLvoid*>(static_cast<GLubyte*>(dataPointer));
mMapOffset = static_cast<GLint64>(offset);
mMapLength = static_cast<GLint64>(length);
mAccessFlags = static_cast<GLint>(access);
@ -71,20 +96,26 @@ GLvoid *Buffer::mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access)
mIndexRangeCache.invalidateRange(offset, length);
}
return mMapPointer;
return error;
}
void Buffer::unmap()
Error Buffer::unmap()
{
ASSERT(mMapped);
mBuffer->unmap();
Error error = mBuffer->unmap();
if (error.isError())
{
return error;
}
mMapped = GL_FALSE;
mMapPointer = NULL;
mMapOffset = 0;
mMapLength = 0;
mAccessFlags = 0;
return error;
}
void Buffer::markTransformFeedbackUsage()

Просмотреть файл

@ -11,6 +11,8 @@
#ifndef LIBGLESV2_BUFFER_H_
#define LIBGLESV2_BUFFER_H_
#include "libGLESv2/Error.h"
#include "common/angleutils.h"
#include "common/RefCountObject.h"
#include "libGLESv2/renderer/IndexRangeCache.h"
@ -31,13 +33,13 @@ class Buffer : public RefCountObject
virtual ~Buffer();
void bufferData(const void *data, GLsizeiptr size, GLenum usage);
void bufferSubData(const void *data, GLsizeiptr size, GLintptr offset);
void copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size);
GLvoid *mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access);
void unmap();
Error bufferData(const void *data, GLsizeiptr size, GLenum usage);
Error bufferSubData(const void *data, GLsizeiptr size, GLintptr offset);
Error copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size);
Error mapRange(GLintptr offset, GLsizeiptr length, GLbitfield access);
Error unmap();
GLenum getUsage() const { return mUsage; }
GLenum getUsage() const { return mUsage; }
GLint getAccessFlags() const { return mAccessFlags; }
GLboolean isMapped() const { return mMapped; }
GLvoid *getMapPointer() const { return mMapPointer; }

Просмотреть файл

@ -182,12 +182,17 @@ std::vector<std::string> Extensions::getStrings() const
}
static bool GetFormatSupport(const TextureCapsMap &textureCaps, const std::vector<GLenum> &requiredFormats,
bool requiresFiltering, bool requiresRendering)
bool requiresTexturing, bool requiresFiltering, bool requiresRendering)
{
for (size_t i = 0; i < requiredFormats.size(); i++)
{
const TextureCaps &cap = textureCaps.get(requiredFormats[i]);
if (requiresTexturing && !cap.texturable)
{
return false;
}
if (requiresFiltering && !cap.filterable)
{
return false;
@ -209,7 +214,7 @@ static bool DetermineRGB8AndRGBA8TextureSupport(const TextureCapsMap &textureCap
requiredFormats.push_back(GL_RGB8);
requiredFormats.push_back(GL_RGBA8);
return GetFormatSupport(textureCaps, requiredFormats, true, true);
return GetFormatSupport(textureCaps, requiredFormats, true, true, true);
}
// Checks for GL_EXT_texture_format_BGRA8888 support
@ -218,7 +223,7 @@ static bool DetermineBGRA8TextureSupport(const TextureCapsMap &textureCaps)
std::vector<GLenum> requiredFormats;
requiredFormats.push_back(GL_BGRA8_EXT);
return GetFormatSupport(textureCaps, requiredFormats, true, true);
return GetFormatSupport(textureCaps, requiredFormats, true, true, true);
}
// Checks for GL_OES_texture_half_float support
@ -228,7 +233,7 @@ static bool DetermineHalfFloatTextureSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_RGB16F);
requiredFormats.push_back(GL_RGBA16F);
return GetFormatSupport(textureCaps, requiredFormats, false, true);
return GetFormatSupport(textureCaps, requiredFormats, true, false, true);
}
// Checks for GL_OES_texture_half_float_linear support
@ -238,7 +243,7 @@ static bool DetermineHalfFloatTextureFilteringSupport(const TextureCapsMap &text
requiredFormats.push_back(GL_RGB16F);
requiredFormats.push_back(GL_RGBA16F);
return GetFormatSupport(textureCaps, requiredFormats, true, false);
return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
}
// Checks for GL_OES_texture_float support
@ -248,7 +253,7 @@ static bool DetermineFloatTextureSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_RGB32F);
requiredFormats.push_back(GL_RGBA32F);
return GetFormatSupport(textureCaps, requiredFormats, false, true);
return GetFormatSupport(textureCaps, requiredFormats, true, false, true);
}
// Checks for GL_OES_texture_float_linear support
@ -258,7 +263,7 @@ static bool DetermineFloatTextureFilteringSupport(const TextureCapsMap &textureC
requiredFormats.push_back(GL_RGB32F);
requiredFormats.push_back(GL_RGBA32F);
return GetFormatSupport(textureCaps, requiredFormats, true, false);
return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
}
// Checks for GL_EXT_texture_rg support
@ -278,7 +283,7 @@ static bool DetermineRGTextureSupport(const TextureCapsMap &textureCaps, bool ch
requiredFormats.push_back(GL_RG32F);
}
return GetFormatSupport(textureCaps, requiredFormats, true, false);
return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
}
// Check for GL_EXT_texture_compression_dxt1
@ -288,7 +293,7 @@ static bool DetermineDXT1TextureSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
return GetFormatSupport(textureCaps, requiredFormats, true, false);
return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
}
// Check for GL_ANGLE_texture_compression_dxt3
@ -297,7 +302,7 @@ static bool DetermineDXT3TextureSupport(const TextureCapsMap &textureCaps)
std::vector<GLenum> requiredFormats;
requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE);
return GetFormatSupport(textureCaps, requiredFormats, true, false);
return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
}
// Check for GL_ANGLE_texture_compression_dxt5
@ -306,7 +311,7 @@ static bool DetermineDXT5TextureSupport(const TextureCapsMap &textureCaps)
std::vector<GLenum> requiredFormats;
requiredFormats.push_back(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE);
return GetFormatSupport(textureCaps, requiredFormats, true, false);
return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
}
// Check for GL_ANGLE_texture_compression_dxt5
@ -319,8 +324,8 @@ static bool DetermineSRGBTextureSupport(const TextureCapsMap &textureCaps)
std::vector<GLenum> requiredRenderFormats;
requiredRenderFormats.push_back(GL_SRGB8_ALPHA8);
return GetFormatSupport(textureCaps, requiredFilterFormats, true, false) &&
GetFormatSupport(textureCaps, requiredRenderFormats, false, true);
return GetFormatSupport(textureCaps, requiredFilterFormats, true, true, false) &&
GetFormatSupport(textureCaps, requiredRenderFormats, true, false, true);
}
// Check for GL_ANGLE_depth_texture
@ -331,7 +336,7 @@ static bool DetermineDepthTextureSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_DEPTH_COMPONENT32_OES);
requiredFormats.push_back(GL_DEPTH24_STENCIL8_OES);
return GetFormatSupport(textureCaps, requiredFormats, true, true);
return GetFormatSupport(textureCaps, requiredFormats, true, true, true);
}
// Check for GL_EXT_color_buffer_float
@ -346,7 +351,7 @@ static bool DetermineColorBufferFloatSupport(const TextureCapsMap &textureCaps)
requiredFormats.push_back(GL_RGBA32F);
requiredFormats.push_back(GL_R11F_G11F_B10F);
return GetFormatSupport(textureCaps, requiredFormats, false, true);
return GetFormatSupport(textureCaps, requiredFormats, true, false, true);
}
void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps)

Просмотреть файл

@ -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

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -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);
@ -137,8 +134,8 @@ class Context
void setProgramBinary(GLuint program, GLenum binaryFormat, const void *binary, GLint length);
void bindTransformFeedback(GLuint transformFeedback);
void beginQuery(GLenum target, GLuint query);
void endQuery(GLenum target);
Error beginQuery(GLenum target, GLuint query);
Error endQuery(GLenum target);
void setFramebufferZero(Framebuffer *framebuffer);
@ -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;
@ -185,17 +182,17 @@ class Context
bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams);
bool getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams);
void clear(GLbitfield mask);
void clearBufferfv(GLenum buffer, int drawbuffer, const float *values);
void clearBufferuiv(GLenum buffer, int drawbuffer, const unsigned int *values);
void clearBufferiv(GLenum buffer, int drawbuffer, const int *values);
void clearBufferfi(GLenum buffer, int drawbuffer, float depth, int stencil);
Error clear(GLbitfield mask);
Error clearBufferfv(GLenum buffer, int drawbuffer, const float *values);
Error clearBufferuiv(GLenum buffer, int drawbuffer, const unsigned int *values);
Error clearBufferiv(GLenum buffer, int drawbuffer, const int *values);
Error clearBufferfi(GLenum buffer, int drawbuffer, float depth, int stencil);
void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei *bufSize, void* pixels);
void drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances);
void drawElements(GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei instances,
const rx::RangeUI &indexRange);
Error readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei *bufSize, void* pixels);
Error drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances);
Error drawElements(GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei instances,
const rx::RangeUI &indexRange);
void sync(bool block); // flush/finish
void recordError(const Error &error);
@ -218,8 +215,8 @@ class Context
void getCurrentReadFormatType(GLenum *internalFormat, GLenum *format, GLenum *type);
void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter);
Error blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter);
rx::Renderer *getRenderer() { return mRenderer; }
@ -234,13 +231,13 @@ class Context
// TODO: std::array may become unavailable using older versions of GCC
typedef std::array<unsigned int, IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS> FramebufferTextureSerialArray;
bool 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,
size_t framebufferSerialCount);
bool applyUniformBuffers();
Error applyRenderTarget(GLenum drawMode, bool ignoreViewport);
Error applyState(GLenum drawMode);
Error applyShaders(ProgramBinary *programBinary, bool transformFeedbackActive);
Error applyTextures(ProgramBinary *programBinary, SamplerType shaderType, const FramebufferTextureSerialArray &framebufferSerials,
size_t framebufferSerialCount);
Error applyTextures(ProgramBinary *programBinary);
Error applyUniformBuffers();
bool applyTransformFeedbackBuffers();
void markTransformFeedbackUsage();
@ -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);
Error generateSwizzles(ProgramBinary *programBinary, SamplerType type);
Error 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;

Просмотреть файл

@ -16,9 +16,54 @@
#include "libGLESv2/FramebufferAttachment.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/RenderTarget.h"
#include "libGLESv2/renderer/Workarounds.h"
#include "libGLESv2/renderer/d3d/TextureD3D.h"
#include "common/utilities.h"
namespace rx
{
RenderTarget *GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment)
{
if (attachment->isTexture())
{
gl::Texture *texture = attachment->getTexture();
ASSERT(texture);
TextureD3D *textureD3D = TextureD3D::makeTextureD3D(texture->getImplementation());
const gl::ImageIndex *index = attachment->getTextureImageIndex();
ASSERT(index);
return textureD3D->getRenderTarget(*index);
}
gl::Renderbuffer *renderbuffer = attachment->getRenderbuffer();
ASSERT(renderbuffer);
// TODO: cast to RenderbufferD3D
return renderbuffer->getStorage()->getRenderTarget();
}
// Note: RenderTarget serials should ideally be in the RenderTargets themselves.
unsigned int GetAttachmentSerial(gl::FramebufferAttachment *attachment)
{
if (attachment->isTexture())
{
gl::Texture *texture = attachment->getTexture();
ASSERT(texture);
TextureD3D *textureD3D = TextureD3D::makeTextureD3D(texture->getImplementation());
const gl::ImageIndex *index = attachment->getTextureImageIndex();
ASSERT(index);
return textureD3D->getRenderTargetSerial(*index);
}
gl::Renderbuffer *renderbuffer = attachment->getRenderbuffer();
ASSERT(renderbuffer);
// TODO: cast to RenderbufferD3D
return renderbuffer->getStorage()->getSerial();
}
}
namespace gl
{
@ -47,7 +92,7 @@ Framebuffer::~Framebuffer()
SafeDelete(mStencilbuffer);
}
FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle, GLint level, GLint layer) const
FramebufferAttachment *Framebuffer::createAttachment(GLenum binding, GLenum type, GLuint handle, GLint level, GLint layer) const
{
if (handle == 0)
{
@ -62,15 +107,14 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle,
return NULL;
case GL_RENDERBUFFER:
return new RenderbufferAttachment(context->getRenderbuffer(handle));
return new RenderbufferAttachment(binding, context->getRenderbuffer(handle));
case GL_TEXTURE_2D:
{
Texture *texture = context->getTexture(handle);
if (texture && texture->getTarget() == GL_TEXTURE_2D)
{
Texture2D *tex2D = static_cast<Texture2D*>(texture);
return new Texture2DAttachment(tex2D, level);
return new TextureAttachment(binding, texture, ImageIndex::Make2D(level));
}
else
{
@ -88,8 +132,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle,
Texture *texture = context->getTexture(handle);
if (texture && texture->getTarget() == GL_TEXTURE_CUBE_MAP)
{
TextureCubeMap *texCube = static_cast<TextureCubeMap*>(texture);
return new TextureCubeMapAttachment(texCube, type, level);
return new TextureAttachment(binding, texture, ImageIndex::MakeCube(type, level));
}
else
{
@ -102,8 +145,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle,
Texture *texture = context->getTexture(handle);
if (texture && texture->getTarget() == GL_TEXTURE_3D)
{
Texture3D *tex3D = static_cast<Texture3D*>(texture);
return new Texture3DAttachment(tex3D, level, layer);
return new TextureAttachment(binding, texture, ImageIndex::Make3D(level, layer));
}
else
{
@ -116,8 +158,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum type, GLuint handle,
Texture *texture = context->getTexture(handle);
if (texture && texture->getTarget() == GL_TEXTURE_2D_ARRAY)
{
Texture2DArray *tex2DArray = static_cast<Texture2DArray*>(texture);
return new Texture2DArrayAttachment(tex2DArray, level, layer);
return new TextureAttachment(binding, texture, ImageIndex::Make2DArray(level, layer));
}
else
{
@ -135,24 +176,25 @@ void Framebuffer::setColorbuffer(unsigned int colorAttachment, GLenum type, GLui
{
ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS);
SafeDelete(mColorbuffers[colorAttachment]);
mColorbuffers[colorAttachment] = createAttachment(type, colorbuffer, level, layer);
GLenum binding = colorAttachment + GL_COLOR_ATTACHMENT0;
mColorbuffers[colorAttachment] = createAttachment(binding, type, colorbuffer, level, layer);
}
void Framebuffer::setDepthbuffer(GLenum type, GLuint depthbuffer, GLint level, GLint layer)
{
SafeDelete(mDepthbuffer);
mDepthbuffer = createAttachment(type, depthbuffer, level, layer);
mDepthbuffer = createAttachment(GL_DEPTH_ATTACHMENT, type, depthbuffer, level, layer);
}
void Framebuffer::setStencilbuffer(GLenum type, GLuint stencilbuffer, GLint level, GLint layer)
{
SafeDelete(mStencilbuffer);
mStencilbuffer = createAttachment(type, stencilbuffer, level, layer);
mStencilbuffer = createAttachment(GL_STENCIL_ATTACHMENT, type, stencilbuffer, level, layer);
}
void Framebuffer::setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer, GLint level, GLint layer)
{
FramebufferAttachment *attachment = createAttachment(type, depthStencilBuffer, level, layer);
FramebufferAttachment *attachment = createAttachment(GL_DEPTH_STENCIL_ATTACHMENT, type, depthStencilBuffer, level, layer);
SafeDelete(mDepthbuffer);
SafeDelete(mStencilbuffer);
@ -164,7 +206,7 @@ void Framebuffer::setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer,
// Make a new attachment object to ensure we do not double-delete
// See angle issue 686
mStencilbuffer = createAttachment(type, depthStencilBuffer, level, layer);
mStencilbuffer = createAttachment(GL_DEPTH_STENCIL_ATTACHMENT, type, depthStencilBuffer, level, layer);
}
}
@ -571,55 +613,21 @@ void Framebuffer::invalidateSub(const Caps &caps, GLsizei numAttachments, const
GLint x, GLint y, GLsizei width, GLsizei height)
{
ASSERT(completeness() == GL_FRAMEBUFFER_COMPLETE);
for (int i = 0; i < numAttachments; ++i)
for (GLsizei attachIndex = 0; attachIndex < numAttachments; ++attachIndex)
{
rx::RenderTarget *renderTarget = NULL;
GLenum attachmentTarget = attachments[attachIndex];
if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15)
{
gl::FramebufferAttachment *attachment = getColorbuffer(attachments[i] - GL_COLOR_ATTACHMENT0);
if (attachment)
{
renderTarget = attachment->getRenderTarget();
}
}
else if (attachments[i] == GL_COLOR)
{
gl::FramebufferAttachment *attachment = getColorbuffer(0);
if (attachment)
{
renderTarget = attachment->getRenderTarget();
}
}
else
{
gl::FramebufferAttachment *attachment = NULL;
switch (attachments[i])
{
case GL_DEPTH_ATTACHMENT:
case GL_DEPTH:
attachment = mDepthbuffer;
break;
case GL_STENCIL_ATTACHMENT:
case GL_STENCIL:
attachment = mStencilbuffer;
break;
case GL_DEPTH_STENCIL_ATTACHMENT:
attachment = getDepthOrStencilbuffer();
break;
default:
UNREACHABLE();
}
gl::FramebufferAttachment *attachment =
(attachmentTarget == GL_DEPTH_STENCIL_ATTACHMENT) ? getDepthOrStencilbuffer() :
getAttachment(attachmentTarget);
if (attachment)
{
renderTarget = attachment->getRenderTarget();
}
}
if (renderTarget)
if (attachment)
{
renderTarget->invalidate(x, y, width, height);
rx::RenderTarget *renderTarget = rx::GetAttachmentRenderTarget(attachment);
if (renderTarget)
{
renderTarget->invalidate(x, y, width, height);
}
}
}
}
@ -628,14 +636,14 @@ DefaultFramebuffer::DefaultFramebuffer(rx::Renderer *renderer, Colorbuffer *colo
: Framebuffer(renderer, 0)
{
Renderbuffer *colorRenderbuffer = new Renderbuffer(0, colorbuffer);
mColorbuffers[0] = new RenderbufferAttachment(colorRenderbuffer);
mColorbuffers[0] = new RenderbufferAttachment(GL_BACK, colorRenderbuffer);
Renderbuffer *depthStencilBuffer = new Renderbuffer(0, depthStencil);
// Make a new attachment objects to ensure we do not double-delete
// See angle issue 686
mDepthbuffer = (depthStencilBuffer->getDepthSize() != 0 ? new RenderbufferAttachment(depthStencilBuffer) : NULL);
mStencilbuffer = (depthStencilBuffer->getStencilSize() != 0 ? new RenderbufferAttachment(depthStencilBuffer) : NULL);
mDepthbuffer = (depthStencilBuffer->getDepthSize() != 0 ? new RenderbufferAttachment(GL_DEPTH_ATTACHMENT, depthStencilBuffer) : NULL);
mStencilbuffer = (depthStencilBuffer->getStencilSize() != 0 ? new RenderbufferAttachment(GL_STENCIL_ATTACHMENT, depthStencilBuffer) : NULL);
mDrawBufferStates[0] = GL_BACK;
mReadBufferState = GL_BACK;
@ -668,6 +676,29 @@ bool Framebuffer::hasValidDepthStencil() const
mDepthbuffer->id() == mStencilbuffer->id());
}
ColorbufferInfo Framebuffer::getColorbuffersForRender() const
{
ColorbufferInfo colorbuffersForRender;
for (size_t colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; ++colorAttachment)
{
GLenum drawBufferState = mDrawBufferStates[colorAttachment];
FramebufferAttachment *colorbuffer = mColorbuffers[colorAttachment];
if (colorbuffer != NULL && drawBufferState != GL_NONE)
{
ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + colorAttachment));
colorbuffersForRender.push_back(colorbuffer);
}
else if (!mRenderer->getWorkarounds().mrtPerfWorkaround)
{
colorbuffersForRender.push_back(NULL);
}
}
return colorbuffersForRender;
}
GLenum DefaultFramebuffer::completeness() const
{
// The default framebuffer *must* always be complete, though it may not be
@ -679,6 +710,7 @@ FramebufferAttachment *DefaultFramebuffer::getAttachment(GLenum attachment) cons
{
switch (attachment)
{
case GL_COLOR:
case GL_BACK:
return getColorbuffer(0);
case GL_DEPTH:

Просмотреть файл

@ -10,6 +10,8 @@
#ifndef LIBGLESV2_FRAMEBUFFER_H_
#define LIBGLESV2_FRAMEBUFFER_H_
#include <vector>
#include "common/angleutils.h"
#include "common/RefCountObject.h"
#include "Constants.h"
@ -28,6 +30,8 @@ class Stencilbuffer;
class DepthStencilbuffer;
struct Caps;
typedef std::vector<FramebufferAttachment *> ColorbufferInfo;
class Framebuffer
{
public:
@ -72,6 +76,11 @@ class Framebuffer
void invalidateSub(const Caps &caps, GLsizei numAttachments, const GLenum *attachments,
GLint x, GLint y, GLsizei width, GLsizei height);
// Use this method to retrieve the color buffer map when doing rendering.
// It will apply a workaround for poor shader performance on some systems
// by compacting the list to skip NULL values.
ColorbufferInfo getColorbuffersForRender() const;
protected:
rx::Renderer *mRenderer;
@ -84,10 +93,10 @@ class Framebuffer
FramebufferAttachment *mDepthbuffer;
FramebufferAttachment *mStencilbuffer;
private:
private:
DISALLOW_COPY_AND_ASSIGN(Framebuffer);
FramebufferAttachment *createAttachment(GLenum type, GLuint handle, GLint level, GLint layer) const;
FramebufferAttachment *createAttachment(GLenum binding, GLenum type, GLuint handle, GLint level, GLint layer) const;
};
class DefaultFramebuffer : public Framebuffer
@ -104,4 +113,14 @@ class DefaultFramebuffer : public Framebuffer
}
namespace rx
{
class RenderTarget;
// TODO: place this in FramebufferD3D.h
RenderTarget *GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment);
unsigned int GetAttachmentSerial(gl::FramebufferAttachment *attachment);
}
#endif // LIBGLESV2_FRAMEBUFFER_H_

Просмотреть файл

@ -22,7 +22,8 @@ namespace gl
////// FramebufferAttachment Implementation //////
FramebufferAttachment::FramebufferAttachment()
FramebufferAttachment::FramebufferAttachment(GLenum binding)
: mBinding(binding)
{
}
@ -75,320 +76,85 @@ bool FramebufferAttachment::isTexture() const
return (type() != GL_RENDERBUFFER);
}
///// Texture2DAttachment Implementation ////////
///// TextureAttachment Implementation ////////
Texture2DAttachment::Texture2DAttachment(Texture2D *texture, GLint level) : mLevel(level)
TextureAttachment::TextureAttachment(GLenum binding, Texture *texture, const ImageIndex &index)
: FramebufferAttachment(binding),
mIndex(index)
{
mTexture2D.set(texture);
mTexture.set(texture);
}
Texture2DAttachment::~Texture2DAttachment()
TextureAttachment::~TextureAttachment()
{
mTexture2D.set(NULL);
mTexture.set(NULL);
}
rx::RenderTarget *Texture2DAttachment::getRenderTarget()
{
return mTexture2D->getRenderTarget(mLevel);
}
rx::TextureStorage *Texture2DAttachment::getTextureStorage()
{
return mTexture2D->getNativeTexture()->getStorageInstance();
}
GLsizei Texture2DAttachment::getWidth() const
{
return mTexture2D->getWidth(mLevel);
}
GLsizei Texture2DAttachment::getHeight() const
{
return mTexture2D->getHeight(mLevel);
}
GLenum Texture2DAttachment::getInternalFormat() const
{
return mTexture2D->getInternalFormat(mLevel);
}
GLenum Texture2DAttachment::getActualFormat() const
{
return mTexture2D->getActualFormat(mLevel);
}
GLsizei Texture2DAttachment::getSamples() const
GLsizei TextureAttachment::getSamples() const
{
return 0;
}
unsigned int Texture2DAttachment::getSerial() const
GLuint TextureAttachment::id() const
{
return mTexture2D->getRenderTargetSerial(mLevel);
return mTexture->id();
}
GLuint Texture2DAttachment::id() const
GLsizei TextureAttachment::getWidth() const
{
return mTexture2D->id();
return mTexture->getWidth(mIndex);
}
GLenum Texture2DAttachment::type() const
GLsizei TextureAttachment::getHeight() const
{
return GL_TEXTURE_2D;
return mTexture->getHeight(mIndex);
}
GLint Texture2DAttachment::mipLevel() const
GLenum TextureAttachment::getInternalFormat() const
{
return mLevel;
return mTexture->getInternalFormat(mIndex);
}
GLint Texture2DAttachment::layer() const
GLenum TextureAttachment::getActualFormat() const
{
return 0;
return mTexture->getActualFormat(mIndex);
}
unsigned int Texture2DAttachment::getTextureSerial() const
GLenum TextureAttachment::type() const
{
return mTexture2D->getTextureSerial();
return mIndex.type;
}
///// TextureCubeMapAttachment Implementation ////////
TextureCubeMapAttachment::TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level)
: mFaceTarget(faceTarget), mLevel(level)
GLint TextureAttachment::mipLevel() const
{
mTextureCubeMap.set(texture);
return mIndex.mipIndex;
}
TextureCubeMapAttachment::~TextureCubeMapAttachment()
GLint TextureAttachment::layer() const
{
mTextureCubeMap.set(NULL);
return mIndex.layerIndex;
}
rx::RenderTarget *TextureCubeMapAttachment::getRenderTarget()
Texture *TextureAttachment::getTexture()
{
return mTextureCubeMap->getRenderTarget(mFaceTarget, mLevel);
return mTexture.get();
}
rx::TextureStorage *TextureCubeMapAttachment::getTextureStorage()
const ImageIndex *TextureAttachment::getTextureImageIndex() const
{
return mTextureCubeMap->getNativeTexture()->getStorageInstance();
return &mIndex;
}
GLsizei TextureCubeMapAttachment::getWidth() const
Renderbuffer *TextureAttachment::getRenderbuffer()
{
return mTextureCubeMap->getWidth(mFaceTarget, mLevel);
}
GLsizei TextureCubeMapAttachment::getHeight() const
{
return mTextureCubeMap->getHeight(mFaceTarget, mLevel);
}
GLenum TextureCubeMapAttachment::getInternalFormat() const
{
return mTextureCubeMap->getInternalFormat(mFaceTarget, mLevel);
}
GLenum TextureCubeMapAttachment::getActualFormat() const
{
return mTextureCubeMap->getActualFormat(mFaceTarget, mLevel);
}
GLsizei TextureCubeMapAttachment::getSamples() const
{
return 0;
}
unsigned int TextureCubeMapAttachment::getSerial() const
{
return mTextureCubeMap->getRenderTargetSerial(mFaceTarget, mLevel);
}
GLuint TextureCubeMapAttachment::id() const
{
return mTextureCubeMap->id();
}
GLenum TextureCubeMapAttachment::type() const
{
return mFaceTarget;
}
GLint TextureCubeMapAttachment::mipLevel() const
{
return mLevel;
}
GLint TextureCubeMapAttachment::layer() const
{
return 0;
}
unsigned int TextureCubeMapAttachment::getTextureSerial() const
{
return mTextureCubeMap->getTextureSerial();
}
///// Texture3DAttachment Implementation ////////
Texture3DAttachment::Texture3DAttachment(Texture3D *texture, GLint level, GLint layer)
: mLevel(level), mLayer(layer)
{
mTexture3D.set(texture);
}
Texture3DAttachment::~Texture3DAttachment()
{
mTexture3D.set(NULL);
}
rx::RenderTarget *Texture3DAttachment::getRenderTarget()
{
return mTexture3D->getRenderTarget(mLevel, mLayer);
}
rx::TextureStorage *Texture3DAttachment::getTextureStorage()
{
return mTexture3D->getNativeTexture()->getStorageInstance();
}
GLsizei Texture3DAttachment::getWidth() const
{
return mTexture3D->getWidth(mLevel);
}
GLsizei Texture3DAttachment::getHeight() const
{
return mTexture3D->getHeight(mLevel);
}
GLenum Texture3DAttachment::getInternalFormat() const
{
return mTexture3D->getInternalFormat(mLevel);
}
GLenum Texture3DAttachment::getActualFormat() const
{
return mTexture3D->getActualFormat(mLevel);
}
GLsizei Texture3DAttachment::getSamples() const
{
return 0;
}
unsigned int Texture3DAttachment::getSerial() const
{
return mTexture3D->getRenderTargetSerial(mLevel, mLayer);
}
GLuint Texture3DAttachment::id() const
{
return mTexture3D->id();
}
GLenum Texture3DAttachment::type() const
{
return GL_TEXTURE_3D;
}
GLint Texture3DAttachment::mipLevel() const
{
return mLevel;
}
GLint Texture3DAttachment::layer() const
{
return mLayer;
}
unsigned int Texture3DAttachment::getTextureSerial() const
{
return mTexture3D->getTextureSerial();
}
////// Texture2DArrayAttachment Implementation //////
Texture2DArrayAttachment::Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer)
: mLevel(level), mLayer(layer)
{
mTexture2DArray.set(texture);
}
Texture2DArrayAttachment::~Texture2DArrayAttachment()
{
mTexture2DArray.set(NULL);
}
rx::RenderTarget *Texture2DArrayAttachment::getRenderTarget()
{
return mTexture2DArray->getRenderTarget(mLevel, mLayer);
}
rx::TextureStorage *Texture2DArrayAttachment::getTextureStorage()
{
return mTexture2DArray->getNativeTexture()->getStorageInstance();
}
GLsizei Texture2DArrayAttachment::getWidth() const
{
return mTexture2DArray->getWidth(mLevel);
}
GLsizei Texture2DArrayAttachment::getHeight() const
{
return mTexture2DArray->getHeight(mLevel);
}
GLenum Texture2DArrayAttachment::getInternalFormat() const
{
return mTexture2DArray->getInternalFormat(mLevel);
}
GLenum Texture2DArrayAttachment::getActualFormat() const
{
return mTexture2DArray->getActualFormat(mLevel);
}
GLsizei Texture2DArrayAttachment::getSamples() const
{
return 0;
}
unsigned int Texture2DArrayAttachment::getSerial() const
{
return mTexture2DArray->getRenderTargetSerial(mLevel, mLayer);
}
GLuint Texture2DArrayAttachment::id() const
{
return mTexture2DArray->id();
}
GLenum Texture2DArrayAttachment::type() const
{
return GL_TEXTURE_2D_ARRAY;
}
GLint Texture2DArrayAttachment::mipLevel() const
{
return mLevel;
}
GLint Texture2DArrayAttachment::layer() const
{
return mLayer;
}
unsigned int Texture2DArrayAttachment::getTextureSerial() const
{
return mTexture2DArray->getTextureSerial();
UNREACHABLE();
return NULL;
}
////// RenderbufferAttachment Implementation //////
RenderbufferAttachment::RenderbufferAttachment(Renderbuffer *renderbuffer)
RenderbufferAttachment::RenderbufferAttachment(GLenum binding, Renderbuffer *renderbuffer)
: FramebufferAttachment(binding)
{
ASSERT(renderbuffer);
mRenderbuffer.set(renderbuffer);
@ -399,17 +165,6 @@ RenderbufferAttachment::~RenderbufferAttachment()
mRenderbuffer.set(NULL);
}
rx::RenderTarget *RenderbufferAttachment::getRenderTarget()
{
return mRenderbuffer->getStorage()->getRenderTarget();
}
rx::TextureStorage *RenderbufferAttachment::getTextureStorage()
{
UNREACHABLE();
return NULL;
}
GLsizei RenderbufferAttachment::getWidth() const
{
return mRenderbuffer->getWidth();
@ -435,11 +190,6 @@ GLsizei RenderbufferAttachment::getSamples() const
return mRenderbuffer->getStorage()->getSamples();
}
unsigned int RenderbufferAttachment::getSerial() const
{
return mRenderbuffer->getStorage()->getSerial();
}
GLuint RenderbufferAttachment::id() const
{
return mRenderbuffer->id();
@ -460,10 +210,21 @@ GLint RenderbufferAttachment::layer() const
return 0;
}
unsigned int RenderbufferAttachment::getTextureSerial() const
Texture *RenderbufferAttachment::getTexture()
{
UNREACHABLE();
return 0;
return NULL;
}
const ImageIndex *RenderbufferAttachment::getTextureImageIndex() const
{
UNREACHABLE();
return NULL;
}
Renderbuffer *RenderbufferAttachment::getRenderbuffer()
{
return mRenderbuffer.get();
}
}

Просмотреть файл

@ -12,6 +12,7 @@
#include "common/angleutils.h"
#include "common/RefCountObject.h"
#include "Texture.h"
#include "angle_gl.h"
@ -24,10 +25,6 @@ class TextureStorage;
namespace gl
{
class Texture2D;
class TextureCubeMap;
class Texture3D;
class Texture2DArray;
class Renderbuffer;
// FramebufferAttachment implements a GL framebuffer attachment.
@ -39,7 +36,7 @@ class Renderbuffer;
class FramebufferAttachment
{
public:
FramebufferAttachment();
explicit FramebufferAttachment(GLenum binding);
virtual ~FramebufferAttachment();
// Helper methods
@ -56,178 +53,80 @@ class FramebufferAttachment
bool isTextureWithId(GLuint textureId) const { return isTexture() && id() == textureId; }
bool isRenderbufferWithId(GLuint renderbufferId) const { return !isTexture() && id() == renderbufferId; }
// Child class interface
virtual rx::RenderTarget *getRenderTarget() = 0;
virtual rx::TextureStorage *getTextureStorage() = 0;
GLenum getBinding() const { return mBinding; }
// Child class interface
virtual GLsizei getWidth() const = 0;
virtual GLsizei getHeight() const = 0;
virtual GLenum getInternalFormat() const = 0;
virtual GLenum getActualFormat() const = 0;
virtual GLsizei getSamples() const = 0;
virtual unsigned int getSerial() const = 0;
virtual GLuint id() const = 0;
virtual GLenum type() const = 0;
virtual GLint mipLevel() const = 0;
virtual GLint layer() const = 0;
virtual unsigned int getTextureSerial() const = 0;
virtual Texture *getTexture() = 0;
virtual const ImageIndex *getTextureImageIndex() const = 0;
virtual Renderbuffer *getRenderbuffer() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(FramebufferAttachment);
GLenum mBinding;
};
class Texture2DAttachment : public FramebufferAttachment
class TextureAttachment : public FramebufferAttachment
{
public:
Texture2DAttachment(Texture2D *texture, GLint level);
TextureAttachment(GLenum binding, Texture *texture, const ImageIndex &index);
virtual ~TextureAttachment();
virtual ~Texture2DAttachment();
rx::RenderTarget *getRenderTarget();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getSamples() const;
virtual GLuint id() const;
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const;
virtual GLuint id() const;
virtual GLenum type() const;
virtual GLint mipLevel() const;
virtual GLint layer() const;
virtual unsigned int getTextureSerial() const;
virtual Texture *getTexture();
virtual const ImageIndex *getTextureImageIndex() const;
virtual Renderbuffer *getRenderbuffer();
private:
DISALLOW_COPY_AND_ASSIGN(Texture2DAttachment);
DISALLOW_COPY_AND_ASSIGN(TextureAttachment);
BindingPointer<Texture2D> mTexture2D;
const GLint mLevel;
};
class TextureCubeMapAttachment : public FramebufferAttachment
{
public:
TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level);
virtual ~TextureCubeMapAttachment();
rx::RenderTarget *getRenderTarget();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const;
virtual GLuint id() const;
virtual GLenum type() const;
virtual GLint mipLevel() const;
virtual GLint layer() const;
virtual unsigned int getTextureSerial() const;
private:
DISALLOW_COPY_AND_ASSIGN(TextureCubeMapAttachment);
BindingPointer<TextureCubeMap> mTextureCubeMap;
const GLint mLevel;
const GLenum mFaceTarget;
};
class Texture3DAttachment : public FramebufferAttachment
{
public:
Texture3DAttachment(Texture3D *texture, GLint level, GLint layer);
virtual ~Texture3DAttachment();
rx::RenderTarget *getRenderTarget();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const;
virtual GLuint id() const;
virtual GLenum type() const;
virtual GLint mipLevel() const;
virtual GLint layer() const;
virtual unsigned int getTextureSerial() const;
private:
DISALLOW_COPY_AND_ASSIGN(Texture3DAttachment);
BindingPointer<Texture3D> mTexture3D;
const GLint mLevel;
const GLint mLayer;
};
class Texture2DArrayAttachment : public FramebufferAttachment
{
public:
Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer);
virtual ~Texture2DArrayAttachment();
rx::RenderTarget *getRenderTarget();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const;
virtual GLuint id() const;
virtual GLenum type() const;
virtual GLint mipLevel() const;
virtual GLint layer() const;
virtual unsigned int getTextureSerial() const;
private:
DISALLOW_COPY_AND_ASSIGN(Texture2DArrayAttachment);
BindingPointer<Texture2DArray> mTexture2DArray;
const GLint mLevel;
const GLint mLayer;
BindingPointer<Texture> mTexture;
ImageIndex mIndex;
};
class RenderbufferAttachment : public FramebufferAttachment
{
public:
RenderbufferAttachment(Renderbuffer *renderbuffer);
RenderbufferAttachment(GLenum binding, Renderbuffer *renderbuffer);
virtual ~RenderbufferAttachment();
rx::RenderTarget *getRenderTarget();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const;
virtual GLuint id() const;
virtual GLenum type() const;
virtual GLint mipLevel() const;
virtual GLint layer() const;
virtual unsigned int getTextureSerial() const;
virtual Texture *getTexture();
virtual const ImageIndex *getTextureImageIndex() const;
virtual Renderbuffer *getRenderbuffer();
private:
DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment);

Просмотреть файл

@ -0,0 +1,143 @@
//
// Copyright 2014 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.
//
// ImageIndex.cpp: Implementation for ImageIndex methods.
#include "libGLESv2/ImageIndex.h"
#include "libGLESv2/Texture.h"
#include "common/utilities.h"
namespace gl
{
ImageIndex::ImageIndex(const ImageIndex &other)
: type(other.type),
mipIndex(other.mipIndex),
layerIndex(other.layerIndex)
{}
ImageIndex &ImageIndex::operator=(const ImageIndex &other)
{
type = other.type;
mipIndex = other.mipIndex;
layerIndex = other.layerIndex;
return *this;
}
ImageIndex ImageIndex::Make2D(GLint mipIndex)
{
return ImageIndex(GL_TEXTURE_2D, mipIndex, ENTIRE_LEVEL);
}
ImageIndex ImageIndex::MakeCube(GLenum target, GLint mipIndex)
{
ASSERT(gl::IsCubemapTextureTarget(target));
return ImageIndex(target, mipIndex, TextureCubeMap::targetToLayerIndex(target));
}
ImageIndex ImageIndex::Make2DArray(GLint mipIndex, GLint layerIndex)
{
return ImageIndex(GL_TEXTURE_2D_ARRAY, mipIndex, layerIndex);
}
ImageIndex ImageIndex::Make3D(GLint mipIndex, GLint layerIndex)
{
return ImageIndex(GL_TEXTURE_3D, mipIndex, layerIndex);
}
ImageIndex::ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn)
: type(typeIn),
mipIndex(mipIndexIn),
layerIndex(layerIndexIn)
{}
ImageIndexIterator ImageIndexIterator::Make2D(GLint minMip, GLint maxMip)
{
return ImageIndexIterator(GL_TEXTURE_2D, rx::Range<GLint>(minMip, maxMip),
rx::Range<GLint>(ImageIndex::ENTIRE_LEVEL, ImageIndex::ENTIRE_LEVEL), NULL);
}
ImageIndexIterator ImageIndexIterator::MakeCube(GLint minMip, GLint maxMip)
{
return ImageIndexIterator(GL_TEXTURE_CUBE_MAP, rx::Range<GLint>(minMip, maxMip), rx::Range<GLint>(0, 6), NULL);
}
ImageIndexIterator ImageIndexIterator::Make3D(GLint minMip, GLint maxMip,
GLint minLayer, GLint maxLayer)
{
return ImageIndexIterator(GL_TEXTURE_3D, rx::Range<GLint>(minMip, maxMip), rx::Range<GLint>(minLayer, maxLayer), NULL);
}
ImageIndexIterator ImageIndexIterator::Make2DArray(GLint minMip, GLint maxMip,
const GLsizei *layerCounts)
{
return ImageIndexIterator(GL_TEXTURE_2D_ARRAY, rx::Range<GLint>(minMip, maxMip),
rx::Range<GLint>(0, IMPLEMENTATION_MAX_2D_ARRAY_TEXTURE_LAYERS), layerCounts);
}
ImageIndexIterator::ImageIndexIterator(GLenum type, const rx::Range<GLint> &mipRange,
const rx::Range<GLint> &layerRange, const GLsizei *layerCounts)
: mType(type),
mMipRange(mipRange),
mLayerRange(layerRange),
mLayerCounts(layerCounts),
mCurrentMip(mipRange.start),
mCurrentLayer(layerRange.start)
{}
GLint ImageIndexIterator::maxLayer() const
{
return (mLayerCounts ? static_cast<GLint>(mLayerCounts[mCurrentMip]) : mLayerRange.end);
}
ImageIndex ImageIndexIterator::next()
{
ASSERT(hasNext());
ImageIndex value = current();
// Iterate layers in the inner loop for now. We can add switchable
// layer or mip iteration if we need it.
if (mCurrentLayer != ImageIndex::ENTIRE_LEVEL)
{
if (mCurrentLayer < maxLayer()-1)
{
mCurrentLayer++;
}
else if (mCurrentMip < mMipRange.end-1)
{
mCurrentMip++;
mCurrentLayer = mLayerRange.start;
}
}
else if (mCurrentMip < mMipRange.end-1)
{
mCurrentMip++;
mCurrentLayer = mLayerRange.start;
}
return value;
}
ImageIndex ImageIndexIterator::current() const
{
ImageIndex value(mType, mCurrentMip, mCurrentLayer);
if (mType == GL_TEXTURE_CUBE_MAP)
{
value.type = TextureCubeMap::layerIndexToTarget(mCurrentLayer);
}
return value;
}
bool ImageIndexIterator::hasNext() const
{
return (mCurrentMip < mMipRange.end || mCurrentLayer < maxLayer());
}
}

Просмотреть файл

@ -0,0 +1,67 @@
//
// Copyright 2014 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.
//
// ImageIndex.h: A helper struct for indexing into an Image array
#ifndef LIBGLESV2_IMAGE_INDEX_H_
#define LIBGLESV2_IMAGE_INDEX_H_
#include "angle_gl.h"
#include "common/mathutil.h"
namespace gl
{
struct ImageIndex
{
GLenum type;
GLint mipIndex;
GLint layerIndex;
ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn);
ImageIndex(const ImageIndex &other);
ImageIndex &operator=(const ImageIndex &other);
bool hasLayer() const { return layerIndex != ENTIRE_LEVEL; }
static ImageIndex Make2D(GLint mipIndex);
static ImageIndex MakeCube(GLenum target, GLint mipIndex);
static ImageIndex Make2DArray(GLint mipIndex, GLint layerIndex);
static ImageIndex Make3D(GLint mipIndex, GLint layerIndex = ENTIRE_LEVEL);
static const GLint ENTIRE_LEVEL = static_cast<GLint>(-1);
};
class ImageIndexIterator
{
public:
static ImageIndexIterator Make2D(GLint minMip, GLint maxMip);
static ImageIndexIterator MakeCube(GLint minMip, GLint maxMip);
static ImageIndexIterator Make3D(GLint minMip, GLint maxMip, GLint minLayer, GLint maxLayer);
static ImageIndexIterator Make2DArray(GLint minMip, GLint maxMip, const GLsizei *layerCounts);
ImageIndex next();
ImageIndex current() const;
bool hasNext() const;
private:
ImageIndexIterator(GLenum type, const rx::Range<GLint> &mipRange,
const rx::Range<GLint> &layerRange, const GLsizei *layerCounts);
GLint maxLayer() const;
GLenum mType;
rx::Range<GLint> mMipRange;
rx::Range<GLint> mLayerRange;
const GLsizei *mLayerCounts;
GLint mCurrentMip;
GLint mCurrentLayer;
};
}
#endif // LIBGLESV2_IMAGE_INDEX_H_

Просмотреть файл

@ -10,6 +10,7 @@
#include "libGLESv2/Program.h"
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/ResourceManager.h"
#include "libGLESv2/renderer/Renderer.h"
namespace gl
{
@ -250,7 +251,7 @@ bool Program::link(const Caps &caps)
mInfoLog.reset();
resetUniformBlockBindings();
mProgramBinary.set(new ProgramBinary(mRenderer));
mProgramBinary.set(new ProgramBinary(mRenderer->createProgram()));
mLinked = mProgramBinary->link(mInfoLog, mAttributeBindings, mFragmentShader, mVertexShader,
mTransformFeedbackVaryings, mTransformFeedbackBufferMode, caps);
@ -308,8 +309,9 @@ bool Program::setProgramBinary(GLenum binaryFormat, const void *binary, GLsizei
mInfoLog.reset();
mProgramBinary.set(new ProgramBinary(mRenderer));
mProgramBinary.set(new ProgramBinary(mRenderer->createProgram()));
mLinked = mProgramBinary->load(mInfoLog, binaryFormat, binary, length);
if (!mLinked)
{
mProgramBinary.set(NULL);

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -42,6 +42,7 @@ class ShaderExecutable;
class Renderer;
struct TranslatedAttribute;
class UniformStorage;
class ProgramImpl;
}
namespace gl
@ -89,23 +90,19 @@ struct LinkedVarying
class ProgramBinary : public RefCountObject
{
public:
explicit ProgramBinary(rx::Renderer *renderer);
explicit ProgramBinary(rx::ProgramImpl *impl);
~ProgramBinary();
rx::ShaderExecutable *getPixelExecutableForFramebuffer(const Framebuffer *fbo);
rx::ShaderExecutable *getPixelExecutableForOutputLayout(const std::vector<GLenum> &outputLayout);
rx::ShaderExecutable *getVertexExecutableForInputLayout(const VertexFormat inputLayout[MAX_VERTEX_ATTRIBS]);
rx::ShaderExecutable *getGeometryExecutable() const;
rx::ProgramImpl *getImplementation() { return mProgram; }
const rx::ProgramImpl *getImplementation() const { return mProgram; }
GLuint getAttributeLocation(const char *name);
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;
bool usesGeometryShader() const;
GLint getUniformLocation(std::string name);
GLuint getUniformIndex(std::string name);
@ -137,8 +134,9 @@ class ProgramBinary : public RefCountObject
void getUniformuiv(GLint location, GLuint *params);
void dirtyAllUniforms();
void applyUniforms();
bool applyUniformBuffers(const std::vector<Buffer*> boundBuffers, const Caps &caps);
Error applyUniforms();
Error applyUniformBuffers(const std::vector<Buffer*> boundBuffers, const Caps &caps);
bool load(InfoLog &infoLog, GLenum binaryFormat, const void *binary, GLsizei length);
bool save(GLenum *binaryFormat, void *binary, GLsizei bufSize, GLsizei *length);
@ -178,14 +176,13 @@ class ProgramBinary : public RefCountObject
void updateSamplerMapping();
unsigned int getSerial() const;
int getShaderVersion() const;
void initAttributesByLayout();
void sortAttributesByLayout(rx::TranslatedAttribute attributes[MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const;
const std::vector<LinkedUniform*> &getUniforms() const { return mUniforms; }
const rx::UniformStorage &getVertexUniformStorage() const { return *mVertexUniformStorage; }
const rx::UniformStorage &getFragmentUniformStorage() const { return *mFragmentUniformStorage; }
static bool linkVaryings(InfoLog &infoLog, Shader *fragmentShader, Shader *vertexShader);
private:
DISALLOW_COPY_AND_ASSIGN(ProgramBinary);
@ -196,30 +193,29 @@ class ProgramBinary : public RefCountObject
bool active;
GLint logicalTextureUnit;
TextureType textureType;
GLenum textureType;
};
void reset();
bool linkVaryings(InfoLog &infoLog, Shader *fragmentShader, Shader *vertexShader);
bool linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, Shader *fragmentShader, Shader *vertexShader);
bool linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, const Shader *vertexShader);
bool linkValidateVariablesBase(InfoLog &infoLog,
const std::string &variableName,
const sh::ShaderVariable &vertexVariable,
const sh::ShaderVariable &fragmentVariable,
bool validatePrecision);
static bool linkValidateVariablesBase(InfoLog &infoLog,
const std::string &variableName,
const sh::ShaderVariable &vertexVariable,
const sh::ShaderVariable &fragmentVariable,
bool validatePrecision);
bool linkValidateUniforms(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform);
bool linkValidateVaryings(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying);
bool linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform);
static bool linkValidateUniforms(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform);
static bool linkValidateVaryings(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying);
static bool linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform);
bool linkUniforms(InfoLog &infoLog, const Shader &vertexShader, const Shader &fragmentShader, const Caps &caps);
void defineUniformBase(GLenum shader, const sh::Uniform &uniform, unsigned int uniformRegister);
void defineUniform(GLenum shader, const sh::ShaderVariable &uniform, const std::string &fullName, sh::HLSLBlockEncoder *encoder);
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,
@ -234,7 +230,6 @@ class ProgramBinary : public RefCountObject
bool defineUniformBlock(InfoLog &infoLog, const Shader &shader, const sh::InterfaceBlock &interfaceBlock, const Caps &caps);
bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex, const Caps &caps);
void defineOutputVariables(Shader *fragmentShader);
void initializeUniformStorage();
template <typename T>
void setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType);
@ -245,80 +240,22 @@ class ProgramBinary : public RefCountObject
template <typename T>
void getUniformv(GLint location, T *params, GLenum uniformType);
class VertexExecutable
{
public:
VertexExecutable(const VertexFormat inputLayout[MAX_VERTEX_ATTRIBS],
const GLenum signature[MAX_VERTEX_ATTRIBS],
rx::ShaderExecutable *shaderExecutable);
~VertexExecutable();
bool matchesSignature(const GLenum convertedLayout[MAX_VERTEX_ATTRIBS]) const;
const VertexFormat *inputs() const { return mInputs; }
const GLenum *signature() const { return mSignature; }
rx::ShaderExecutable *shaderExecutable() const { return mShaderExecutable; }
private:
VertexFormat mInputs[MAX_VERTEX_ATTRIBS];
GLenum mSignature[MAX_VERTEX_ATTRIBS];
rx::ShaderExecutable *mShaderExecutable;
};
class PixelExecutable
{
public:
PixelExecutable(const std::vector<GLenum> &outputSignature, rx::ShaderExecutable *shaderExecutable);
~PixelExecutable();
// FIXME(geofflang): Work around NVIDIA driver bug by repacking buffers
bool matchesSignature(const std::vector<GLenum> &signature) const { return true; /* mOutputSignature == signature; */ }
const std::vector<GLenum> &outputSignature() const { return mOutputSignature; }
rx::ShaderExecutable *shaderExecutable() const { return mShaderExecutable; }
private:
std::vector<GLenum> mOutputSignature;
rx::ShaderExecutable *mShaderExecutable;
};
rx::Renderer *const mRenderer;
rx::DynamicHLSL *mDynamicHLSL;
std::string mVertexHLSL;
rx::D3DWorkaroundType mVertexWorkarounds;
std::vector<VertexExecutable *> mVertexExecutables;
std::string mPixelHLSL;
rx::D3DWorkaroundType mPixelWorkarounds;
bool mUsesFragDepth;
std::vector<rx::PixelShaderOuputVariable> mPixelShaderKey;
std::vector<PixelExecutable *> mPixelExecutables;
rx::ShaderExecutable *mGeometryExecutable;
rx::ProgramImpl *mProgram;
sh::Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS];
sh::Attribute mShaderAttributes[MAX_VERTEX_ATTRIBS];
int mSemanticIndex[MAX_VERTEX_ATTRIBS];
int mAttributesByLayout[MAX_VERTEX_ATTRIBS];
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;
int mShaderVersion;
bool mDirtySamplerMapping;
std::vector<LinkedUniform*> mUniforms;
std::vector<UniformBlock*> mUniformBlocks;
std::vector<VariableLocation> mUniformIndex;
std::map<int, VariableLocation> mOutputVariables;
rx::UniformStorage *mVertexUniformStorage;
rx::UniformStorage *mFragmentUniformStorage;
bool mValidated;

Просмотреть файл

@ -19,31 +19,27 @@ Query::Query(rx::QueryImpl *impl, GLuint id)
Query::~Query()
{
delete mQuery;
SafeDelete(mQuery);
}
void Query::begin()
Error Query::begin()
{
// TODO: Rather than keeping track of whether the query was successfully
// created via a boolean in the GL-level Query object, we should probably
// use the error system to track these failed creations at the context level,
// and reset the active query ID for the target to 0 upon failure.
mStarted = mQuery->begin();
return mQuery->begin();
}
void Query::end()
Error Query::end()
{
mQuery->end();
return mQuery->end();
}
GLuint Query::getResult()
Error Query::getResult(GLuint *params)
{
return mQuery->getResult();
return mQuery->getResult(params);
}
GLboolean Query::isResultAvailable()
Error Query::isResultAvailable(GLuint *available)
{
return mQuery->isResultAvailable();
return mQuery->isResultAvailable(available);
}
GLenum Query::getType() const
@ -51,9 +47,4 @@ GLenum Query::getType() const
return mQuery->getType();
}
bool Query::isStarted() const
{
return mStarted;
}
}

Просмотреть файл

@ -9,6 +9,7 @@
#ifndef LIBGLESV2_QUERY_H_
#define LIBGLESV2_QUERY_H_
#include "libGLESv2/Error.h"
#include "common/angleutils.h"
#include "common/RefCountObject.h"
@ -28,20 +29,17 @@ class Query : public RefCountObject
Query(rx::QueryImpl *impl, GLuint id);
virtual ~Query();
void begin();
void end();
Error begin();
Error end();
GLuint getResult();
GLboolean isResultAvailable();
Error getResult(GLuint *params);
Error isResultAvailable(GLuint *available);
GLenum getType() const;
bool isStarted() const;
private:
DISALLOW_COPY_AND_ASSIGN(Query);
bool mStarted;
rx::QueryImpl *mQuery;
};

Просмотреть файл

@ -125,11 +125,6 @@ rx::RenderTarget *RenderbufferStorage::getRenderTarget()
return NULL;
}
rx::RenderTarget *RenderbufferStorage::getDepthStencil()
{
return NULL;
}
GLsizei RenderbufferStorage::getWidth() const
{
return mWidth;
@ -160,7 +155,7 @@ unsigned int RenderbufferStorage::getSerial() const
return mSerial;
}
unsigned int RenderbufferStorage::issueSerials(GLuint count)
unsigned int RenderbufferStorage::issueSerials(unsigned int count)
{
unsigned int firstSerial = mCurrentSerial;
mCurrentSerial += count;

Просмотреть файл

@ -71,7 +71,6 @@ class RenderbufferStorage
virtual ~RenderbufferStorage() = 0;
virtual rx::RenderTarget *getRenderTarget();
virtual rx::RenderTarget *getDepthStencil();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
@ -84,7 +83,7 @@ class RenderbufferStorage
virtual bool isTexture() const;
virtual unsigned int getTextureSerial() const;
static unsigned int issueSerials(GLuint count);
static unsigned int issueSerials(unsigned int count);
protected:
GLsizei mWidth;

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -65,11 +65,11 @@ class ResourceManager
Renderbuffer *getRenderbuffer(GLuint handle);
Sampler *getSampler(GLuint handle);
FenceSync *getFenceSync(GLuint handle);
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);

Просмотреть файл

@ -32,6 +32,7 @@ Shader::Shader(ResourceManager *manager, rx::ShaderImpl *impl, GLenum type, GLui
mDeleteStatus(false),
mCompiled(false)
{
ASSERT(impl);
}
Shader::~Shader()
@ -151,4 +152,54 @@ void Shader::flagForDeletion()
mDeleteStatus = true;
}
const std::vector<gl::PackedVarying> &Shader::getVaryings() const
{
return mShader->getVaryings();
}
const std::vector<sh::Uniform> &Shader::getUniforms() const
{
return mShader->getUniforms();
}
const std::vector<sh::InterfaceBlock> &Shader::getInterfaceBlocks() const
{
return mShader->getInterfaceBlocks();
}
const std::vector<sh::Attribute> &Shader::getActiveAttributes() const
{
return mShader->getActiveAttributes();
}
const std::vector<sh::Attribute> &Shader::getActiveOutputVariables() const
{
return mShader->getActiveOutputVariables();
}
std::vector<gl::PackedVarying> &Shader::getVaryings()
{
return mShader->getVaryings();
}
std::vector<sh::Uniform> &Shader::getUniforms()
{
return mShader->getUniforms();
}
std::vector<sh::InterfaceBlock> &Shader::getInterfaceBlocks()
{
return mShader->getInterfaceBlocks();
}
std::vector<sh::Attribute> &Shader::getActiveAttributes()
{
return mShader->getActiveAttributes();
}
std::vector<sh::Attribute> &Shader::getActiveOutputVariables()
{
return mShader->getActiveOutputVariables();
}
}

Просмотреть файл

@ -35,13 +35,16 @@ class ResourceManager;
struct PackedVarying : public sh::Varying
{
unsigned int registerIndex; // Assigned during link
unsigned int columnIndex; // Assigned during link, defaults to 0
PackedVarying(const sh::Varying &varying)
: sh::Varying(varying),
registerIndex(GL_INVALID_INDEX)
registerIndex(GL_INVALID_INDEX),
columnIndex(0)
{}
bool registerAssigned() const { return registerIndex != GL_INVALID_INDEX; }
bool isBuiltIn() const { return name.compare(0, 3, "gl_") == 0; }
void resetRegisterAssignment()
{
@ -80,6 +83,18 @@ class Shader
bool isFlaggedForDeletion() const;
void flagForDeletion();
const std::vector<gl::PackedVarying> &getVaryings() const;
const std::vector<sh::Uniform> &getUniforms() const;
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const;
const std::vector<sh::Attribute> &getActiveAttributes() const;
const std::vector<sh::Attribute> &getActiveOutputVariables() const;
std::vector<gl::PackedVarying> &getVaryings();
std::vector<sh::Uniform> &getUniforms();
std::vector<sh::InterfaceBlock> &getInterfaceBlocks();
std::vector<sh::Attribute> &getActiveAttributes();
std::vector<sh::Attribute> &getActiveOutputVariables();
private:
DISALLOW_COPY_AND_ASSIGN(Shader);

Просмотреть файл

@ -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,7 +19,17 @@
namespace gl
{
State::State()
{
}
State::~State()
{
reset();
}
void State::initialize(const Caps& caps, GLuint clientVersion)
{
mContext = NULL;
@ -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,15 +138,20 @@ 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 };
for (int attribIndex = 0; attribIndex < MAX_VERTEX_ATTRIBS; attribIndex++)
@ -244,15 +266,8 @@ ClearParameters State::getClearParameters(GLbitfield mask) const
{
if (framebufferObject->getStencilbuffer() != NULL)
{
rx::RenderTarget *depthStencil = framebufferObject->getStencilbuffer()->getRenderTarget();
if (!depthStencil)
{
ERR("Depth stencil pointer unexpectedly null.");
ClearParameters nullClearParam = { 0 };
return nullClearParam;
}
if (GetInternalFormatInfo(depthStencil->getActualFormat()).stencilBits > 0)
GLenum stencilActualFormat = framebufferObject->getStencilbuffer()->getActualFormat();
if (GetInternalFormatInfo(stencilActualFormat).stencilBits > 0)
{
clearParams.clearStencil = true;
}
@ -590,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)
@ -623,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);
}
}
}
@ -657,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();
}
@ -672,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);
}
}
}
@ -1315,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;

Просмотреть файл

@ -12,9 +12,9 @@
#include "libGLESv2/main.h"
#include "libGLESv2/Context.h"
#include "libGLESv2/formatutils.h"
#include "libGLESv2/ImageIndex.h"
#include "libGLESv2/Renderbuffer.h"
#include "libGLESv2/renderer/Image.h"
#include "libGLESv2/renderer/RenderTarget.h"
#include "libGLESv2/renderer/d3d/TextureStorage.h"
#include "libEGL/Surface.h"
@ -77,7 +77,7 @@ void Texture::getSamplerStateWithNativeOffset(SamplerState *sampler)
*sampler = mSamplerState;
// Offset the effective base level by the texture storage's top level
rx::TextureStorageInterface *texture = getNativeTexture();
rx::TextureStorage *texture = getNativeTexture();
int topLevel = texture ? texture->getTopLevel() : 0;
sampler->baseLevel = topLevel + mSamplerState.baseLevel;
}
@ -114,7 +114,31 @@ GLenum Texture::getBaseLevelInternalFormat() const
return (baseImage ? baseImage->getInternalFormat() : GL_NONE);
}
rx::TextureStorageInterface *Texture::getNativeTexture()
GLsizei Texture::getWidth(const ImageIndex &index) const
{
rx::Image *image = mTexture->getImage(index);
return image->getWidth();
}
GLsizei Texture::getHeight(const ImageIndex &index) const
{
rx::Image *image = mTexture->getImage(index);
return image->getHeight();
}
GLenum Texture::getInternalFormat(const ImageIndex &index) const
{
rx::Image *image = mTexture->getImage(index);
return image->getInternalFormat();
}
GLenum Texture::getActualFormat(const ImageIndex &index) const
{
rx::Image *image = mTexture->getImage(index);
return image->getActualFormat();
}
rx::TextureStorage *Texture::getNativeTexture()
{
return getImplementation()->getNativeTexture();
}
@ -131,7 +155,7 @@ void Texture::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoff
unsigned int Texture::getTextureSerial()
{
rx::TextureStorageInterface *texture = getNativeTexture();
rx::TextureStorage *texture = getNativeTexture();
return texture ? texture->getTextureSerial() : 0;
}
@ -142,7 +166,7 @@ bool Texture::isImmutable() const
int Texture::immutableLevelCount()
{
return (mImmutable ? getNativeTexture()->getStorageInstance()->getLevelCount() : 0);
return (mImmutable ? getNativeTexture()->getLevelCount() : 0);
}
int Texture::mipLevels() const
@ -202,11 +226,11 @@ GLenum Texture2D::getActualFormat(GLint level) const
return GL_NONE;
}
void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
Error Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{
releaseTexImage();
mTexture->setImage(GL_TEXTURE_2D, level, width, height, 1, internalFormat, format, type, unpack, pixels);
return mTexture->setImage(GL_TEXTURE_2D, level, width, height, 1, internalFormat, format, type, unpack, pixels);
}
void Texture2D::bindTexImage(egl::Surface *surface)
@ -230,21 +254,23 @@ void Texture2D::releaseTexImage()
}
}
void Texture2D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels)
Error Texture2D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize,
const void *pixels)
{
releaseTexImage();
mTexture->setCompressedImage(GL_TEXTURE_2D, level, format, width, height, 1, imageSize, pixels);
return mTexture->setCompressedImage(GL_TEXTURE_2D, level, format, width, height, 1, imageSize, pixels);
}
void Texture2D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
Error Texture2D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{
mTexture->subImage(GL_TEXTURE_2D, level, xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels);
return mTexture->subImage(GL_TEXTURE_2D, level, xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels);
}
void Texture2D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels)
Error Texture2D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
GLenum format, GLsizei imageSize, const void *pixels)
{
mTexture->subImageCompressed(GL_TEXTURE_2D, level, xoffset, yoffset, 0, width, height, 1, format, imageSize, pixels);
return mTexture->subImageCompressed(GL_TEXTURE_2D, level, xoffset, yoffset, 0, width, height, 1, format, imageSize, pixels);
}
void Texture2D::copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
@ -342,16 +368,6 @@ void Texture2D::generateMipmaps()
mTexture->generateMipmaps();
}
unsigned int Texture2D::getRenderTargetSerial(GLint level)
{
return mTexture->getRenderTargetSerial(level, 0);
}
rx::RenderTarget *Texture2D::getRenderTarget(GLint level)
{
return mTexture->getRenderTarget(level, 0);
}
// Tests for 2D texture (mipmap) completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
bool Texture2D::isMipmapComplete() const
{
@ -453,49 +469,27 @@ GLenum TextureCubeMap::getActualFormat(GLenum target, GLint level) const
return GL_NONE;
}
void TextureCubeMap::setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
Error TextureCubeMap::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{
mTexture->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, width, height, 1, internalFormat, format, type, unpack, pixels);
return mTexture->setImage(target, level, width, height, 1, internalFormat, format, type, unpack, pixels);
}
void TextureCubeMap::setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
Error TextureCubeMap::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height,
GLsizei imageSize, const void *pixels)
{
mTexture->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, level, width, height, 1, internalFormat, format, type, unpack, pixels);
return mTexture->setCompressedImage(target, level, format, width, height, 1, imageSize, pixels);
}
void TextureCubeMap::setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
Error TextureCubeMap::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{
mTexture->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, level, width, height, 1, internalFormat, format, type, unpack, pixels);
return mTexture->subImage(target, level, xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels);
}
void TextureCubeMap::setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
Error TextureCubeMap::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height, GLenum format,
GLsizei imageSize, const void *pixels)
{
mTexture->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, level, width, height, 1, internalFormat, format, type, unpack, pixels);
}
void TextureCubeMap::setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{
mTexture->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, level, width, height, 1, internalFormat, format, type, unpack, pixels);
}
void TextureCubeMap::setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{
mTexture->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, level, width, height, 1, internalFormat, format, type, unpack, pixels);
}
void TextureCubeMap::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels)
{
mTexture->setCompressedImage(target, level, format, width, height, 1, imageSize, pixels);
}
void TextureCubeMap::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{
mTexture->subImage(target, level, xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels);
}
void TextureCubeMap::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels)
{
mTexture->subImageCompressed(target, level, xoffset, yoffset, 0, width, height, 1, format, imageSize, pixels);
return mTexture->subImageCompressed(target, level, xoffset, yoffset, 0, width, height, 1, format, imageSize, pixels);
}
// Tests for cube texture completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
@ -585,11 +579,6 @@ bool TextureCubeMap::isSamplerComplete(const SamplerState &samplerState, const T
return true;
}
unsigned int TextureCubeMap::getRenderTargetSerial(GLenum target, GLint level)
{
return mTexture->getRenderTargetSerial(level, targetToLayerIndex(target));
}
int TextureCubeMap::targetToLayerIndex(GLenum target)
{
META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_X - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 1);
@ -612,11 +601,6 @@ GLenum TextureCubeMap::layerIndexToTarget(GLint layer)
return GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
}
rx::RenderTarget *TextureCubeMap::getRenderTarget(GLenum target, GLint level)
{
return mTexture->getRenderTarget(level, targetToLayerIndex(target));
}
bool TextureCubeMap::isMipmapComplete() const
{
if (isImmutable())
@ -730,24 +714,27 @@ bool Texture3D::isDepth(GLint level) const
return GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0;
}
void Texture3D::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
Error Texture3D::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{
mTexture->setImage(GL_TEXTURE_3D, level, width, height, depth, internalFormat, format, type, unpack, pixels);
return mTexture->setImage(GL_TEXTURE_3D, level, width, height, depth, internalFormat, format, type, unpack, pixels);
}
void Texture3D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels)
Error Texture3D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth,
GLsizei imageSize, const void *pixels)
{
mTexture->setCompressedImage(GL_TEXTURE_3D, level, format, width, height, depth, imageSize, pixels);
return mTexture->setCompressedImage(GL_TEXTURE_3D, level, format, width, height, depth, imageSize, pixels);
}
void Texture3D::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
Error Texture3D::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{
mTexture->subImage(GL_TEXTURE_3D, level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels);
return mTexture->subImage(GL_TEXTURE_3D, level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels);
}
void Texture3D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels)
Error Texture3D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth, GLenum format,
GLsizei imageSize, const void *pixels)
{
mTexture->subImageCompressed(GL_TEXTURE_3D, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, pixels);
return mTexture->subImageCompressed(GL_TEXTURE_3D, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, pixels);
}
void Texture3D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
@ -781,17 +768,6 @@ bool Texture3D::isSamplerComplete(const SamplerState &samplerState, const Textur
return true;
}
unsigned int Texture3D::getRenderTargetSerial(GLint level, GLint layer)
{
return mTexture->getRenderTargetSerial(level, layer);
}
rx::RenderTarget *Texture3D::getRenderTarget(GLint level, GLint layer)
{
return mTexture->getRenderTarget(level, layer);
}
bool Texture3D::isMipmapComplete() const
{
int levelCount = mipLevels();
@ -899,24 +875,27 @@ bool Texture2DArray::isDepth(GLint level) const
return GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0;
}
void Texture2DArray::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
Error Texture2DArray::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{
mTexture->setImage(GL_TEXTURE_2D_ARRAY, level, width, height, depth, internalFormat, format, type, unpack, pixels);
return mTexture->setImage(GL_TEXTURE_2D_ARRAY, level, width, height, depth, internalFormat, format, type, unpack, pixels);
}
void Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels)
Error Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth,
GLsizei imageSize, const void *pixels)
{
mTexture->setCompressedImage(GL_TEXTURE_2D_ARRAY, level, format, width, height, depth, imageSize, pixels);
return mTexture->setCompressedImage(GL_TEXTURE_2D_ARRAY, level, format, width, height, depth, imageSize, pixels);
}
void Texture2DArray::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
Error Texture2DArray::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{
mTexture->subImage(GL_TEXTURE_2D_ARRAY, level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels);
return mTexture->subImage(GL_TEXTURE_2D_ARRAY, level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels);
}
void Texture2DArray::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels)
Error Texture2DArray::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth, GLenum format,
GLsizei imageSize, const void *pixels)
{
mTexture->subImageCompressed(GL_TEXTURE_2D_ARRAY, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, pixels);
return mTexture->subImageCompressed(GL_TEXTURE_2D_ARRAY, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, pixels);
}
void Texture2DArray::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
@ -950,16 +929,6 @@ bool Texture2DArray::isSamplerComplete(const SamplerState &samplerState, const T
return true;
}
unsigned int Texture2DArray::getRenderTargetSerial(GLint level, GLint layer)
{
return mTexture->getRenderTargetSerial(level, layer);
}
rx::RenderTarget *Texture2DArray::getRenderTarget(GLint level, GLint layer)
{
return mTexture->getRenderTarget(level, layer);
}
bool Texture2DArray::isMipmapComplete() const
{
int levelCount = mipLevels();

Просмотреть файл

@ -30,7 +30,6 @@ class Surface;
namespace rx
{
class TextureStorageInterface;
class RenderTarget;
class Image;
}
@ -38,6 +37,7 @@ namespace gl
{
class Framebuffer;
class FramebufferAttachment;
struct ImageIndex;
bool IsMipmapFiltered(const gl::SamplerState &samplerState);
@ -62,9 +62,14 @@ class Texture : public RefCountObject
GLint getBaseLevelDepth() const;
GLenum getBaseLevelInternalFormat() const;
GLsizei getWidth(const ImageIndex &index) const;
GLsizei getHeight(const ImageIndex &index) const;
GLenum getInternalFormat(const ImageIndex &index) const;
GLenum getActualFormat(const ImageIndex &index) const;
virtual bool isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const = 0;
rx::TextureStorageInterface *getNativeTexture();
rx::TextureStorage *getNativeTexture();
virtual void generateMipmaps();
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
@ -111,10 +116,10 @@ class Texture2D : public Texture
bool isCompressed(GLint level) const;
bool isDepth(GLint level) const;
void setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
Error setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
Error setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
Error subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
Error subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
void copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
@ -124,12 +129,6 @@ class Texture2D : public Texture
virtual void generateMipmaps();
unsigned int getRenderTargetSerial(GLint level);
protected:
friend class Texture2DAttachment;
rx::RenderTarget *getRenderTarget(GLint level);
private:
DISALLOW_COPY_AND_ASSIGN(Texture2D);
@ -153,17 +152,10 @@ class TextureCubeMap : public Texture
bool isCompressed(GLenum target, GLint level) const;
bool isDepth(GLenum target, GLint level) const;
void setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
Error setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
Error subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
void storage(GLsizei levels, GLenum internalformat, GLsizei size);
@ -171,15 +163,9 @@ class TextureCubeMap : public Texture
bool isCubeComplete() const;
unsigned int getRenderTargetSerial(GLenum target, GLint level);
static int targetToLayerIndex(GLenum target);
static GLenum layerIndexToTarget(GLint layer);
protected:
friend class TextureCubeMapAttachment;
rx::RenderTarget *getRenderTarget(GLenum target, GLint level);
private:
DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
@ -202,20 +188,14 @@ class Texture3D : public Texture
bool isCompressed(GLint level) const;
bool isDepth(GLint level) const;
void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
void subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
Error setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
Error setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
Error subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
Error subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
virtual bool isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const;
unsigned int getRenderTargetSerial(GLint level, GLint layer);
protected:
friend class Texture3DAttachment;
rx::RenderTarget *getRenderTarget(GLint level, GLint layer);
private:
DISALLOW_COPY_AND_ASSIGN(Texture3D);
@ -238,20 +218,14 @@ class Texture2DArray : public Texture
bool isCompressed(GLint level) const;
bool isDepth(GLint level) const;
void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
void subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
Error setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
Error setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
Error subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
Error subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
virtual bool isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const;
unsigned int getRenderTargetSerial(GLint level, GLint layer);
protected:
friend class Texture2DArrayAttachment;
rx::RenderTarget *getRenderTarget(GLint level, GLint layer);
private:
DISALLOW_COPY_AND_ASSIGN(Texture2DArray);

Просмотреть файл

@ -44,7 +44,7 @@ class VertexArray
void setAttributeState(unsigned int attributeIndex, gl::Buffer *boundBuffer, GLint size, GLenum type,
bool normalized, bool pureInteger, GLsizei stride, const void *pointer);
const VertexAttribute* getVertexAttributes() const { return mVertexAttributes.data(); }
const VertexAttribute* getVertexAttributes() const { return &mVertexAttributes[0]; }
Buffer *getElementArrayBuffer() const { return mElementArrayBuffer.get(); }
void setElementArrayBuffer(Buffer *buffer);
GLuint getElementArrayBufferId() const { return mElementArrayBuffer.id(); }

Просмотреть файл

@ -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,
@ -261,13 +250,6 @@ enum VertexConversionType
VERTEX_CONVERT_BOTH = 3
};
enum D3DWorkaroundType
{
ANGLE_D3D_WORKAROUND_NONE,
ANGLE_D3D_WORKAROUND_SKIP_OPTIMIZATION,
ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION
};
}
#endif // LIBGLESV2_ANGLETYPES_H_

Просмотреть файл

@ -212,7 +212,7 @@ static bool NeverSupported(GLuint, const Extensions &)
}
template <GLuint minCoreGLVersion>
static bool RequireESVersion(GLuint clientVersion, const Extensions &)
static bool RequireES(GLuint clientVersion, const Extensions &)
{
return clientVersion >= minCoreGLVersion;
}
@ -222,30 +222,37 @@ typedef bool(Extensions::*ExtensionBool);
// Check support for a single extension
template <ExtensionBool bool1>
static bool RequireExtension(GLuint, const Extensions & extensions)
static bool RequireExt(GLuint, const Extensions & extensions)
{
return extensions.*bool1;
}
// Check for a minimum client version or a single extension
template <GLuint minCoreGLVersion, ExtensionBool bool1>
static bool RequireESVersionOrExtension(GLuint clientVersion, const Extensions &extensions)
static bool RequireESOrExt(GLuint clientVersion, const Extensions &extensions)
{
return clientVersion >= minCoreGLVersion || extensions.*bool1;
}
// Check for a minimum client version or two extensions
template <GLuint minCoreGLVersion, ExtensionBool bool1, ExtensionBool bool2>
static bool RequireESVersionOrExtensions(GLuint clientVersion, const Extensions &extensions)
static bool RequireESOrExtAndExt(GLuint clientVersion, const Extensions &extensions)
{
return clientVersion >= minCoreGLVersion || (extensions.*bool1 || extensions.*bool2);
return clientVersion >= minCoreGLVersion || (extensions.*bool1 && extensions.*bool2);
}
// Check for a minimum client version or at least one of two extensions
template <GLuint minCoreGLVersion, ExtensionBool bool1, ExtensionBool bool2>
static bool RequireESOrExtOrExt(GLuint clientVersion, const Extensions &extensions)
{
return clientVersion >= minCoreGLVersion || extensions.*bool1 || extensions.*bool2;
}
// Check support for two extensions
template <ExtensionBool bool1, ExtensionBool bool2>
static bool RequireExtensions(GLuint, const Extensions &extensions)
static bool RequireExtAndExt(GLuint, const Extensions &extensions)
{
return extensions.*bool1 || extensions.*bool2;
return extensions.*bool1 && extensions.*bool2;
}
InternalFormat::InternalFormat()
@ -380,105 +387,105 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
// From ES 3.0.1 spec, table 3.12
map.insert(InternalFormatInfoPair(GL_NONE, InternalFormat()));
// | Internal format | | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable |
map.insert(InternalFormatInfoPair(GL_R8, RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESVersionOrExtension<3, &Extensions::textureRG>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_R8_SNORM, RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireESVersion<3>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RG8, RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESVersionOrExtension<3, &Extensions::textureRG>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RG8_SNORM, RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireESVersion<3>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB8, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESVersionOrExtension<3, &Extensions::rgb8rgba8>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB8_SNORM, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireESVersion<3>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB565, RGBAFormat( 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, RequireESVersion<2>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA4, RGBAFormat( 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, RequireESVersion<2>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB5_A1, RGBAFormat( 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, RequireESVersion<2>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA8, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESVersionOrExtension<3, &Extensions::rgb8rgba8>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA8_SNORM, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireESVersion<3>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB10_A2, RGBAFormat(10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireESVersion<3>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB10_A2UI, RGBAFormat(10, 10, 10, 2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT, false, RequireESVersion<3>, NeverSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_SRGB8, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESVersionOrExtension<3, &Extensions::sRGB>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_SRGB8_ALPHA8, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESVersionOrExtension<3, &Extensions::sRGB>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_R11F_G11F_B10F, RGBAFormat(11, 11, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT, false, RequireESVersion<3>, RequireExtension<&Extensions::colorBufferFloat>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB9_E5, RGBAFormat( 9, 9, 9, 0, 5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT, false, RequireESVersion<3>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_R8I, RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_R8UI, RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_R16I, RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_SHORT, GL_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_R16UI, RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_R32I, RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_INT, GL_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_R32UI, RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RG8I, RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_BYTE, GL_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RG8UI, RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RG16I, RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_SHORT, GL_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RG16UI, RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RG32I, RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_INT, GL_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RG32UI, RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGB8I, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, RequireESVersion<3>, NeverSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGB8UI, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireESVersion<3>, NeverSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGB16I, RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, RequireESVersion<3>, NeverSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGB16UI, RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireESVersion<3>, NeverSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGB32I, RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, RequireESVersion<3>, NeverSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGB32UI, RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireESVersion<3>, NeverSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA8I, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_BYTE, GL_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA8UI, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA16I, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT, GL_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA16UI, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA32I, RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, GL_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA32UI, RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireESVersion<3>, AlwaysSupported, NeverSupported)));
// | Internal format | | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable |
map.insert(InternalFormatInfoPair(GL_R8, RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::textureRG>, RequireESOrExt<3, &Extensions::textureRG>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_R8_SNORM, RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RG8, RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::textureRG>, RequireESOrExt<3, &Extensions::textureRG>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RG8_SNORM, RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB8, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::rgb8rgba8>, RequireESOrExt<3, &Extensions::rgb8rgba8>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB8_SNORM, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB565, RGBAFormat( 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, RequireES<2>, RequireES<2>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA4, RGBAFormat( 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, RequireES<2>, RequireES<2>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB5_A1, RGBAFormat( 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, RequireES<2>, RequireES<2>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA8, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::rgb8rgba8>, RequireESOrExt<3, &Extensions::rgb8rgba8>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA8_SNORM, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB10_A2, RGBAFormat(10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireES<3>, RequireES<3>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB10_A2UI, RGBAFormat(10, 10, 10, 2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_SRGB8, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESOrExt<3, &Extensions::sRGB>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_SRGB8_ALPHA8, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESOrExt<3, &Extensions::sRGB>, RequireESOrExt<3, &Extensions::sRGB>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_R11F_G11F_B10F, RGBAFormat(11, 11, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT, false, RequireES<3>, RequireExt<&Extensions::colorBufferFloat>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB9_E5, RGBAFormat( 9, 9, 9, 0, 5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT, false, RequireES<3>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_R8I, RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_R8UI, RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_R16I, RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_R16UI, RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_R32I, RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_R32UI, RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RG8I, RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RG8UI, RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RG16I, RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RG16UI, RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RG32I, RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RG32UI, RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGB8I, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGB8UI, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGB16I, RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGB16UI, RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGB32I, RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGB32UI, RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA8I, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA8UI, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA16I, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA16UI, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA32I, RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA32UI, RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
map.insert(InternalFormatInfoPair(GL_BGRA8_EXT, RGBAFormat( 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExtension<&Extensions::textureFormatBGRA8888>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_BGRA4_ANGLEX, RGBAFormat( 4, 4, 4, 4, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExtension<&Extensions::textureFormatBGRA8888>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_BGR5_A1_ANGLEX, RGBAFormat( 5, 5, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExtension<&Extensions::textureFormatBGRA8888>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_BGRA8_EXT, RGBAFormat( 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_BGRA4_ANGLEX, RGBAFormat( 4, 4, 4, 4, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_BGR5_A1_ANGLEX, RGBAFormat( 5, 5, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported)));
// Floating point renderability and filtering is provided by OES_texture_float and OES_texture_half_float
// | Internal format | | D |S | Format | Type | Comp | SRGB | Texture supported | Renderable | Filterable |
// | | | | | | | type | | | | |
map.insert(InternalFormatInfoPair(GL_R16F, RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, GL_FLOAT, false, RequireESVersionOrExtensions<3, &Extensions::textureHalfFloat, &Extensions::textureRG>, AlwaysSupported, RequireExtension<&Extensions::textureHalfFloatLinear>)));
map.insert(InternalFormatInfoPair(GL_RG16F, RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, GL_FLOAT, false, RequireESVersionOrExtensions<3, &Extensions::textureHalfFloat, &Extensions::textureRG>, AlwaysSupported, RequireExtension<&Extensions::textureHalfFloatLinear>)));
map.insert(InternalFormatInfoPair(GL_RGB16F, RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, GL_FLOAT, false, RequireESVersionOrExtension<3, &Extensions::textureHalfFloat>, AlwaysSupported, RequireExtension<&Extensions::textureHalfFloatLinear>)));
map.insert(InternalFormatInfoPair(GL_RGBA16F, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, RequireESVersionOrExtension<3, &Extensions::textureHalfFloat>, AlwaysSupported, RequireExtension<&Extensions::textureHalfFloatLinear>)));
map.insert(InternalFormatInfoPair(GL_R32F, RGBAFormat(32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, RequireESVersionOrExtensions<3, &Extensions::textureFloat, &Extensions::textureRG>, AlwaysSupported, RequireExtension<&Extensions::textureFloatLinear> )));
map.insert(InternalFormatInfoPair(GL_RG32F, RGBAFormat(32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, RequireESVersionOrExtensions<3, &Extensions::textureFloat, &Extensions::textureRG>, AlwaysSupported, RequireExtension<&Extensions::textureFloatLinear> )));
map.insert(InternalFormatInfoPair(GL_RGB32F, RGBAFormat(32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, RequireESVersionOrExtension<3, &Extensions::textureFloat>, AlwaysSupported, RequireExtension<&Extensions::textureFloatLinear> )));
map.insert(InternalFormatInfoPair(GL_RGBA32F, RGBAFormat(32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, RequireESVersionOrExtension<3, &Extensions::textureFloat>, AlwaysSupported, RequireExtension<&Extensions::textureFloatLinear> )));
// | Internal format | | D |S | Format | Type | Comp | SRGB | Texture supported | Renderable | Filterable |
// | | | | | | | type | | | | |
map.insert(InternalFormatInfoPair(GL_R16F, RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, GL_FLOAT, false, RequireESOrExtAndExt<3, &Extensions::textureHalfFloat, &Extensions::textureRG>, RequireESOrExtAndExt<3, &Extensions::textureHalfFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureHalfFloatLinear>)));
map.insert(InternalFormatInfoPair(GL_RG16F, RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, GL_FLOAT, false, RequireESOrExtAndExt<3, &Extensions::textureHalfFloat, &Extensions::textureRG>, RequireESOrExtAndExt<3, &Extensions::textureHalfFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureHalfFloatLinear>)));
map.insert(InternalFormatInfoPair(GL_RGB16F, RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, GL_FLOAT, false, RequireESOrExt<3, &Extensions::textureHalfFloat>, RequireESOrExt<3, &Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>)));
map.insert(InternalFormatInfoPair(GL_RGBA16F, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, RequireESOrExt<3, &Extensions::textureHalfFloat>, RequireESOrExt<3, &Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>)));
map.insert(InternalFormatInfoPair(GL_R32F, RGBAFormat(32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, RequireESOrExtAndExt<3, &Extensions::textureFloat, &Extensions::textureRG>, RequireESOrExtAndExt<3, &Extensions::textureFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureFloatLinear> )));
map.insert(InternalFormatInfoPair(GL_RG32F, RGBAFormat(32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, RequireESOrExtAndExt<3, &Extensions::textureFloat, &Extensions::textureRG>, RequireESOrExtAndExt<3, &Extensions::textureFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureFloatLinear> )));
map.insert(InternalFormatInfoPair(GL_RGB32F, RGBAFormat(32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, RequireESOrExt<3, &Extensions::textureFloat>, RequireESOrExt<3, &Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear> )));
map.insert(InternalFormatInfoPair(GL_RGBA32F, RGBAFormat(32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, RequireESOrExt<3, &Extensions::textureFloat>, RequireESOrExt<3, &Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear> )));
// Depth stencil formats
// | Internal format | | D |S | X | Format | Type | Component type | Supported |
map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT16, DepthStencilFormat(16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, RequireESVersion<2>, AlwaysSupported, RequireESVersionOrExtension<3, &Extensions::depthTextures>)));
map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT24, DepthStencilFormat(24, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireESVersion<3>, AlwaysSupported, RequireESVersionOrExtension<3, &Extensions::depthTextures>)));
map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32F, DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, RequireESVersion<3>, AlwaysSupported, RequireESVersionOrExtension<3, &Extensions::depthTextures>)));
map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32_OES, DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireExtension<&Extensions::depthTextures>, AlwaysSupported, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_DEPTH24_STENCIL8, DepthStencilFormat(24, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, RequireESVersionOrExtension<2, &Extensions::depthTextures>, AlwaysSupported, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_DEPTH32F_STENCIL8, DepthStencilFormat(32, 8, 24, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT, RequireESVersion<3>, AlwaysSupported, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_STENCIL_INDEX8, DepthStencilFormat( 0, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, RequireESVersion<2>, AlwaysSupported, NeverSupported )));
// | Internal format | | D |S | X | Format | Type | Component type | Supported | Renderable | Filterable |
map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT16, DepthStencilFormat(16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, RequireES<2>, RequireES<2>, RequireESOrExt<3, &Extensions::depthTextures>)));
map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT24, DepthStencilFormat(24, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireES<3>, RequireES<3>, RequireESOrExt<3, &Extensions::depthTextures>)));
map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32F, DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, RequireES<3>, RequireES<3>, RequireESOrExt<3, &Extensions::depthTextures>)));
map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32_OES, DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::depthTextures>, RequireExt<&Extensions::depthTextures>, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_DEPTH24_STENCIL8, DepthStencilFormat(24, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, RequireESOrExt<3, &Extensions::depthTextures>, RequireESOrExtOrExt<3, &Extensions::depthTextures, &Extensions::packedDepthStencil>, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_DEPTH32F_STENCIL8, DepthStencilFormat(32, 8, 24, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT, RequireES<3>, RequireES<3>, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_STENCIL_INDEX8, DepthStencilFormat( 0, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, RequireES<2>, RequireES<2>, NeverSupported )));
// Luminance alpha formats
// | Internal format | | L | A | Format | Type | Component type | Supported | Renderable | Filterable |
map.insert(InternalFormatInfoPair(GL_ALPHA8_EXT, LUMAFormat( 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExtension<&Extensions::textureStorage>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE8_EXT, LUMAFormat( 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExtension<&Extensions::textureStorage>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_ALPHA32F_EXT, LUMAFormat( 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtensions<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE32F_EXT, LUMAFormat(32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, RequireExtensions<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_ALPHA16F_EXT, LUMAFormat( 0, 16, GL_ALPHA, GL_HALF_FLOAT, GL_FLOAT, RequireExtensions<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE16F_EXT, LUMAFormat(16, 0, GL_LUMINANCE, GL_HALF_FLOAT, GL_FLOAT, RequireExtensions<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE8_ALPHA8_EXT, LUMAFormat( 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExtension<&Extensions::textureStorage>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA32F_EXT, LUMAFormat(32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtensions<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA16F_EXT, LUMAFormat(16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_FLOAT, RequireExtensions<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_ALPHA8_EXT, LUMAFormat( 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE8_EXT, LUMAFormat( 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_ALPHA32F_EXT, LUMAFormat( 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE32F_EXT, LUMAFormat(32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_ALPHA16F_EXT, LUMAFormat( 0, 16, GL_ALPHA, GL_HALF_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE16F_EXT, LUMAFormat(16, 0, GL_LUMINANCE, GL_HALF_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE8_ALPHA8_EXT, LUMAFormat( 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA32F_EXT, LUMAFormat(32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA16F_EXT, LUMAFormat(16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported)));
// Unsized formats
// | Internal format | | Format | Supported | Renderable | Filterable |
map.insert(InternalFormatInfoPair(GL_ALPHA, UnsizedFormat(GL_ALPHA, RequireESVersion<2>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE, UnsizedFormat(GL_LUMINANCE, RequireESVersion<2>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA, UnsizedFormat(GL_LUMINANCE_ALPHA, RequireESVersion<2>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RED, UnsizedFormat(GL_RED, RequireESVersionOrExtension<3, &Extensions::textureRG>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RG, UnsizedFormat(GL_RG, RequireESVersionOrExtension<3, &Extensions::textureRG>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB, UnsizedFormat(GL_RGB, RequireESVersion<2>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA, UnsizedFormat(GL_RGBA, RequireESVersion<2>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RED_INTEGER, UnsizedFormat(GL_RED_INTEGER, RequireESVersion<3>, NeverSupported, NeverSupported )));
map.insert(InternalFormatInfoPair(GL_RG_INTEGER, UnsizedFormat(GL_RG_INTEGER, RequireESVersion<3>, NeverSupported, NeverSupported )));
map.insert(InternalFormatInfoPair(GL_RGB_INTEGER, UnsizedFormat(GL_RGB_INTEGER, RequireESVersion<3>, NeverSupported, NeverSupported )));
map.insert(InternalFormatInfoPair(GL_RGBA_INTEGER, UnsizedFormat(GL_RGBA_INTEGER, RequireESVersion<3>, NeverSupported, NeverSupported )));
map.insert(InternalFormatInfoPair(GL_BGRA_EXT, UnsizedFormat(GL_BGRA_EXT, RequireExtension<&Extensions::textureFormatBGRA8888>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT, UnsizedFormat(GL_DEPTH_COMPONENT, RequireESVersion<2>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_DEPTH_STENCIL, UnsizedFormat(GL_DEPTH_STENCIL, RequireESVersionOrExtension<3, &Extensions::packedDepthStencil>, AlwaysSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_SRGB_EXT, UnsizedFormat(GL_RGB, RequireESVersionOrExtension<3, &Extensions::sRGB>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_SRGB_ALPHA_EXT, UnsizedFormat(GL_RGBA, RequireESVersionOrExtension<3, &Extensions::sRGB>, AlwaysSupported, AlwaysSupported)));
// | Internal format | | Format | Supported | Renderable | Filterable |
map.insert(InternalFormatInfoPair(GL_ALPHA, UnsizedFormat(GL_ALPHA, RequireES<2>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE, UnsizedFormat(GL_LUMINANCE, RequireES<2>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA, UnsizedFormat(GL_LUMINANCE_ALPHA, RequireES<2>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RED, UnsizedFormat(GL_RED, RequireESOrExt<3, &Extensions::textureRG>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RG, UnsizedFormat(GL_RG, RequireESOrExt<3, &Extensions::textureRG>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGB, UnsizedFormat(GL_RGB, RequireES<2>, RequireES<2>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RGBA, UnsizedFormat(GL_RGBA, RequireES<2>, RequireES<2>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_RED_INTEGER, UnsizedFormat(GL_RED_INTEGER, RequireES<3>, NeverSupported, NeverSupported )));
map.insert(InternalFormatInfoPair(GL_RG_INTEGER, UnsizedFormat(GL_RG_INTEGER, RequireES<3>, NeverSupported, NeverSupported )));
map.insert(InternalFormatInfoPair(GL_RGB_INTEGER, UnsizedFormat(GL_RGB_INTEGER, RequireES<3>, NeverSupported, NeverSupported )));
map.insert(InternalFormatInfoPair(GL_RGBA_INTEGER, UnsizedFormat(GL_RGBA_INTEGER, RequireES<3>, NeverSupported, NeverSupported )));
map.insert(InternalFormatInfoPair(GL_BGRA_EXT, UnsizedFormat(GL_BGRA_EXT, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT, UnsizedFormat(GL_DEPTH_COMPONENT, RequireES<2>, RequireES<2>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_DEPTH_STENCIL, UnsizedFormat(GL_DEPTH_STENCIL, RequireESOrExt<3, &Extensions::packedDepthStencil>, RequireESOrExt<3, &Extensions::packedDepthStencil>, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_SRGB_EXT, UnsizedFormat(GL_RGB, RequireESOrExt<3, &Extensions::sRGB>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_SRGB_ALPHA_EXT, UnsizedFormat(GL_RGBA, RequireESOrExt<3, &Extensions::sRGB>, RequireESOrExt<3, &Extensions::sRGB>, AlwaysSupported)));
// Compressed formats, From ES 3.0.1 spec, table 3.16
// | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable |
@ -494,15 +501,15 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_UNSIGNED_BYTE, true, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
// From GL_EXT_texture_compression_dxt1
// | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable |
map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, RequireExtension<&Extensions::textureCompressionDXT1>, NeverSupported, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, CompressedFormat(4, 4, 64, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, RequireExtension<&Extensions::textureCompressionDXT1>, NeverSupported, AlwaysSupported )));
// | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable |
map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT1>, NeverSupported, AlwaysSupported)));
map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, CompressedFormat(4, 4, 64, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT1>, NeverSupported, AlwaysSupported)));
// From GL_ANGLE_texture_compression_dxt3
map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, false, RequireExtension<&Extensions::textureCompressionDXT5>, NeverSupported, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT5>, NeverSupported, AlwaysSupported)));
// From GL_ANGLE_texture_compression_dxt5
map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, false, RequireExtension<&Extensions::textureCompressionDXT5>, NeverSupported, AlwaysSupported )));
map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT5>, NeverSupported, AlwaysSupported)));
return map;
}

Просмотреть файл

@ -103,4 +103,4 @@ const FormatSet &GetAllSizedInternalFormats();
}
#endif LIBGLESV2_FORMATUTILS_H_
#endif // LIBGLESV2_FORMATUTILS_H_

Просмотреть файл

@ -110,7 +110,12 @@ void __stdcall glBeginQueryEXT(GLenum target, GLuint id)
return;
}
context->beginQuery(target, id);
gl::Error error = context->beginQuery(target, id);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -260,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);
}
}
@ -542,7 +536,12 @@ void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data,
return;
}
buffer->bufferData(data, size, usage);
gl::Error error = buffer->bufferData(data, size, usage);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -598,7 +597,12 @@ void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size,
return;
}
buffer->bufferSubData(data, size, offset);
gl::Error error = buffer->bufferSubData(data, size, offset);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -644,7 +648,12 @@ void __stdcall glClear(GLbitfield mask)
return;
}
context->clear(mask);
gl::Error error = context->clear(mask);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -757,7 +766,12 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
case GL_TEXTURE_2D:
{
gl::Texture2D *texture = context->getTexture2D();
texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
gl::Error error = texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
@ -769,7 +783,12 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data);
gl::Error error = texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
@ -817,7 +836,12 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
case GL_TEXTURE_2D:
{
gl::Texture2D *texture = context->getTexture2D();
texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
@ -829,7 +853,12 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
gl::Error error = texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
@ -1334,7 +1363,12 @@ void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count)
return;
}
context->drawArrays(mode, first, count, 0);
gl::Error error = context->drawArrays(mode, first, count, 0);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -1345,12 +1379,17 @@ void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei coun
gl::Context *context = gl::getNonLostContext();
if (context)
{
if (!ValidateDrawArraysInstanced(context, mode, first, count, primcount))
if (!ValidateDrawArraysInstancedANGLE(context, mode, first, count, primcount))
{
return;
}
context->drawArrays(mode, first, count, primcount);
gl::Error error = context->drawArrays(mode, first, count, primcount);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -1368,7 +1407,12 @@ void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLv
return;
}
context->drawElements(mode, count, type, indices, 0, indexRange);
gl::Error error = context->drawElements(mode, count, type, indices, 0, indexRange);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -1381,12 +1425,17 @@ void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum t
if (context)
{
rx::RangeUI indexRange;
if (!ValidateDrawElementsInstanced(context, mode, count, type, indices, primcount, &indexRange))
if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange))
{
return;
}
context->drawElements(mode, count, type, indices, primcount, indexRange);
gl::Error error = context->drawElements(mode, count, type, indices, primcount, indexRange);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -1436,7 +1485,12 @@ void __stdcall glEndQueryEXT(GLenum target)
return;
}
context->endQuery(target);
gl::Error error = context->endQuery(target);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -2360,7 +2414,7 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac
break;
case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
if (attachment == GL_DEPTH_STENCIL)
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
{
context->recordError(gl::Error(GL_INVALID_OPERATION));
return;
@ -2589,11 +2643,27 @@ void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
switch(pname)
{
case GL_QUERY_RESULT_EXT:
params[0] = queryObject->getResult();
{
gl::Error error = queryObject->getResult(params);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
case GL_QUERY_RESULT_AVAILABLE_EXT:
params[0] = queryObject->isResultAvailable();
{
gl::Error error = queryObject->isResultAvailable(params);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
default:
context->recordError(gl::Error(GL_INVALID_ENUM));
return;
@ -3678,7 +3748,12 @@ void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
return;
}
context->readPixels(x, y, width, height, format, type, &bufSize, data);
gl::Error error = context->readPixels(x, y, width, height, format, type, &bufSize, data);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -3704,7 +3779,12 @@ void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
return;
}
context->readPixels(x, y, width, height, format, type, NULL, pixels);
gl::Error error = context->readPixels(x, y, width, height, format, type, NULL, pixels);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -4085,45 +4165,32 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL
case GL_TEXTURE_2D:
{
gl::Texture2D *texture = context->getTexture2D();
texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
gl::Error error = texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->setImagePosX(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
}
break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->setImageNegX(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
}
break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->setImagePosY(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
}
break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->setImageNegY(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
}
break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->setImagePosZ(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
}
break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->setImageNegZ(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
gl::Error error = texture->setImage(target, level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
default: UNREACHABLE();
}
}
@ -4312,7 +4379,12 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
case GL_TEXTURE_2D:
{
gl::Texture2D *texture = context->getTexture2D();
texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
gl::Error error = texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
@ -4324,7 +4396,12 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
gl::Error error = texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
@ -4955,14 +5032,24 @@ void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GL
case GL_TEXTURE_3D:
{
gl::Texture3D *texture = context->getTexture3D();
texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
case GL_TEXTURE_2D_ARRAY:
{
gl::Texture2DArray *texture = context->getTexture2DArray();
texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
@ -5008,14 +5095,24 @@ void __stdcall glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint
case GL_TEXTURE_3D:
{
gl::Texture3D *texture = context->getTexture3D();
texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
case GL_TEXTURE_2D_ARRAY:
{
gl::Texture2DArray *texture = context->getTexture2DArray();
texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
@ -5103,14 +5200,24 @@ void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum interna
case GL_TEXTURE_3D:
{
gl::Texture3D *texture = context->getTexture3D();
texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
case GL_TEXTURE_2D_ARRAY:
{
gl::Texture2DArray *texture = context->getTexture2DArray();
texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
@ -5168,16 +5275,26 @@ void __stdcall glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffs
case GL_TEXTURE_3D:
{
gl::Texture3D *texture = context->getTexture3D();
texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
format, imageSize, data);
gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
format, imageSize, data);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
case GL_TEXTURE_2D_ARRAY:
{
gl::Texture2DArray *texture = context->getTexture2DArray();
texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
format, imageSize, data);
gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
format, imageSize, data);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
@ -5276,7 +5393,13 @@ void __stdcall glBeginQuery(GLenum target, GLuint id)
{
return;
}
context->beginQuery(target, id);
gl::Error error = context->beginQuery(target, id);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -5298,7 +5421,12 @@ void __stdcall glEndQuery(GLenum target)
return;
}
context->endQuery(target);
gl::Error error = context->endQuery(target);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -5363,12 +5491,26 @@ void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
switch(pname)
{
case GL_QUERY_RESULT:
params[0] = queryObject->getResult();
case GL_QUERY_RESULT_EXT:
{
gl::Error error = queryObject->getResult(params);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
case GL_QUERY_RESULT_AVAILABLE:
params[0] = queryObject->isResultAvailable();
case GL_QUERY_RESULT_AVAILABLE_EXT:
{
gl::Error error = queryObject->isResultAvailable(params);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
default:
@ -5559,8 +5701,13 @@ void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint sr
return;
}
context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
mask, filter);
gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
mask, filter);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -6588,7 +6735,12 @@ void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* val
return;
}
context->clearBufferiv(buffer, drawbuffer, value);
gl::Error error = context->clearBufferiv(buffer, drawbuffer, value);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -6620,7 +6772,12 @@ void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* v
return;
}
context->clearBufferuiv(buffer, drawbuffer, value);
gl::Error error = context->clearBufferuiv(buffer, drawbuffer, value);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -6660,7 +6817,12 @@ void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* v
return;
}
context->clearBufferfv(buffer, drawbuffer, value);
gl::Error error = context->clearBufferfv(buffer, drawbuffer, value);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -6692,7 +6854,12 @@ void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, G
return;
}
context->clearBufferfi(buffer, drawbuffer, depth, stencil);
gl::Error error = context->clearBufferfi(buffer, drawbuffer, depth, stencil);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -6780,7 +6947,12 @@ void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintp
// if size is zero, the copy is a successful no-op
if (size > 0)
{
writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
gl::Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
}
@ -8184,8 +8356,13 @@ void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLi
return;
}
context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
mask, filter);
gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
mask, filter);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
@ -8379,7 +8556,14 @@ void * __stdcall glMapBufferOES(GLenum target, GLenum access)
return NULL;
}
return buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
gl::Error error = buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
if (error.isError())
{
context->recordError(error);
return NULL;
}
return buffer->getMapPointer();
}
return NULL;
@ -8408,7 +8592,12 @@ GLboolean __stdcall glUnmapBufferOES(GLenum target)
// TODO: detect if we had corruption. if so, throw an error and return false.
buffer->unmap();
gl::Error error = buffer->unmap();
if (error.isError())
{
context->recordError(error);
return GL_FALSE;
}
return GL_TRUE;
}
@ -8498,7 +8687,14 @@ void* __stdcall glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr
return NULL;
}
return buffer->mapRange(offset, length, access);
gl::Error error = buffer->mapRange(offset, length, access);
if (error.isError())
{
context->recordError(error);
return NULL;
}
return buffer->getMapPointer();
}
return NULL;

Просмотреть файл

@ -10,6 +10,7 @@ UNIFIED_SOURCES += [
'../common/RefCountObject.cpp',
'../common/tls.cpp',
'../common/utilities.cpp',
'../common/win32/NativeWindow.cpp',
'../compiler/preprocessor/DiagnosticsBase.cpp',
'../compiler/preprocessor/DirectiveHandlerBase.cpp',
'../compiler/preprocessor/DirectiveParser.cpp',
@ -92,6 +93,7 @@ UNIFIED_SOURCES += [
'Framebuffer.cpp',
'FramebufferAttachment.cpp',
'HandleAllocator.cpp',
'ImageIndex.cpp',
'libGLESv2.cpp',
'main.cpp',
'Program.cpp',
@ -117,10 +119,12 @@ UNIFIED_SOURCES += [
'renderer/d3d/d3d9/VertexBuffer9.cpp',
'renderer/d3d/d3d9/VertexDeclarationCache.cpp',
'renderer/d3d/DynamicHLSL.cpp',
'renderer/d3d/HLSLCompiler.cpp',
'renderer/d3d/ImageD3D.cpp',
'renderer/d3d/IndexBuffer.cpp',
'renderer/d3d/IndexDataManager.cpp',
'renderer/d3d/MemoryBuffer.cpp',
'renderer/d3d/ProgramD3D.cpp',
'renderer/d3d/ShaderD3D.cpp',
'renderer/d3d/TextureD3D.cpp',
'renderer/d3d/TextureStorage.cpp',
@ -147,7 +151,6 @@ UNIFIED_SOURCES += [
SOURCES += [
'../compiler/translator/glslang_lex.cpp',
'../compiler/translator/glslang_tab.cpp',
'renderer/d3d/HLSLCompiler.cpp',
'renderer/loadimageSSE2.cpp',
]
SOURCES['renderer/loadimageSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
@ -213,7 +216,7 @@ LOCAL_INCLUDES += [ '../../include', '../../src' ]
if CONFIG['MOZ_HAS_WINSDK_WITH_D3D']:
OS_LIBS += [ 'd3d9', 'dxguid' ]
EXTRA_DSO_LDOPTS += [ 'd3d9.lib', 'dxguid.lib' ]
else:
EXTRA_DSO_LDOPTS += [
'\'%s/lib/%s/d3d9.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']),
@ -225,5 +228,5 @@ SharedLibrary('libGLESv2')
RCFILE = SRCDIR + '/libGLESv2.rc'
DEFFILE = SRCDIR + '/libGLESv2.def'
SOURCES['renderer/d3d/HLSLCompiler.cpp'].flags += ['-DANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES=\'{ TEXT("d3dcompiler_47.dll"), TEXT("d3dcompiler_46.dll"), TEXT("d3dcompiler_43.dll") }\'']
DEFINES['ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES'] = '{ TEXT("d3dcompiler_47.dll"), TEXT("d3dcompiler_46.dll"), TEXT("d3dcompiler_43.dll") }'

Просмотреть файл

@ -20,12 +20,12 @@ class BufferImpl
public:
virtual ~BufferImpl() { }
virtual void setData(const void* data, size_t size, GLenum usage) = 0;
virtual gl::Error setData(const void* data, size_t size, GLenum usage) = 0;
virtual void *getData() = 0;
virtual void setSubData(const void* data, size_t size, size_t offset) = 0;
virtual void copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) = 0;
virtual GLvoid* map(size_t offset, size_t length, GLbitfield access) = 0;
virtual void unmap() = 0;
virtual gl::Error setSubData(const void* data, size_t size, size_t offset) = 0;
virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) = 0;
virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr) = 0;
virtual gl::Error unmap() = 0;
virtual void markTransformFeedbackUsage() = 0;
};

Просмотреть файл

@ -4,7 +4,7 @@
// found in the LICENSE file.
//
// Image.h: Implements the rx::Image class, an abstract base class for the
// Image.h: Implements the rx::Image class, an abstract base class for the
// renderer-specific classes which will define the interface to the underlying
// surfaces or resources.
@ -15,7 +15,7 @@ namespace rx
Image::Image()
{
mWidth = 0;
mWidth = 0;
mHeight = 0;
mDepth = 0;
mInternalFormat = GL_NONE;

Просмотреть файл

@ -4,7 +4,7 @@
// found in the LICENSE file.
//
// Image.h: Defines the rx::Image class, an abstract base class for the
// Image.h: Defines the rx::Image class, an abstract base class for the
// renderer-specific classes which will define the interface to the underlying
// surfaces or resources.
@ -12,6 +12,7 @@
#define LIBGLESV2_RENDERER_IMAGE_H_
#include "common/debug.h"
#include "libGLESv2/Error.h"
#include <GLES2/gl2.h>
@ -45,10 +46,10 @@ class Image
virtual bool redefine(Renderer *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) = 0;
virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, GLenum type, const void *input) = 0;
virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input) = 0;
virtual gl::Error loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, GLenum type, const void *input) = 0;
virtual gl::Error loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input) = 0;
virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0;

Просмотреть файл

@ -61,4 +61,4 @@ class IndexRangeCache
}
#endif LIBGLESV2_RENDERER_INDEXRANGECACHE_H
#endif // LIBGLESV2_RENDERER_INDEXRANGECACHE_H

Просмотреть файл

@ -0,0 +1,60 @@
//
// Copyright 2014 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.
//
// ProgramImpl.h: Defines the abstract rx::ProgramImpl class.
#ifndef LIBGLESV2_RENDERER_PROGRAMIMPL_H_
#define LIBGLESV2_RENDERER_PROGRAMIMPL_H_
#include "common/angleutils.h"
#include "libGLESv2/BinaryStream.h"
#include "libGLESv2/Constants.h"
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/renderer/Renderer.h"
namespace rx
{
class Renderer;
class ProgramImpl
{
public:
virtual ~ProgramImpl() { }
virtual bool usesPointSize() const = 0;
virtual int getShaderVersion() const = 0;
virtual GLenum getTransformFeedbackBufferMode() const = 0;
virtual std::vector<gl::LinkedVarying> &getTransformFeedbackLinkedVaryings() = 0;
virtual sh::Attribute *getShaderAttributes() = 0;
virtual GLenum getBinaryFormat() = 0;
virtual bool load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) = 0;
virtual bool save(gl::BinaryOutputStream *stream) = 0;
virtual bool compileProgramExecutables(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader,
int registers) = 0;
virtual bool link(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader,
const std::vector<std::string> &transformFeedbackVaryings, GLenum transformFeedbackBufferMode,
int *registers, std::vector<gl::LinkedVarying> *linkedVaryings,
std::map<int, gl::VariableLocation> *outputVariables, const gl::Caps &caps) = 0;
virtual void initializeUniformStorage(const std::vector<gl::LinkedUniform*> &uniforms) = 0;
virtual gl::Error applyUniforms(const std::vector<gl::LinkedUniform*> &uniforms) = 0;
virtual gl::Error applyUniformBuffers(const std::vector<gl::UniformBlock*> uniformBlocks, const std::vector<gl::Buffer*> boundBuffers,
const gl::Caps &caps) = 0;
virtual bool assignUniformBlockRegister(gl::InfoLog &infoLog, gl::UniformBlock *uniformBlock, GLenum shader,
unsigned int registerIndex, const gl::Caps &caps) = 0;
virtual unsigned int getReservedUniformVectors(GLenum shader) = 0;
virtual void reset() = 0;
};
}
#endif // LIBGLESV2_RENDERER_PROGRAMIMPL_H_

Просмотреть файл

@ -9,6 +9,8 @@
#ifndef LIBGLESV2_RENDERER_QUERYIMPL_H_
#define LIBGLESV2_RENDERER_QUERYIMPL_H_
#include "libGLESv2/Error.h"
#include "common/angleutils.h"
#include <GLES2/gl2.h>
@ -22,10 +24,10 @@ class QueryImpl
explicit QueryImpl(GLenum type) { mType = type; }
virtual ~QueryImpl() { }
virtual bool begin() = 0;
virtual void end() = 0;
virtual GLuint getResult() = 0;
virtual GLboolean isResultAvailable() = 0;
virtual gl::Error begin() = 0;
virtual gl::Error end() = 0;
virtual gl::Error getResult(GLuint *params) = 0;
virtual gl::Error isResultAvailable(GLuint *available) = 0;
GLenum getType() const { return mType; }

Просмотреть файл

@ -21,6 +21,10 @@
#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
#endif // ANGLE_ENABLE_D3D11
#if defined (ANGLE_TEST_CONFIG)
#define ANGLE_DEFAULT_D3D11 1
#endif
#if !defined(ANGLE_DEFAULT_D3D11)
// Enables use of the Direct3D 11 API for a default display, when available
#define ANGLE_DEFAULT_D3D11 0
@ -34,6 +38,7 @@ namespace rx
Renderer::Renderer(egl::Display *display)
: mDisplay(display),
mCapsInitialized(false),
mWorkaroundsInitialized(false),
mCurrentClientVersion(2)
{
}
@ -75,6 +80,17 @@ const gl::Extensions &Renderer::getRendererExtensions() const
return mExtensions;
}
const Workarounds &Renderer::getWorkarounds() const
{
if (!mWorkaroundsInitialized)
{
mWorkarounds = generateWorkarounds();
mWorkaroundsInitialized = true;
}
return mWorkarounds;
}
typedef Renderer *(*CreateRendererFunction)(egl::Display*, EGLNativeDisplayType, EGLint);
template <typename RendererType>

Просмотреть файл

@ -13,6 +13,9 @@
#include "libGLESv2/Uniform.h"
#include "libGLESv2/angletypes.h"
#include "libGLESv2/Caps.h"
#include "common/NativeWindow.h"
#include "libGLESv2/Error.h"
#include "libGLESv2/renderer/Workarounds.h"
#include <cstdint>
@ -43,10 +46,7 @@ struct VertexAttribCurrentValueData;
namespace rx
{
class TextureStorageInterface2D;
class TextureStorageInterfaceCube;
class TextureStorageInterface3D;
class TextureStorageInterface2DArray;
class TextureStorage;
class VertexBuffer;
class IndexBuffer;
class QueryImpl;
@ -56,6 +56,7 @@ class VertexArrayImpl;
class BufferStorage;
struct TranslatedIndexData;
class ShaderImpl;
class ProgramImpl;
class ShaderExecutable;
class SwapChain;
class RenderTarget;
@ -108,39 +109,39 @@ class Renderer
virtual void sync(bool block) = 0;
virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) = 0;
virtual SwapChain *createSwapChain(rx::NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) = 0;
virtual void generateSwizzle(gl::Texture *texture) = 0;
virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler) = 0;
virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture) = 0;
virtual gl::Error generateSwizzle(gl::Texture *texture) = 0;
virtual gl::Error setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler) = 0;
virtual gl::Error setTexture(gl::SamplerType type, int index, gl::Texture *texture) = 0;
virtual bool setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]) = 0;
virtual gl::Error setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]) = 0;
virtual void setRasterizerState(const gl::RasterizerState &rasterState) = 0;
virtual void setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor,
unsigned int sampleMask) = 0;
virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW) = 0;
virtual gl::Error setRasterizerState(const gl::RasterizerState &rasterState) = 0;
virtual gl::Error setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor,
unsigned int sampleMask) = 0;
virtual gl::Error setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW) = 0;
virtual void setScissorRectangle(const gl::Rectangle &scissor, bool enabled) = 0;
virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace,
virtual void setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace,
bool ignoreViewport) = 0;
virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer) = 0;
virtual void applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
bool rasterizerDiscard, bool transformFeedbackActive) = 0;
virtual void applyUniforms(const gl::ProgramBinary &programBinary) = 0;
virtual gl::Error applyRenderTarget(gl::Framebuffer *frameBuffer) = 0;
virtual gl::Error applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
bool rasterizerDiscard, bool transformFeedbackActive) = 0;
virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray) = 0;
virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount) = 0;
virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], const gl::VertexAttribCurrentValueData currentValues[],
GLint first, GLsizei count, GLsizei instances) = 0;
virtual GLenum applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo) = 0;
virtual gl::Error applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], const gl::VertexAttribCurrentValueData currentValues[],
GLint first, GLsizei count, GLsizei instances) = 0;
virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo) = 0;
virtual void applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[]) = 0;
virtual void drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive) = 0;
virtual void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances) = 0;
virtual gl::Error drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive) = 0;
virtual gl::Error drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances) = 0;
virtual void clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer) = 0;
virtual gl::Error clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer) = 0;
virtual void markAllStateDirty() = 0;
@ -171,24 +172,20 @@ class Renderer
virtual int getMaxSwapInterval() const = 0;
// Pixel operations
virtual bool copyToRenderTarget(TextureStorageInterface2D *dest, TextureStorageInterface2D *source) = 0;
virtual bool copyToRenderTarget(TextureStorageInterfaceCube *dest, TextureStorageInterfaceCube *source) = 0;
virtual bool copyToRenderTarget(TextureStorageInterface3D *dest, TextureStorageInterface3D *source) = 0;
virtual bool copyToRenderTarget(TextureStorageInterface2DArray *dest, TextureStorageInterface2DArray *source) = 0;
virtual gl::Error copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level) = 0;
virtual gl::Error copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level) = 0;
virtual gl::Error copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level) = 0;
virtual gl::Error copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level) = 0;
virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorageInterface2D *storage, GLint level) = 0;
virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level) = 0;
virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface3D *storage, GLint level) = 0;
virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface2DArray *storage, GLint level) = 0;
virtual gl::Error blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter) = 0;
virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter) = 0;
virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels) = 0;
virtual gl::Error readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels) = 0;
// RenderTarget creation
virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth) = 0;
@ -196,13 +193,14 @@ class Renderer
// Shader creation
virtual ShaderImpl *createShader(GLenum type) = 0;
virtual ProgramImpl *createProgram() = 0;
// Shader operations
virtual void releaseShaderCompiler() = 0;
virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type,
const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
bool separatedOutputBuffers) = 0;
virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type,
virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const std::string &shaderHLSL, rx::ShaderType type,
const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
bool separatedOutputBuffers, D3DWorkaroundType workaround) = 0;
virtual UniformStorage *createUniformStorage(size_t storageSize) = 0;
@ -240,13 +238,15 @@ class Renderer
// Buffer-to-texture and Texture-to-buffer copies
virtual bool supportsFastCopyBufferToTexture(GLenum internalFormat) const = 0;
virtual bool fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea) = 0;
virtual gl::Error fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea) = 0;
virtual bool getLUID(LUID *adapterLuid) const = 0;
virtual rx::VertexConversionType getVertexConversionType(const gl::VertexFormat &vertexFormat) const = 0;
virtual GLenum getVertexComponentType(const gl::VertexFormat &vertexFormat) const = 0;
const Workarounds &getWorkarounds() const;
protected:
egl::Display *mDisplay;
@ -254,12 +254,16 @@ class Renderer
DISALLOW_COPY_AND_ASSIGN(Renderer);
virtual void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap* outTextureCaps, gl::Extensions *outExtensions) const = 0;
virtual Workarounds generateWorkarounds() const = 0;
mutable bool mCapsInitialized;
mutable gl::Caps mCaps;
mutable gl::TextureCapsMap mTextureCaps;
mutable gl::Extensions mExtensions;
mutable bool mWorkaroundsInitialized;
mutable Workarounds mWorkarounds;
int mCurrentClientVersion;
};

Просмотреть файл

@ -9,7 +9,10 @@
#ifndef LIBGLESV2_RENDERER_SHADERIMPL_H_
#define LIBGLESV2_RENDERER_SHADERIMPL_H_
#include <vector>
#include "common/angleutils.h"
#include "libGLESv2/Shader.h"
namespace rx
{
@ -17,11 +20,33 @@ namespace rx
class ShaderImpl
{
public:
ShaderImpl() { }
virtual ~ShaderImpl() { }
virtual bool compile(const std::string &source) = 0;
virtual const std::string &getInfoLog() const = 0;
virtual const std::string &getTranslatedSource() const = 0;
const std::vector<gl::PackedVarying> &getVaryings() const { return mVaryings; }
const std::vector<sh::Uniform> &getUniforms() const { return mUniforms; }
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return mInterfaceBlocks; }
const std::vector<sh::Attribute> &getActiveAttributes() const { return mActiveAttributes; }
const std::vector<sh::Attribute> &getActiveOutputVariables() const { return mActiveOutputVariables; }
std::vector<gl::PackedVarying> &getVaryings() { return mVaryings; }
std::vector<sh::Uniform> &getUniforms() { return mUniforms; }
std::vector<sh::InterfaceBlock> &getInterfaceBlocks() { return mInterfaceBlocks; }
std::vector<sh::Attribute> &getActiveAttributes() { return mActiveAttributes; }
std::vector<sh::Attribute> &getActiveOutputVariables() { return mActiveOutputVariables; }
protected:
DISALLOW_COPY_AND_ASSIGN(ShaderImpl);
std::vector<gl::PackedVarying> mVaryings;
std::vector<sh::Uniform> mUniforms;
std::vector<sh::InterfaceBlock> mInterfaceBlocks;
std::vector<sh::Attribute> mActiveAttributes;
std::vector<sh::Attribute> mActiveOutputVariables;
};
}

Просмотреть файл

@ -11,6 +11,7 @@
#define LIBGLESV2_RENDERER_SWAPCHAIN_H_
#include "common/angleutils.h"
#include "common/NativeWindow.h"
#include "common/platform.h"
#include <GLES2/gl2.h>
@ -26,8 +27,8 @@ namespace rx
class SwapChain
{
public:
SwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat)
: mWindow(window), mShareHandle(shareHandle), mBackBufferFormat(backBufferFormat), mDepthBufferFormat(depthBufferFormat)
SwapChain(rx::NativeWindow nativeWindow, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat)
: mNativeWindow(nativeWindow), mShareHandle(shareHandle), mBackBufferFormat(backBufferFormat), mDepthBufferFormat(depthBufferFormat)
{
}
@ -41,7 +42,7 @@ class SwapChain
virtual HANDLE getShareHandle() {return mShareHandle;};
protected:
const HWND mWindow; // Window that the surface is created for.
rx::NativeWindow mNativeWindow; // Handler for the Window that the surface is created for.
const GLenum mBackBufferFormat;
const GLenum mDepthBufferFormat;

Просмотреть файл

@ -10,9 +10,12 @@
#define LIBGLESV2_RENDERER_TEXTUREIMPL_H_
#include "common/angleutils.h"
#include "libGLESv2/Error.h"
#include "angle_gl.h"
#include "libGLESv2/ImageIndex.h"
namespace egl
{
class Surface;
@ -29,9 +32,8 @@ namespace rx
{
class Image;
class RenderTarget;
class Renderer;
class TextureStorageInterface;
class TextureStorage;
class TextureImpl
{
@ -41,26 +43,25 @@ class TextureImpl
// TODO: If this methods could go away that would be ideal;
// TextureStorage should only be necessary for the D3D backend, and as such
// higher level code should not rely on it.
virtual TextureStorageInterface *getNativeTexture() = 0;
virtual TextureStorage *getNativeTexture() = 0;
// Deprecated in favour of the ImageIndex method
virtual Image *getImage(int level, int layer) const = 0;
virtual Image *getImage(const gl::ImageIndex &index) const = 0;
virtual GLsizei getLayerCount(int level) const = 0;
virtual void setUsage(GLenum usage) = 0;
virtual void setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) = 0;
virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels) = 0;
virtual void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) = 0;
virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels) = 0;
virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) = 0;
virtual gl::Error setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels) = 0;
virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) = 0;
virtual gl::Error subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels) = 0;
virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0;
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0;
virtual void storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) = 0;
virtual void generateMipmaps() = 0;
virtual unsigned int getRenderTargetSerial(GLint level, GLint layer) = 0;
virtual RenderTarget *getRenderTarget(GLint level, GLint layer) = 0;
virtual void bindTexImage(egl::Surface *surface) = 0;
virtual void releaseTexImage() = 0;
};

Просмотреть файл

@ -0,0 +1,37 @@
//
// Copyright (c) 2014 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.
//
// angletypes.h: Workarounds for driver bugs and other issues.
#ifndef LIBGLESV2_RENDERER_WORKAROUNDS_H_
#define LIBGLESV2_RENDERER_WORKAROUNDS_H_
// TODO(jmadill,zmo,geofflang): make a workarounds library that can operate
// independent of ANGLE's renderer. Workarounds should also be accessible
// outside of the Renderer.
namespace rx
{
enum D3DWorkaroundType
{
ANGLE_D3D_WORKAROUND_NONE,
ANGLE_D3D_WORKAROUND_SKIP_OPTIMIZATION,
ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION
};
struct Workarounds
{
Workarounds()
: mrtPerfWorkaround(false)
{}
bool mrtPerfWorkaround;
};
}
#endif // LIBGLESV2_RENDERER_WORKAROUNDS_H_

Просмотреть файл

@ -22,7 +22,7 @@ META_ASSERT(GL_INVALID_INDEX == UINT_MAX);
using namespace gl;
namespace gl_d3d
namespace
{
std::string HLSLComponentTypeString(GLenum componentType)
@ -70,6 +70,21 @@ std::string HLSLTypeString(GLenum type)
return HLSLComponentTypeString(gl::VariableComponentType(type), gl::VariableComponentCount(type));
}
const rx::PixelShaderOutputVariable &GetOutputAtLocation(const std::vector<rx::PixelShaderOutputVariable> &outputVariables,
unsigned int location)
{
for (size_t variableIndex = 0; variableIndex < outputVariables.size(); ++variableIndex)
{
if (outputVariables[variableIndex].outputIndex == location)
{
return outputVariables[variableIndex];
}
}
UNREACHABLE();
return outputVariables[0];
}
}
namespace rx
@ -111,6 +126,7 @@ static bool packVarying(PackedVarying *varying, const int maxVaryingVectors, Var
if (available)
{
varying->registerIndex = r;
varying->columnIndex = 0;
for (int y = 0; y < registers; y++)
{
@ -144,6 +160,7 @@ static bool packVarying(PackedVarying *varying, const int maxVaryingVectors, Var
if (available)
{
varying->registerIndex = r;
varying->columnIndex = 2;
for (int y = 0; y < registers; y++)
{
@ -174,7 +191,7 @@ static bool packVarying(PackedVarying *varying, const int maxVaryingVectors, Var
for (int x = 0; x < 4; x++)
{
if (space[x] >= registers && space[x] < space[column])
if (space[x] >= registers && (space[column] < registers || space[x] < space[column]))
{
column = x;
}
@ -187,6 +204,7 @@ static bool packVarying(PackedVarying *varying, const int maxVaryingVectors, Var
if (!packing[r][column])
{
varying->registerIndex = r;
varying->columnIndex = column;
for (int y = r; y < r + registers; y++)
{
@ -207,8 +225,8 @@ static bool packVarying(PackedVarying *varying, const int maxVaryingVectors, Var
// Packs varyings into generic varying registers, using the algorithm from [OpenGL ES Shading Language 1.00 rev. 17] appendix A section 7 page 111
// Returns the number of used varying registers, or -1 if unsuccesful
int DynamicHLSL::packVaryings(InfoLog &infoLog, VaryingPacking packing, rx::FragmentShaderD3D *fragmentShader,
rx::VertexShaderD3D *vertexShader, const std::vector<std::string>& transformFeedbackVaryings)
int DynamicHLSL::packVaryings(InfoLog &infoLog, VaryingPacking packing, rx::ShaderD3D *fragmentShader,
rx::ShaderD3D *vertexShader, const std::vector<std::string>& transformFeedbackVaryings)
{
// TODO (geofflang): Use context's caps
const int maxVaryingVectors = mRenderer->getRendererCaps().maxVaryingVectors;
@ -218,9 +236,18 @@ int DynamicHLSL::packVaryings(InfoLog &infoLog, VaryingPacking packing, rx::Frag
std::set<std::string> packedVaryings;
for (unsigned int varyingIndex = 0; varyingIndex < fragmentShader->mVaryings.size(); varyingIndex++)
std::vector<gl::PackedVarying> &fragmentVaryings = fragmentShader->getVaryings();
std::vector<gl::PackedVarying> &vertexVaryings = vertexShader->getVaryings();
for (unsigned int varyingIndex = 0; varyingIndex < fragmentVaryings.size(); varyingIndex++)
{
PackedVarying *varying = &fragmentShader->mVaryings[varyingIndex];
PackedVarying *varying = &fragmentVaryings[varyingIndex];
// Do not assign registers to built-in or unreferenced varyings
if (varying->isBuiltIn() || !varying->staticUse)
{
continue;
}
if (packVarying(varying, maxVaryingVectors, packing))
{
packedVaryings.insert(varying->name);
@ -238,9 +265,9 @@ int DynamicHLSL::packVaryings(InfoLog &infoLog, VaryingPacking packing, rx::Frag
if (packedVaryings.find(transformFeedbackVarying) == packedVaryings.end())
{
bool found = false;
for (unsigned int varyingIndex = 0; varyingIndex < vertexShader->mVaryings.size(); varyingIndex++)
for (unsigned int varyingIndex = 0; varyingIndex < vertexVaryings.size(); varyingIndex++)
{
PackedVarying *varying = &vertexShader->mVaryings[varyingIndex];
PackedVarying *varying = &vertexVaryings[varyingIndex];
if (transformFeedbackVarying == varying->name)
{
if (!packVarying(varying, maxVaryingVectors, packing))
@ -276,16 +303,19 @@ int DynamicHLSL::packVaryings(InfoLog &infoLog, VaryingPacking packing, rx::Frag
return registers;
}
std::string DynamicHLSL::generateVaryingHLSL(rx::VertexShaderD3D *shader) const
std::string DynamicHLSL::generateVaryingHLSL(const ShaderD3D *shader) const
{
std::string varyingSemantic = getVaryingSemantic(shader->mUsesPointSize);
std::string varyingHLSL;
for (unsigned int varyingIndex = 0; varyingIndex < shader->mVaryings.size(); varyingIndex++)
const std::vector<gl::PackedVarying> &varyings = shader->getVaryings();
for (unsigned int varyingIndex = 0; varyingIndex < varyings.size(); varyingIndex++)
{
const PackedVarying &varying = shader->mVaryings[varyingIndex];
const PackedVarying &varying = varyings[varyingIndex];
if (varying.registerAssigned())
{
ASSERT(!varying.isBuiltIn());
GLenum transposedType = TransposeMatrixType(varying.type);
int variableRows = (varying.isStruct() ? 1 : VariableRowCount(transposedType));
@ -293,6 +323,10 @@ std::string DynamicHLSL::generateVaryingHLSL(rx::VertexShaderD3D *shader) const
{
for (int row = 0; row < variableRows; row++)
{
// TODO: Add checks to ensure D3D interpolation modifiers don't result in too many registers being used.
// For example, if there are N registers, and we have N vec3 varyings and 1 float varying, then D3D will pack them into N registers.
// If the float varying has the 'nointerpolation' modifier on it then we would need N + 1 registers, and D3D compilation will fail.
switch (varying.interpolation)
{
case sh::INTERPOLATION_SMOOTH: varyingHLSL += " "; break;
@ -301,7 +335,7 @@ std::string DynamicHLSL::generateVaryingHLSL(rx::VertexShaderD3D *shader) const
default: UNREACHABLE();
}
unsigned int semanticIndex = elementIndex * variableRows + varying.registerIndex + row;
unsigned int semanticIndex = elementIndex * variableRows + varying.columnIndex * mRenderer->getRendererCaps().maxVaryingVectors + varying.registerIndex + row;
std::string n = Str(semanticIndex);
std::string typeString;
@ -316,7 +350,7 @@ std::string DynamicHLSL::generateVaryingHLSL(rx::VertexShaderD3D *shader) const
{
GLenum componentType = VariableComponentType(transposedType);
int columnCount = VariableColumnCount(transposedType);
typeString = gl_d3d::HLSLComponentTypeString(componentType, columnCount);
typeString = HLSLComponentTypeString(componentType, columnCount);
}
varyingHLSL += typeString + " v" + n + " : " + varyingSemantic + n + ";\n";
}
@ -338,23 +372,22 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &s
for (unsigned int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
{
ASSERT(inputIndex < MAX_VERTEX_ATTRIBS);
const VertexFormat &vertexFormat = inputLayout[inputIndex];
const sh::Attribute &shaderAttribute = shaderAttributes[attributeIndex];
if (!shaderAttribute.name.empty())
{
ASSERT(inputIndex < MAX_VERTEX_ATTRIBS);
const VertexFormat &vertexFormat = inputLayout[inputIndex];
// HLSL code for input structure
if (IsMatrixType(shaderAttribute.type))
{
// Matrix types are always transposed
structHLSL += " " + gl_d3d::HLSLMatrixTypeString(TransposeMatrixType(shaderAttribute.type));
structHLSL += " " + HLSLMatrixTypeString(TransposeMatrixType(shaderAttribute.type));
}
else
{
GLenum componentType = mRenderer->getVertexComponentType(vertexFormat);
structHLSL += " " + gl_d3d::HLSLComponentTypeString(componentType, VariableComponentCount(shaderAttribute.type));
structHLSL += " " + HLSLComponentTypeString(componentType, VariableComponentCount(shaderAttribute.type));
}
structHLSL += " " + decorateVariable(shaderAttribute.name) + " : TEXCOORD" + Str(semanticIndex) + ";\n";
@ -400,7 +433,7 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &s
return vertexHLSL;
}
std::string DynamicHLSL::generatePixelShaderForOutputSignature(const std::string &sourceShader, const std::vector<PixelShaderOuputVariable> &outputVariables,
std::string DynamicHLSL::generatePixelShaderForOutputSignature(const std::string &sourceShader, const std::vector<PixelShaderOutputVariable> &outputVariables,
bool usesFragDepth, const std::vector<GLenum> &outputLayout) const
{
const int shaderModel = mRenderer->getMajorShaderModel();
@ -409,17 +442,19 @@ std::string DynamicHLSL::generatePixelShaderForOutputSignature(const std::string
std::string declarationHLSL;
std::string copyHLSL;
for (size_t i = 0; i < outputVariables.size(); i++)
{
const PixelShaderOuputVariable& outputVariable = outputVariables[i];
ASSERT(outputLayout.size() > outputVariable.outputIndex);
// FIXME(geofflang): Work around NVIDIA driver bug by repacking buffers
bool outputIndexEnabled = true; // outputLayout[outputVariable.outputIndex] != GL_NONE
if (outputIndexEnabled)
for (size_t layoutIndex = 0; layoutIndex < outputLayout.size(); ++layoutIndex)
{
GLenum binding = outputLayout[layoutIndex];
if (binding != GL_NONE)
{
declarationHLSL += " " + gl_d3d::HLSLTypeString(outputVariable.type) + " " + outputVariable.name +
" : " + targetSemantic + Str(outputVariable.outputIndex) + ";\n";
unsigned int location = (binding - GL_COLOR_ATTACHMENT0);
const PixelShaderOutputVariable &outputVariable = GetOutputAtLocation(outputVariables, location);
declarationHLSL += " " + HLSLTypeString(outputVariable.type) + " " + outputVariable.name +
" : " + targetSemantic + Str(layoutIndex) + ";\n";
copyHLSL += " output." + outputVariable.name + " = " + outputVariable.source + ";\n";
}
@ -604,17 +639,19 @@ void DynamicHLSL::storeBuiltinLinkedVaryings(const SemanticInfo &info,
}
}
void DynamicHLSL::storeUserLinkedVaryings(const rx::VertexShaderD3D *vertexShader,
void DynamicHLSL::storeUserLinkedVaryings(const rx::ShaderD3D *vertexShader,
std::vector<LinkedVarying> *linkedVaryings) const
{
const std::string &varyingSemantic = getVaryingSemantic(vertexShader->mUsesPointSize);
const std::vector<PackedVarying> &varyings = vertexShader->mVaryings;
const std::vector<PackedVarying> &varyings = vertexShader->getVaryings();
for (unsigned int varyingIndex = 0; varyingIndex < varyings.size(); varyingIndex++)
{
const PackedVarying &varying = varyings[varyingIndex];
if (varying.registerAssigned())
{
ASSERT(!varying.isBuiltIn());
GLenum transposedType = TransposeMatrixType(varying.type);
int variableRows = (varying.isStruct() ? 1 : VariableRowCount(transposedType));
@ -627,11 +664,11 @@ void DynamicHLSL::storeUserLinkedVaryings(const rx::VertexShaderD3D *vertexShade
bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const VaryingPacking packing,
std::string& pixelHLSL, std::string& vertexHLSL,
rx::FragmentShaderD3D *fragmentShader, rx::VertexShaderD3D *vertexShader,
rx::ShaderD3D *fragmentShader, rx::ShaderD3D *vertexShader,
const std::vector<std::string>& transformFeedbackVaryings,
std::vector<LinkedVarying> *linkedVaryings,
std::map<int, VariableLocation> *programOutputVars,
std::vector<PixelShaderOuputVariable> *outPixelShaderKey,
std::vector<PixelShaderOutputVariable> *outPixelShaderKey,
bool *outUsesFragDepth) const
{
if (pixelHLSL.empty() || vertexHLSL.empty())
@ -723,9 +760,10 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
vertexHLSL += " output.gl_FragCoord = gl_Position;\n";
}
for (unsigned int vertVaryingIndex = 0; vertVaryingIndex < vertexShader->mVaryings.size(); vertVaryingIndex++)
const std::vector<PackedVarying> &vertexVaryings = vertexShader->getVaryings();
for (unsigned int vertVaryingIndex = 0; vertVaryingIndex < vertexVaryings.size(); vertVaryingIndex++)
{
const PackedVarying &varying = vertexShader->mVaryings[vertVaryingIndex];
const PackedVarying &varying = vertexVaryings[vertVaryingIndex];
if (varying.registerAssigned())
{
for (unsigned int elementIndex = 0; elementIndex < varying.elementCount(); elementIndex++)
@ -734,39 +772,9 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
for (int row = 0; row < variableRows; row++)
{
int r = varying.registerIndex + elementIndex * variableRows + row;
int r = varying.registerIndex + varying.columnIndex * mRenderer->getRendererCaps().maxVaryingVectors + elementIndex * variableRows + row;
vertexHLSL += " output.v" + Str(r);
bool sharedRegister = false; // Register used by multiple varyings
for (int x = 0; x < 4; x++)
{
if (packing[r][x] && packing[r][x] != packing[r][0])
{
sharedRegister = true;
break;
}
}
if(sharedRegister)
{
vertexHLSL += ".";
for (int x = 0; x < 4; x++)
{
if (packing[r][x] == &varying)
{
switch(x)
{
case 0: vertexHLSL += "x"; break;
case 1: vertexHLSL += "y"; break;
case 2: vertexHLSL += "z"; break;
case 3: vertexHLSL += "w"; break;
}
}
}
}
vertexHLSL += " = _" + varying.name;
if (varying.isArray())
@ -798,7 +806,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
{
for (unsigned int renderTargetIndex = 0; renderTargetIndex < numRenderTargets; renderTargetIndex++)
{
PixelShaderOuputVariable outputKeyVariable;
PixelShaderOutputVariable outputKeyVariable;
outputKeyVariable.type = GL_FLOAT_VEC4;
outputKeyVariable.name = "gl_Color" + Str(renderTargetIndex);
outputKeyVariable.source = broadcast ? "gl_Color[0]" : "gl_Color[" + Str(renderTargetIndex) + "]";
@ -813,7 +821,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
{
defineOutputVariables(fragmentShader, programOutputVars);
const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getActiveOutputVariables();
for (auto locationIt = programOutputVars->begin(); locationIt != programOutputVars->end(); locationIt++)
{
const VariableLocation &outputLocation = locationIt->second;
@ -821,7 +829,9 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
const std::string &variableName = "out_" + outputLocation.name;
const std::string &elementString = (outputLocation.element == GL_INVALID_INDEX ? "" : Str(outputLocation.element));
PixelShaderOuputVariable outputKeyVariable;
ASSERT(outputVariable.staticUse);
PixelShaderOutputVariable outputKeyVariable;
outputKeyVariable.type = outputVariable.type;
outputKeyVariable.name = variableName + elementString;
outputKeyVariable.source = variableName + ArrayString(outputLocation.element);
@ -897,18 +907,20 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
}
}
for (unsigned int varyingIndex = 0; varyingIndex < fragmentShader->mVaryings.size(); varyingIndex++)
const std::vector<PackedVarying> &fragmentVaryings = fragmentShader->getVaryings();
for (unsigned int varyingIndex = 0; varyingIndex < fragmentVaryings.size(); varyingIndex++)
{
const PackedVarying &varying = fragmentShader->mVaryings[varyingIndex];
const PackedVarying &varying = fragmentVaryings[varyingIndex];
if (varying.registerAssigned())
{
ASSERT(!varying.isBuiltIn());
for (unsigned int elementIndex = 0; elementIndex < varying.elementCount(); elementIndex++)
{
GLenum transposedType = TransposeMatrixType(varying.type);
int variableRows = (varying.isStruct() ? 1 : VariableRowCount(transposedType));
for (int row = 0; row < variableRows; row++)
{
std::string n = Str(varying.registerIndex + elementIndex * variableRows + row);
std::string n = Str(varying.registerIndex + varying.columnIndex * mRenderer->getRendererCaps().maxVaryingVectors + elementIndex * variableRows + row);
pixelHLSL += " _" + varying.name;
if (varying.isArray())
@ -939,7 +951,10 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
}
}
}
else UNREACHABLE();
else
{
ASSERT(varying.isBuiltIn() || !varying.staticUse);
}
}
pixelHLSL += "\n"
@ -951,15 +966,17 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
return true;
}
void DynamicHLSL::defineOutputVariables(rx::FragmentShaderD3D *fragmentShader, std::map<int, VariableLocation> *programOutputVars) const
void DynamicHLSL::defineOutputVariables(rx::ShaderD3D *fragmentShader, std::map<int, VariableLocation> *programOutputVars) const
{
const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getActiveOutputVariables();
for (unsigned int outputVariableIndex = 0; outputVariableIndex < shaderOutputVars.size(); outputVariableIndex++)
{
const sh::Attribute &outputVariable = shaderOutputVars[outputVariableIndex];
const int baseLocation = outputVariable.location == -1 ? 0 : outputVariable.location;
ASSERT(outputVariable.staticUse);
if (outputVariable.arraySize > 0)
{
for (unsigned int elementIndex = 0; elementIndex < outputVariable.arraySize; elementIndex++)
@ -977,14 +994,14 @@ void DynamicHLSL::defineOutputVariables(rx::FragmentShaderD3D *fragmentShader, s
}
}
std::string DynamicHLSL::generateGeometryShaderHLSL(int registers, rx::FragmentShaderD3D *fragmentShader, rx::VertexShaderD3D *vertexShader) const
std::string DynamicHLSL::generateGeometryShaderHLSL(int registers, rx::ShaderD3D *fragmentShader, rx::ShaderD3D *vertexShader) const
{
// for now we only handle point sprite emulation
ASSERT(vertexShader->mUsesPointSize && mRenderer->getMajorShaderModel() >= 4);
return generatePointSpriteHLSL(registers, fragmentShader, vertexShader);
}
std::string DynamicHLSL::generatePointSpriteHLSL(int registers, rx::FragmentShaderD3D *fragmentShader, rx::VertexShaderD3D *vertexShader) const
std::string DynamicHLSL::generatePointSpriteHLSL(int registers, rx::ShaderD3D *fragmentShader, rx::ShaderD3D *vertexShader) const
{
ASSERT(registers >= 0);
ASSERT(vertexShader->mUsesPointSize);

Просмотреть файл

@ -42,12 +42,10 @@ namespace rx
{
class Renderer;
class ShaderD3D;
class VertexShaderD3D;
class FragmentShaderD3D;
typedef const gl::PackedVarying *VaryingPacking[gl::IMPLEMENTATION_MAX_VARYING_VECTORS][4];
struct PixelShaderOuputVariable
struct PixelShaderOutputVariable
{
GLenum type;
std::string name;
@ -60,22 +58,22 @@ class DynamicHLSL
public:
explicit DynamicHLSL(rx::Renderer *const renderer);
int packVaryings(gl::InfoLog &infoLog, VaryingPacking packing, rx::FragmentShaderD3D *fragmentShader,
rx::VertexShaderD3D *vertexShader, const std::vector<std::string>& transformFeedbackVaryings);
int packVaryings(gl::InfoLog &infoLog, VaryingPacking packing, rx::ShaderD3D *fragmentShader,
rx::ShaderD3D *vertexShader, const std::vector<std::string>& transformFeedbackVaryings);
std::string generateVertexShaderForInputLayout(const std::string &sourceShader, const gl::VertexFormat inputLayout[],
const sh::Attribute shaderAttributes[]) const;
std::string generatePixelShaderForOutputSignature(const std::string &sourceShader, const std::vector<PixelShaderOuputVariable> &outputVariables,
std::string generatePixelShaderForOutputSignature(const std::string &sourceShader, const std::vector<PixelShaderOutputVariable> &outputVariables,
bool usesFragDepth, const std::vector<GLenum> &outputLayout) const;
bool generateShaderLinkHLSL(gl::InfoLog &infoLog, int registers, const VaryingPacking packing,
std::string& pixelHLSL, std::string& vertexHLSL,
rx::FragmentShaderD3D *fragmentShader, rx::VertexShaderD3D *vertexShader,
rx::ShaderD3D *fragmentShader, rx::ShaderD3D *vertexShader,
const std::vector<std::string>& transformFeedbackVaryings,
std::vector<gl::LinkedVarying> *linkedVaryings,
std::map<int, gl::VariableLocation> *programOutputVars,
std::vector<PixelShaderOuputVariable> *outPixelShaderKey,
std::vector<PixelShaderOutputVariable> *outPixelShaderKey,
bool *outUsesFragDepth) const;
std::string generateGeometryShaderHLSL(int registers, rx::FragmentShaderD3D *fragmentShader, rx::VertexShaderD3D *vertexShader) const;
std::string generateGeometryShaderHLSL(int registers, rx::ShaderD3D *fragmentShader, rx::ShaderD3D *vertexShader) const;
void getInputLayoutSignature(const gl::VertexFormat inputLayout[], GLenum signature[]) const;
private:
@ -89,11 +87,11 @@ class DynamicHLSL
SemanticInfo getSemanticInfo(int startRegisters, bool fragCoord, bool pointCoord, bool pointSize,
bool pixelShader) const;
std::string generateVaryingLinkHLSL(const SemanticInfo &info, const std::string &varyingHLSL) const;
std::string generateVaryingHLSL(rx::VertexShaderD3D *shader) const;
void storeUserLinkedVaryings(const rx::VertexShaderD3D *vertexShader, std::vector<gl::LinkedVarying> *linkedVaryings) const;
std::string generateVaryingHLSL(const ShaderD3D *shader) const;
void storeUserLinkedVaryings(const rx::ShaderD3D *vertexShader, std::vector<gl::LinkedVarying> *linkedVaryings) const;
void storeBuiltinLinkedVaryings(const SemanticInfo &info, std::vector<gl::LinkedVarying> *linkedVaryings) const;
void defineOutputVariables(rx::FragmentShaderD3D *fragmentShader, std::map<int, gl::VariableLocation> *programOutputVars) const;
std::string generatePointSpriteHLSL(int registers, rx::FragmentShaderD3D *fragmentShader, rx::VertexShaderD3D *vertexShader) const;
void defineOutputVariables(rx::ShaderD3D *fragmentShader, std::map<int, gl::VariableLocation> *programOutputVars) const;
std::string generatePointSpriteHLSL(int registers, rx::ShaderD3D *fragmentShader, rx::ShaderD3D *vertexShader) const;
// Prepend an underscore
static std::string decorateVariable(const std::string &name);

Просмотреть файл

@ -15,6 +15,18 @@
namespace rx
{
CompileConfig::CompileConfig()
: flags(0),
name()
{
}
CompileConfig::CompileConfig(UINT flags, const std::string &name)
: flags(flags),
name(name)
{
}
HLSLCompiler::HLSLCompiler()
: mD3DCompilerModule(NULL),
mD3DCompileFunc(NULL)
@ -54,7 +66,7 @@ bool HLSLCompiler::initialize()
return false;
}
mD3DCompileFunc = reinterpret_cast<CompileFuncPtr>(GetProcAddress(mD3DCompilerModule, "D3DCompile"));
mD3DCompileFunc = reinterpret_cast<pD3DCompile>(GetProcAddress(mD3DCompilerModule, "D3DCompile"));
ASSERT(mD3DCompileFunc);
return mD3DCompileFunc != NULL;
@ -70,23 +82,25 @@ void HLSLCompiler::release()
}
}
ShaderBlob *HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, const char *profile,
const UINT optimizationFlags[], const char *flagNames[], int attempts) const
ID3DBlob *HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string &hlsl, const std::string &profile,
const std::vector<CompileConfig> &configs) const
{
ASSERT(mD3DCompilerModule && mD3DCompileFunc);
if (!hlsl)
if (gl::perfActive())
{
return NULL;
std::string sourcePath = getTempPath();
std::string sourceText = FormatString("#line 2 \"%s\"\n\n%s", sourcePath.c_str(), hlsl.c_str());
writeFile(sourcePath.c_str(), sourceText.c_str(), sourceText.size());
}
pD3DCompile compileFunc = reinterpret_cast<pD3DCompile>(mD3DCompileFunc);
for (int i = 0; i < attempts; ++i)
for (size_t i = 0; i < configs.size(); ++i)
{
ID3DBlob *errorMessage = NULL;
ID3DBlob *binary = NULL;
HRESULT result = compileFunc(hlsl, strlen(hlsl), gl::g_fakepath, NULL, NULL, "main", profile, optimizationFlags[i], 0, &binary, &errorMessage);
HRESULT result = mD3DCompileFunc(hlsl.c_str(), hlsl.length(), gl::g_fakepath, NULL, NULL, "main", profile.c_str(),
configs[i].flags, 0, &binary, &errorMessage);
if (errorMessage)
{
@ -101,20 +115,20 @@ ShaderBlob *HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const char *hlsl
if (SUCCEEDED(result))
{
return (ShaderBlob*)binary;
return binary;
}
else
{
if (result == E_OUTOFMEMORY)
{
return gl::error(GL_OUT_OF_MEMORY, (ShaderBlob*)NULL);
return gl::error<ID3DBlob*>(GL_OUT_OF_MEMORY, NULL);
}
infoLog.append("Warning: D3D shader compilation failed with %s flags.", flagNames[i]);
infoLog.append("Warning: D3D shader compilation failed with %s flags.", configs[i].name.c_str());
if (i + 1 < attempts)
if (i + 1 < configs.size())
{
infoLog.append(" Retrying with %s.\n", flagNames[i + 1]);
infoLog.append(" Retrying with %s.\n", configs[i + 1].name.c_str());
}
}
}

Просмотреть файл

@ -2,6 +2,10 @@
#define LIBGLESV2_RENDERER_HLSL_D3DCOMPILER_H_
#include "common/angleutils.h"
#include "common/platform.h"
#include <vector>
#include <string>
namespace gl
{
@ -11,8 +15,14 @@ class InfoLog;
namespace rx
{
typedef void* ShaderBlob;
typedef void(*CompileFuncPtr)();
struct CompileConfig
{
UINT flags;
std::string name;
CompileConfig();
CompileConfig(UINT flags, const std::string &name);
};
class HLSLCompiler
{
@ -23,14 +33,14 @@ class HLSLCompiler
bool initialize();
void release();
ShaderBlob *compileToBinary(gl::InfoLog &infoLog, const char *hlsl, const char *profile,
const UINT optimizationFlags[], const char *flagNames[], int attempts) const;
ID3DBlob *compileToBinary(gl::InfoLog &infoLog, const std::string &hlsl, const std::string &profile,
const std::vector<CompileConfig> &configs) const;
private:
DISALLOW_COPY_AND_ASSIGN(HLSLCompiler);
HMODULE mD3DCompilerModule;
CompileFuncPtr mD3DCompileFunc;
pD3DCompile mD3DCompileFunc;
};
}

Просмотреть файл

@ -21,10 +21,7 @@ class Framebuffer;
namespace rx
{
class TextureStorageInterface2D;
class TextureStorageInterfaceCube;
class TextureStorageInterface3D;
class TextureStorageInterface2DArray;
class TextureStorage;
class ImageD3D : public Image
{
@ -36,14 +33,14 @@ class ImageD3D : public Image
virtual bool isDirty() const = 0;
virtual void setManagedSurface(TextureStorageInterface2D *storage, int level) {};
virtual void setManagedSurface(TextureStorageInterfaceCube *storage, int face, int level) {};
virtual void setManagedSurface(TextureStorageInterface3D *storage, int level) {};
virtual void setManagedSurface(TextureStorageInterface2DArray *storage, int layer, int level) {};
virtual bool copyToStorage(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0;
virtual bool copyToStorage(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0;
virtual bool copyToStorage(TextureStorageInterface3D *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth) = 0;
virtual bool copyToStorage(TextureStorageInterface2DArray *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height) = 0;
virtual void setManagedSurface2D(TextureStorage *storage, int level) {};
virtual void setManagedSurfaceCube(TextureStorage *storage, int face, int level) {};
virtual void setManagedSurface3D(TextureStorage *storage, int level) {};
virtual void setManagedSurface2DArray(TextureStorage *storage, int layer, int level) {};
virtual gl::Error copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0;
virtual gl::Error copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0;
virtual gl::Error copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth) = 0;
virtual gl::Error copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(ImageD3D);

Просмотреть файл

@ -66,21 +66,22 @@ unsigned int IndexBufferInterface::getSerial() const
return mIndexBuffer->getSerial();
}
bool IndexBufferInterface::mapBuffer(unsigned int size, void** outMappedMemory, unsigned int *streamOffset)
gl::Error IndexBufferInterface::mapBuffer(unsigned int size, void** outMappedMemory, unsigned int *streamOffset)
{
// Protect against integer overflow
if (mWritePosition + size < mWritePosition)
{
return false;
return gl::Error(GL_OUT_OF_MEMORY, "Mapping of internal index buffer would cause an integer overflow.");
}
if (!mIndexBuffer->mapBuffer(mWritePosition, size, outMappedMemory))
gl::Error error = mIndexBuffer->mapBuffer(mWritePosition, size, outMappedMemory);
if (error.isError())
{
if (outMappedMemory)
{
*outMappedMemory = NULL;
}
return false;
return error;
}
if (streamOffset)
@ -89,10 +90,10 @@ bool IndexBufferInterface::mapBuffer(unsigned int size, void** outMappedMemory,
}
mWritePosition += size;
return true;
return gl::Error(GL_NO_ERROR);
}
bool IndexBufferInterface::unmapBuffer()
gl::Error IndexBufferInterface::unmapBuffer()
{
return mIndexBuffer->unmapBuffer();
}
@ -112,12 +113,12 @@ void IndexBufferInterface::setWritePosition(unsigned int writePosition)
mWritePosition = writePosition;
}
bool IndexBufferInterface::discard()
gl::Error IndexBufferInterface::discard()
{
return mIndexBuffer->discard();
}
bool IndexBufferInterface::setBufferSize(unsigned int bufferSize, GLenum indexType)
gl::Error IndexBufferInterface::setBufferSize(unsigned int bufferSize, GLenum indexType)
{
if (mIndexBuffer->getBufferSize() == 0)
{
@ -137,26 +138,30 @@ StreamingIndexBufferInterface::~StreamingIndexBufferInterface()
{
}
bool StreamingIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum indexType)
gl::Error StreamingIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum indexType)
{
bool result = true;
unsigned int curBufferSize = getBufferSize();
unsigned int writePos = getWritePosition();
if (size > curBufferSize)
{
result = setBufferSize(std::max(size, 2 * curBufferSize), indexType);
gl::Error error = setBufferSize(std::max(size, 2 * curBufferSize), indexType);
if (error.isError())
{
return error;
}
setWritePosition(0);
}
else if (writePos + size > curBufferSize || writePos + size < writePos)
{
if (!discard())
gl::Error error = discard();
if (error.isError())
{
return false;
return error;
}
setWritePosition(0);
}
return result;
return gl::Error(GL_NO_ERROR);
}
@ -168,7 +173,7 @@ StaticIndexBufferInterface::~StaticIndexBufferInterface()
{
}
bool StaticIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum indexType)
gl::Error StaticIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum indexType)
{
unsigned int curSize = getBufferSize();
if (curSize == 0)
@ -177,13 +182,12 @@ bool StaticIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum in
}
else if (curSize >= size && indexType == getIndexType())
{
return true;
return gl::Error(GL_NO_ERROR);
}
else
{
ERR("Static index buffers can't be resized");
UNREACHABLE();
return false;
return gl::Error(GL_INVALID_OPERATION, "Internal static index buffers can't be resized");
}
}

Просмотреть файл

@ -11,6 +11,7 @@
#define LIBGLESV2_RENDERER_INDEXBUFFER_H_
#include "common/angleutils.h"
#include "libGLESv2/Error.h"
#include "libGLESv2/renderer/IndexRangeCache.h"
namespace rx
@ -23,16 +24,16 @@ class IndexBuffer
IndexBuffer();
virtual ~IndexBuffer();
virtual bool initialize(unsigned int bufferSize, GLenum indexType, bool dynamic) = 0;
virtual gl::Error initialize(unsigned int bufferSize, GLenum indexType, bool dynamic) = 0;
virtual bool mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory) = 0;
virtual bool unmapBuffer() = 0;
virtual gl::Error mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory) = 0;
virtual gl::Error unmapBuffer() = 0;
virtual bool discard() = 0;
virtual gl::Error discard() = 0;
virtual GLenum getIndexType() const = 0;
virtual unsigned int getBufferSize() const = 0;
virtual bool setSize(unsigned int bufferSize, GLenum indexType) = 0;
virtual gl::Error setSize(unsigned int bufferSize, GLenum indexType) = 0;
unsigned int getSerial() const;
@ -52,15 +53,15 @@ class IndexBufferInterface
IndexBufferInterface(Renderer *renderer, bool dynamic);
virtual ~IndexBufferInterface();
virtual bool reserveBufferSpace(unsigned int size, GLenum indexType) = 0;
virtual gl::Error reserveBufferSpace(unsigned int size, GLenum indexType) = 0;
GLenum getIndexType() const;
unsigned int getBufferSize() const;
unsigned int getSerial() const;
bool mapBuffer(unsigned int size, void** outMappedMemory, unsigned int *streamOffset);
bool unmapBuffer();
gl::Error mapBuffer(unsigned int size, void** outMappedMemory, unsigned int *streamOffset);
gl::Error unmapBuffer();
IndexBuffer *getIndexBuffer() const;
@ -68,9 +69,9 @@ class IndexBufferInterface
unsigned int getWritePosition() const;
void setWritePosition(unsigned int writePosition);
bool discard();
gl::Error discard();
bool setBufferSize(unsigned int bufferSize, GLenum indexType);
gl::Error setBufferSize(unsigned int bufferSize, GLenum indexType);
private:
DISALLOW_COPY_AND_ASSIGN(IndexBufferInterface);
@ -89,7 +90,7 @@ class StreamingIndexBufferInterface : public IndexBufferInterface
StreamingIndexBufferInterface(Renderer *renderer);
~StreamingIndexBufferInterface();
virtual bool reserveBufferSpace(unsigned int size, GLenum indexType);
virtual gl::Error reserveBufferSpace(unsigned int size, GLenum indexType);
};
class StaticIndexBufferInterface : public IndexBufferInterface
@ -98,7 +99,7 @@ class StaticIndexBufferInterface : public IndexBufferInterface
explicit StaticIndexBufferInterface(Renderer *renderer);
~StaticIndexBufferInterface();
virtual bool reserveBufferSpace(unsigned int size, GLenum indexType);
virtual gl::Error reserveBufferSpace(unsigned int size, GLenum indexType);
IndexRangeCache *getIndexRangeCache();
@ -108,4 +109,4 @@ class StaticIndexBufferInterface : public IndexBufferInterface
}
#endif // LIBGLESV2_RENDERER_INDEXBUFFER_H_
#endif // LIBGLESV2_RENDERER_INDEXBUFFER_H_

Просмотреть файл

@ -58,44 +58,20 @@ static void ConvertIndices(GLenum sourceType, GLenum destinationType, const void
}
IndexDataManager::IndexDataManager(Renderer *renderer)
: mRenderer(renderer)
: mRenderer(renderer),
mStreamingBufferShort(NULL),
mStreamingBufferInt(NULL)
{
mStreamingBufferShort = new StreamingIndexBufferInterface(mRenderer);
if (!mStreamingBufferShort->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_SHORT))
{
SafeDelete(mStreamingBufferShort);
}
mStreamingBufferInt = new StreamingIndexBufferInterface(mRenderer);
if (!mStreamingBufferInt->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT))
{
SafeDelete(mStreamingBufferInt);
}
if (!mStreamingBufferShort)
{
// Make sure both buffers are deleted.
SafeDelete(mStreamingBufferInt);
ERR("Failed to allocate the streaming index buffer(s).");
}
mCountingBuffer = NULL;
}
IndexDataManager::~IndexDataManager()
{
SafeDelete(mStreamingBufferShort);
SafeDelete(mStreamingBufferInt);
SafeDelete(mCountingBuffer);
}
GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer *buffer, const GLvoid *indices, TranslatedIndexData *translated)
gl::Error IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer *buffer, const GLvoid *indices, TranslatedIndexData *translated)
{
if (!mStreamingBufferShort)
{
return GL_OUT_OF_MEMORY;
}
const gl::Type &typeInfo = gl::GetTypeInfo(type);
GLenum destinationIndexType = (type == GL_UNSIGNED_INT) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT;
@ -107,10 +83,6 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer
if (buffer != NULL)
{
if (reinterpret_cast<uintptr_t>(indices) > std::numeric_limits<unsigned int>::max())
{
return GL_OUT_OF_MEMORY;
}
offset = static_cast<unsigned int>(reinterpret_cast<uintptr_t>(indices));
storage = BufferD3D::makeBufferD3D(buffer->getImplementation());
@ -167,7 +139,11 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer
if (!directStorage && !indexBuffer)
{
indexBuffer = (destinationIndexType == GL_UNSIGNED_INT) ? mStreamingBufferInt : mStreamingBufferShort;
gl::Error error = getStreamingIndexBuffer(destinationIndexType, &indexBuffer);
if (error.isError())
{
return error;
}
unsigned int convertCount = count;
@ -189,30 +165,30 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer
if (convertCount > std::numeric_limits<unsigned int>::max() / destTypeInfo.bytes)
{
ERR("Reserving %u indicies of %u bytes each exceeds the maximum buffer size.", convertCount, destTypeInfo.bytes);
return GL_OUT_OF_MEMORY;
return gl::Error(GL_OUT_OF_MEMORY, "Reserving %u indices of %u bytes each exceeds the maximum buffer size.",
convertCount, destTypeInfo.bytes);
}
unsigned int bufferSizeRequired = convertCount * destTypeInfo.bytes;
if (!indexBuffer->reserveBufferSpace(bufferSizeRequired, type))
error = indexBuffer->reserveBufferSpace(bufferSizeRequired, type);
if (error.isError())
{
ERR("Failed to reserve %u bytes in an index buffer.", bufferSizeRequired);
return GL_OUT_OF_MEMORY;
return error;
}
void* output = NULL;
if (!indexBuffer->mapBuffer(bufferSizeRequired, &output, &streamOffset))
error = indexBuffer->mapBuffer(bufferSizeRequired, &output, &streamOffset);
if (error.isError())
{
ERR("Failed to map index buffer.");
return GL_OUT_OF_MEMORY;
return error;
}
ConvertIndices(type, destinationIndexType, staticBuffer ? storage->getData() : indices, convertCount, output);
if (!indexBuffer->unmapBuffer())
error = indexBuffer->unmapBuffer();
if (error.isError())
{
ERR("Failed to unmap index buffer.");
return GL_OUT_OF_MEMORY;
return error;
}
if (staticBuffer)
@ -234,77 +210,46 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer
storage->promoteStaticUsage(count * typeInfo.bytes);
}
return GL_NO_ERROR;
return gl::Error(GL_NO_ERROR);
}
StaticIndexBufferInterface *IndexDataManager::getCountingIndices(GLsizei count)
gl::Error IndexDataManager::getStreamingIndexBuffer(GLenum destinationIndexType, IndexBufferInterface **outBuffer)
{
if (count <= 65536) // 16-bit indices
ASSERT(outBuffer);
if (destinationIndexType == GL_UNSIGNED_INT)
{
const unsigned int spaceNeeded = count * sizeof(unsigned short);
if (!mCountingBuffer || mCountingBuffer->getBufferSize() < spaceNeeded)
if (!mStreamingBufferInt)
{
delete mCountingBuffer;
mCountingBuffer = new StaticIndexBufferInterface(mRenderer);
mCountingBuffer->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_SHORT);
void* mappedMemory = NULL;
if (!mCountingBuffer->mapBuffer(spaceNeeded, &mappedMemory, NULL))
mStreamingBufferInt = new StreamingIndexBufferInterface(mRenderer);
gl::Error error = mStreamingBufferInt->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT);
if (error.isError())
{
ERR("Failed to map counting buffer.");
return NULL;
}
unsigned short *data = reinterpret_cast<unsigned short*>(mappedMemory);
for(int i = 0; i < count; i++)
{
data[i] = i;
}
if (!mCountingBuffer->unmapBuffer())
{
ERR("Failed to unmap counting buffer.");
return NULL;
SafeDelete(mStreamingBufferInt);
return error;
}
}
}
else if (mStreamingBufferInt) // 32-bit indices supported
{
const unsigned int spaceNeeded = count * sizeof(unsigned int);
if (!mCountingBuffer || mCountingBuffer->getBufferSize() < spaceNeeded)
{
delete mCountingBuffer;
mCountingBuffer = new StaticIndexBufferInterface(mRenderer);
mCountingBuffer->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT);
void* mappedMemory = NULL;
if (!mCountingBuffer->mapBuffer(spaceNeeded, &mappedMemory, NULL))
{
ERR("Failed to map counting buffer.");
return NULL;
}
unsigned int *data = reinterpret_cast<unsigned int*>(mappedMemory);
for(int i = 0; i < count; i++)
{
data[i] = i;
}
if (!mCountingBuffer->unmapBuffer())
{
ERR("Failed to unmap counting buffer.");
return NULL;
}
}
*outBuffer = mStreamingBufferInt;
return gl::Error(GL_NO_ERROR);
}
else
{
return NULL;
ASSERT(destinationIndexType == GL_UNSIGNED_SHORT);
if (!mStreamingBufferShort)
{
mStreamingBufferShort = new StreamingIndexBufferInterface(mRenderer);
gl::Error error = mStreamingBufferShort->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_SHORT);
if (error.isError())
{
SafeDelete(mStreamingBufferShort);
return error;
}
}
*outBuffer = mStreamingBufferShort;
return gl::Error(GL_NO_ERROR);
}
return mCountingBuffer;
}
}

Просмотреть файл

@ -12,6 +12,7 @@
#include "common/angleutils.h"
#include "common/mathutil.h"
#include "libGLESv2/Error.h"
#include <GLES2/gl2.h>
@ -27,6 +28,7 @@ class Buffer;
namespace rx
{
class IndexBufferInterface;
class StaticIndexBufferInterface;
class StreamingIndexBufferInterface;
class IndexBuffer;
@ -51,17 +53,17 @@ class IndexDataManager
explicit IndexDataManager(Renderer *renderer);
virtual ~IndexDataManager();
GLenum prepareIndexData(GLenum type, GLsizei count, gl::Buffer *arrayElementBuffer, const GLvoid *indices, TranslatedIndexData *translated);
StaticIndexBufferInterface *getCountingIndices(GLsizei count);
gl::Error prepareIndexData(GLenum type, GLsizei count, gl::Buffer *arrayElementBuffer, const GLvoid *indices, TranslatedIndexData *translated);
private:
gl::Error getStreamingIndexBuffer(GLenum destinationIndexType, IndexBufferInterface **outBuffer);
DISALLOW_COPY_AND_ASSIGN(IndexDataManager);
Renderer *const mRenderer;
StreamingIndexBufferInterface *mStreamingBufferShort;
StreamingIndexBufferInterface *mStreamingBufferInt;
StaticIndexBufferInterface *mCountingBuffer;
};
}

Просмотреть файл

@ -5,6 +5,7 @@
//
#include "libGLESv2/renderer/d3d/MemoryBuffer.h"
#include "common/debug.h"
#include <algorithm>
#include <cstdlib>
@ -28,7 +29,9 @@ bool MemoryBuffer::resize(size_t size)
{
if (size == 0)
{
clear();
free(mData);
mData = NULL;
mSize = 0;
}
else
{
@ -64,14 +67,8 @@ const uint8_t *MemoryBuffer::data() const
uint8_t *MemoryBuffer::data()
{
ASSERT(mData);
return mData;
}
void MemoryBuffer::clear()
{
free(mData);
mData = NULL;
mSize = 0;
}
}

Просмотреть файл

@ -21,13 +21,11 @@ class MemoryBuffer
bool resize(size_t size);
size_t size() const;
void clear();
bool empty() const { return mSize == 0; }
const uint8_t *data() const;
uint8_t *data();
bool empty() const { return (mSize == 0); }
private:
size_t mSize;
uint8_t *mData;

Просмотреть файл

@ -0,0 +1,686 @@
//
// Copyright (c) 2014 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.
//
// ProgramD3D.cpp: Defines the rx::ProgramD3D class which implements rx::ProgramImpl.
#include "libGLESv2/renderer/d3d/ProgramD3D.h"
#include "common/utilities.h"
#include "libGLESv2/Framebuffer.h"
#include "libGLESv2/FramebufferAttachment.h"
#include "libGLESv2/Program.h"
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/ShaderExecutable.h"
#include "libGLESv2/renderer/d3d/DynamicHLSL.h"
#include "libGLESv2/renderer/d3d/ShaderD3D.h"
#include "libGLESv2/main.h"
namespace rx
{
namespace
{
void GetDefaultInputLayoutFromShader(const std::vector<sh::Attribute> &shaderAttributes, gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS])
{
size_t layoutIndex = 0;
for (size_t attributeIndex = 0; attributeIndex < shaderAttributes.size(); attributeIndex++)
{
ASSERT(layoutIndex < gl::MAX_VERTEX_ATTRIBS);
const sh::Attribute &shaderAttr = shaderAttributes[attributeIndex];
if (shaderAttr.type != GL_NONE)
{
GLenum transposedType = gl::TransposeMatrixType(shaderAttr.type);
for (size_t rowIndex = 0; static_cast<int>(rowIndex) < gl::VariableRowCount(transposedType); rowIndex++, layoutIndex++)
{
gl::VertexFormat *defaultFormat = &inputLayout[layoutIndex];
defaultFormat->mType = gl::VariableComponentType(transposedType);
defaultFormat->mNormalized = false;
defaultFormat->mPureInteger = (defaultFormat->mType != GL_FLOAT); // note: inputs can not be bool
defaultFormat->mComponents = gl::VariableColumnCount(transposedType);
}
}
}
}
std::vector<GLenum> GetDefaultOutputLayoutFromShader(const std::vector<PixelShaderOutputVariable> &shaderOutputVars)
{
std::vector<GLenum> defaultPixelOutput(1);
ASSERT(!shaderOutputVars.empty());
defaultPixelOutput[0] = GL_COLOR_ATTACHMENT0 + shaderOutputVars[0].outputIndex;
return defaultPixelOutput;
}
}
ProgramD3D::VertexExecutable::VertexExecutable(const gl::VertexFormat inputLayout[],
const GLenum signature[],
ShaderExecutable *shaderExecutable)
: mShaderExecutable(shaderExecutable)
{
for (size_t attributeIndex = 0; attributeIndex < gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
{
mInputs[attributeIndex] = inputLayout[attributeIndex];
mSignature[attributeIndex] = signature[attributeIndex];
}
}
ProgramD3D::VertexExecutable::~VertexExecutable()
{
SafeDelete(mShaderExecutable);
}
bool ProgramD3D::VertexExecutable::matchesSignature(const GLenum signature[]) const
{
for (size_t attributeIndex = 0; attributeIndex < gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
{
if (mSignature[attributeIndex] != signature[attributeIndex])
{
return false;
}
}
return true;
}
ProgramD3D::PixelExecutable::PixelExecutable(const std::vector<GLenum> &outputSignature, ShaderExecutable *shaderExecutable)
: mOutputSignature(outputSignature),
mShaderExecutable(shaderExecutable)
{
}
ProgramD3D::PixelExecutable::~PixelExecutable()
{
SafeDelete(mShaderExecutable);
}
ProgramD3D::ProgramD3D(Renderer *renderer)
: ProgramImpl(),
mRenderer(renderer),
mDynamicHLSL(NULL),
mGeometryExecutable(NULL),
mVertexWorkarounds(ANGLE_D3D_WORKAROUND_NONE),
mPixelWorkarounds(ANGLE_D3D_WORKAROUND_NONE),
mUsesPointSize(false),
mVertexUniformStorage(NULL),
mFragmentUniformStorage(NULL),
mShaderVersion(100)
{
mDynamicHLSL = new DynamicHLSL(renderer);
}
ProgramD3D::~ProgramD3D()
{
reset();
SafeDelete(mDynamicHLSL);
}
ProgramD3D *ProgramD3D::makeProgramD3D(ProgramImpl *impl)
{
ASSERT(HAS_DYNAMIC_TYPE(ProgramD3D*, impl));
return static_cast<ProgramD3D*>(impl);
}
const ProgramD3D *ProgramD3D::makeProgramD3D(const ProgramImpl *impl)
{
ASSERT(HAS_DYNAMIC_TYPE(const ProgramD3D*, impl));
return static_cast<const ProgramD3D*>(impl);
}
bool ProgramD3D::usesPointSpriteEmulation() const
{
return mUsesPointSize && mRenderer->getMajorShaderModel() >= 4;
}
bool ProgramD3D::usesGeometryShader() const
{
return usesPointSpriteEmulation();
}
bool ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream)
{
stream->readInt(&mShaderVersion);
stream->readInt(&mTransformFeedbackBufferMode);
const unsigned int transformFeedbackVaryingCount = stream->readInt<unsigned int>();
mTransformFeedbackLinkedVaryings.resize(transformFeedbackVaryingCount);
for (unsigned int varyingIndex = 0; varyingIndex < transformFeedbackVaryingCount; varyingIndex++)
{
gl::LinkedVarying &varying = mTransformFeedbackLinkedVaryings[varyingIndex];
stream->readString(&varying.name);
stream->readInt(&varying.type);
stream->readInt(&varying.size);
stream->readString(&varying.semanticName);
stream->readInt(&varying.semanticIndex);
stream->readInt(&varying.semanticIndexCount);
}
stream->readString(&mVertexHLSL);
stream->readInt(&mVertexWorkarounds);
stream->readString(&mPixelHLSL);
stream->readInt(&mPixelWorkarounds);
stream->readBool(&mUsesFragDepth);
stream->readBool(&mUsesPointSize);
const size_t pixelShaderKeySize = stream->readInt<unsigned int>();
mPixelShaderKey.resize(pixelShaderKeySize);
for (size_t pixelShaderKeyIndex = 0; pixelShaderKeyIndex < pixelShaderKeySize; pixelShaderKeyIndex++)
{
stream->readInt(&mPixelShaderKey[pixelShaderKeyIndex].type);
stream->readString(&mPixelShaderKey[pixelShaderKeyIndex].name);
stream->readString(&mPixelShaderKey[pixelShaderKeyIndex].source);
stream->readInt(&mPixelShaderKey[pixelShaderKeyIndex].outputIndex);
}
const unsigned char* binary = reinterpret_cast<const unsigned char*>(stream->data());
const unsigned int vertexShaderCount = stream->readInt<unsigned int>();
for (unsigned int vertexShaderIndex = 0; vertexShaderIndex < vertexShaderCount; vertexShaderIndex++)
{
gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS];
for (size_t inputIndex = 0; inputIndex < gl::MAX_VERTEX_ATTRIBS; inputIndex++)
{
gl::VertexFormat *vertexInput = &inputLayout[inputIndex];
stream->readInt(&vertexInput->mType);
stream->readInt(&vertexInput->mNormalized);
stream->readInt(&vertexInput->mComponents);
stream->readBool(&vertexInput->mPureInteger);
}
unsigned int vertexShaderSize = stream->readInt<unsigned int>();
const unsigned char *vertexShaderFunction = binary + stream->offset();
ShaderExecutable *shaderExecutable = mRenderer->loadExecutable(vertexShaderFunction, vertexShaderSize,
SHADER_VERTEX,
mTransformFeedbackLinkedVaryings,
(mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS));
if (!shaderExecutable)
{
infoLog.append("Could not create vertex shader.");
return false;
}
// generated converted input layout
GLenum signature[gl::MAX_VERTEX_ATTRIBS];
getInputLayoutSignature(inputLayout, signature);
// add new binary
mVertexExecutables.push_back(new VertexExecutable(inputLayout, signature, shaderExecutable));
stream->skip(vertexShaderSize);
}
const size_t pixelShaderCount = stream->readInt<unsigned int>();
for (size_t pixelShaderIndex = 0; pixelShaderIndex < pixelShaderCount; pixelShaderIndex++)
{
const size_t outputCount = stream->readInt<unsigned int>();
std::vector<GLenum> outputs(outputCount);
for (size_t outputIndex = 0; outputIndex < outputCount; outputIndex++)
{
stream->readInt(&outputs[outputIndex]);
}
const size_t pixelShaderSize = stream->readInt<unsigned int>();
const unsigned char *pixelShaderFunction = binary + stream->offset();
ShaderExecutable *shaderExecutable = mRenderer->loadExecutable(pixelShaderFunction, pixelShaderSize,
SHADER_PIXEL,
mTransformFeedbackLinkedVaryings,
(mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS));
if (!shaderExecutable)
{
infoLog.append("Could not create pixel shader.");
return false;
}
// add new binary
mPixelExecutables.push_back(new PixelExecutable(outputs, shaderExecutable));
stream->skip(pixelShaderSize);
}
unsigned int geometryShaderSize = stream->readInt<unsigned int>();
if (geometryShaderSize > 0)
{
const unsigned char *geometryShaderFunction = binary + stream->offset();
mGeometryExecutable = mRenderer->loadExecutable(geometryShaderFunction, geometryShaderSize,
SHADER_GEOMETRY,
mTransformFeedbackLinkedVaryings,
(mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS));
if (!mGeometryExecutable)
{
infoLog.append("Could not create geometry shader.");
return false;
}
stream->skip(geometryShaderSize);
}
GUID binaryIdentifier = {0};
stream->readBytes(reinterpret_cast<unsigned char*>(&binaryIdentifier), sizeof(GUID));
GUID identifier = mRenderer->getAdapterIdentifier();
if (memcmp(&identifier, &binaryIdentifier, sizeof(GUID)) != 0)
{
infoLog.append("Invalid program binary.");
return false;
}
return true;
}
bool ProgramD3D::save(gl::BinaryOutputStream *stream)
{
stream->writeInt(mShaderVersion);
stream->writeInt(mTransformFeedbackBufferMode);
stream->writeInt(mTransformFeedbackLinkedVaryings.size());
for (size_t i = 0; i < mTransformFeedbackLinkedVaryings.size(); i++)
{
const gl::LinkedVarying &varying = mTransformFeedbackLinkedVaryings[i];
stream->writeString(varying.name);
stream->writeInt(varying.type);
stream->writeInt(varying.size);
stream->writeString(varying.semanticName);
stream->writeInt(varying.semanticIndex);
stream->writeInt(varying.semanticIndexCount);
}
stream->writeString(mVertexHLSL);
stream->writeInt(mVertexWorkarounds);
stream->writeString(mPixelHLSL);
stream->writeInt(mPixelWorkarounds);
stream->writeInt(mUsesFragDepth);
stream->writeInt(mUsesPointSize);
const std::vector<PixelShaderOutputVariable> &pixelShaderKey = mPixelShaderKey;
stream->writeInt(pixelShaderKey.size());
for (size_t pixelShaderKeyIndex = 0; pixelShaderKeyIndex < pixelShaderKey.size(); pixelShaderKeyIndex++)
{
const PixelShaderOutputVariable &variable = pixelShaderKey[pixelShaderKeyIndex];
stream->writeInt(variable.type);
stream->writeString(variable.name);
stream->writeString(variable.source);
stream->writeInt(variable.outputIndex);
}
stream->writeInt(mVertexExecutables.size());
for (size_t vertexExecutableIndex = 0; vertexExecutableIndex < mVertexExecutables.size(); vertexExecutableIndex++)
{
VertexExecutable *vertexExecutable = mVertexExecutables[vertexExecutableIndex];
for (size_t inputIndex = 0; inputIndex < gl::MAX_VERTEX_ATTRIBS; inputIndex++)
{
const gl::VertexFormat &vertexInput = vertexExecutable->inputs()[inputIndex];
stream->writeInt(vertexInput.mType);
stream->writeInt(vertexInput.mNormalized);
stream->writeInt(vertexInput.mComponents);
stream->writeInt(vertexInput.mPureInteger);
}
size_t vertexShaderSize = vertexExecutable->shaderExecutable()->getLength();
stream->writeInt(vertexShaderSize);
const uint8_t *vertexBlob = vertexExecutable->shaderExecutable()->getFunction();
stream->writeBytes(vertexBlob, vertexShaderSize);
}
stream->writeInt(mPixelExecutables.size());
for (size_t pixelExecutableIndex = 0; pixelExecutableIndex < mPixelExecutables.size(); pixelExecutableIndex++)
{
PixelExecutable *pixelExecutable = mPixelExecutables[pixelExecutableIndex];
const std::vector<GLenum> outputs = pixelExecutable->outputSignature();
stream->writeInt(outputs.size());
for (size_t outputIndex = 0; outputIndex < outputs.size(); outputIndex++)
{
stream->writeInt(outputs[outputIndex]);
}
size_t pixelShaderSize = pixelExecutable->shaderExecutable()->getLength();
stream->writeInt(pixelShaderSize);
const uint8_t *pixelBlob = pixelExecutable->shaderExecutable()->getFunction();
stream->writeBytes(pixelBlob, pixelShaderSize);
}
size_t geometryShaderSize = (mGeometryExecutable != NULL) ? mGeometryExecutable->getLength() : 0;
stream->writeInt(geometryShaderSize);
if (mGeometryExecutable != NULL && geometryShaderSize > 0)
{
const uint8_t *geometryBlob = mGeometryExecutable->getFunction();
stream->writeBytes(geometryBlob, geometryShaderSize);
}
GUID binaryIdentifier = mRenderer->getAdapterIdentifier();
stream->writeBytes(reinterpret_cast<unsigned char*>(&binaryIdentifier), sizeof(GUID));
return true;
}
ShaderExecutable *ProgramD3D::getPixelExecutableForFramebuffer(const gl::Framebuffer *fbo)
{
std::vector<GLenum> outputs;
const gl::ColorbufferInfo &colorbuffers = fbo->getColorbuffersForRender();
for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment)
{
const gl::FramebufferAttachment *colorbuffer = colorbuffers[colorAttachment];
if (colorbuffer)
{
outputs.push_back(colorbuffer->getBinding() == GL_BACK ? GL_COLOR_ATTACHMENT0 : colorbuffer->getBinding());
}
else
{
outputs.push_back(GL_NONE);
}
}
return getPixelExecutableForOutputLayout(outputs);
}
ShaderExecutable *ProgramD3D::getPixelExecutableForOutputLayout(const std::vector<GLenum> &outputSignature)
{
for (size_t executableIndex = 0; executableIndex < mPixelExecutables.size(); executableIndex++)
{
if (mPixelExecutables[executableIndex]->matchesSignature(outputSignature))
{
return mPixelExecutables[executableIndex]->shaderExecutable();
}
}
std::string finalPixelHLSL = mDynamicHLSL->generatePixelShaderForOutputSignature(mPixelHLSL, mPixelShaderKey, mUsesFragDepth,
outputSignature);
// Generate new pixel executable
gl::InfoLog tempInfoLog;
ShaderExecutable *pixelExecutable = mRenderer->compileToExecutable(tempInfoLog, finalPixelHLSL, SHADER_PIXEL,
mTransformFeedbackLinkedVaryings,
(mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS),
mPixelWorkarounds);
if (!pixelExecutable)
{
std::vector<char> tempCharBuffer(tempInfoLog.getLength() + 3);
tempInfoLog.getLog(tempInfoLog.getLength(), NULL, &tempCharBuffer[0]);
ERR("Error compiling dynamic pixel executable:\n%s\n", &tempCharBuffer[0]);
}
else
{
mPixelExecutables.push_back(new PixelExecutable(outputSignature, pixelExecutable));
}
return pixelExecutable;
}
ShaderExecutable *ProgramD3D::getVertexExecutableForInputLayout(const gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS])
{
GLenum signature[gl::MAX_VERTEX_ATTRIBS];
getInputLayoutSignature(inputLayout, signature);
for (size_t executableIndex = 0; executableIndex < mVertexExecutables.size(); executableIndex++)
{
if (mVertexExecutables[executableIndex]->matchesSignature(signature))
{
return mVertexExecutables[executableIndex]->shaderExecutable();
}
}
// Generate new dynamic layout with attribute conversions
std::string finalVertexHLSL = mDynamicHLSL->generateVertexShaderForInputLayout(mVertexHLSL, inputLayout, mShaderAttributes);
// Generate new vertex executable
gl::InfoLog tempInfoLog;
ShaderExecutable *vertexExecutable = mRenderer->compileToExecutable(tempInfoLog, finalVertexHLSL,
SHADER_VERTEX,
mTransformFeedbackLinkedVaryings,
(mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS),
mVertexWorkarounds);
if (!vertexExecutable)
{
std::vector<char> tempCharBuffer(tempInfoLog.getLength()+3);
tempInfoLog.getLog(tempInfoLog.getLength(), NULL, &tempCharBuffer[0]);
ERR("Error compiling dynamic vertex executable:\n%s\n", &tempCharBuffer[0]);
}
else
{
mVertexExecutables.push_back(new VertexExecutable(inputLayout, signature, vertexExecutable));
}
return vertexExecutable;
}
bool ProgramD3D::compileProgramExecutables(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader,
int registers)
{
ShaderD3D *vertexShaderD3D = ShaderD3D::makeShaderD3D(vertexShader->getImplementation());
ShaderD3D *fragmentShaderD3D = ShaderD3D::makeShaderD3D(fragmentShader->getImplementation());
gl::VertexFormat defaultInputLayout[gl::MAX_VERTEX_ATTRIBS];
GetDefaultInputLayoutFromShader(vertexShader->getActiveAttributes(), defaultInputLayout);
ShaderExecutable *defaultVertexExecutable = getVertexExecutableForInputLayout(defaultInputLayout);
std::vector<GLenum> defaultPixelOutput = GetDefaultOutputLayoutFromShader(getPixelShaderKey());
ShaderExecutable *defaultPixelExecutable = getPixelExecutableForOutputLayout(defaultPixelOutput);
if (usesGeometryShader())
{
std::string geometryHLSL = mDynamicHLSL->generateGeometryShaderHLSL(registers, fragmentShaderD3D, vertexShaderD3D);
mGeometryExecutable = mRenderer->compileToExecutable(infoLog, geometryHLSL,
SHADER_GEOMETRY, mTransformFeedbackLinkedVaryings,
(mTransformFeedbackBufferMode == GL_SEPARATE_ATTRIBS),
ANGLE_D3D_WORKAROUND_NONE);
}
return (defaultVertexExecutable && defaultPixelExecutable && (!usesGeometryShader() || mGeometryExecutable));
}
bool ProgramD3D::link(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader,
const std::vector<std::string> &transformFeedbackVaryings, GLenum transformFeedbackBufferMode,
int *registers, std::vector<gl::LinkedVarying> *linkedVaryings,
std::map<int, gl::VariableLocation> *outputVariables, const gl::Caps &caps)
{
ShaderD3D *vertexShaderD3D = ShaderD3D::makeShaderD3D(vertexShader->getImplementation());
ShaderD3D *fragmentShaderD3D = ShaderD3D::makeShaderD3D(fragmentShader->getImplementation());
mTransformFeedbackBufferMode = transformFeedbackBufferMode;
mPixelHLSL = fragmentShaderD3D->getTranslatedSource();
mPixelWorkarounds = fragmentShaderD3D->getD3DWorkarounds();
mVertexHLSL = vertexShaderD3D->getTranslatedSource();
mVertexWorkarounds = vertexShaderD3D->getD3DWorkarounds();
mShaderVersion = vertexShaderD3D->getShaderVersion();
// Map the varyings to the register file
VaryingPacking packing = { NULL };
*registers = mDynamicHLSL->packVaryings(infoLog, packing, fragmentShaderD3D, vertexShaderD3D, transformFeedbackVaryings);
if (*registers < 0)
{
return false;
}
if (!gl::ProgramBinary::linkVaryings(infoLog, fragmentShader, vertexShader))
{
return false;
}
if (!mDynamicHLSL->generateShaderLinkHLSL(infoLog, *registers, packing, mPixelHLSL, mVertexHLSL,
fragmentShaderD3D, vertexShaderD3D, transformFeedbackVaryings,
linkedVaryings, outputVariables, &mPixelShaderKey, &mUsesFragDepth))
{
return false;
}
mUsesPointSize = vertexShaderD3D->usesPointSize();
return true;
}
void ProgramD3D::getInputLayoutSignature(const gl::VertexFormat inputLayout[], GLenum signature[]) const
{
mDynamicHLSL->getInputLayoutSignature(inputLayout, signature);
}
void ProgramD3D::initializeUniformStorage(const std::vector<gl::LinkedUniform*> &uniforms)
{
// Compute total default block size
unsigned int vertexRegisters = 0;
unsigned int fragmentRegisters = 0;
for (size_t uniformIndex = 0; uniformIndex < uniforms.size(); uniformIndex++)
{
const gl::LinkedUniform &uniform = *uniforms[uniformIndex];
if (!gl::IsSampler(uniform.type))
{
if (uniform.isReferencedByVertexShader())
{
vertexRegisters = std::max(vertexRegisters, uniform.vsRegisterIndex + uniform.registerCount);
}
if (uniform.isReferencedByFragmentShader())
{
fragmentRegisters = std::max(fragmentRegisters, uniform.psRegisterIndex + uniform.registerCount);
}
}
}
mVertexUniformStorage = mRenderer->createUniformStorage(vertexRegisters * 16u);
mFragmentUniformStorage = mRenderer->createUniformStorage(fragmentRegisters * 16u);
}
gl::Error ProgramD3D::applyUniforms(const std::vector<gl::LinkedUniform*> &uniforms)
{
return mRenderer->applyUniforms(*this, uniforms);
}
gl::Error ProgramD3D::applyUniformBuffers(const std::vector<gl::UniformBlock*> uniformBlocks, const std::vector<gl::Buffer*> boundBuffers,
const gl::Caps &caps)
{
const gl::Buffer *vertexUniformBuffers[gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS] = {NULL};
const gl::Buffer *fragmentUniformBuffers[gl::IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS] = {NULL};
const unsigned int reservedBuffersInVS = mRenderer->getReservedVertexUniformBuffers();
const unsigned int reservedBuffersInFS = mRenderer->getReservedFragmentUniformBuffers();
for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < uniformBlocks.size(); uniformBlockIndex++)
{
gl::UniformBlock *uniformBlock = uniformBlocks[uniformBlockIndex];
gl::Buffer *uniformBuffer = boundBuffers[uniformBlockIndex];
ASSERT(uniformBlock && uniformBuffer);
if (uniformBuffer->getSize() < uniformBlock->dataSize)
{
// undefined behaviour
return gl::Error(GL_INVALID_OPERATION, "It is undefined behaviour to use a uniform buffer that is too small.");
}
// Unnecessary to apply an unreferenced standard or shared UBO
if (!uniformBlock->isReferencedByVertexShader() && !uniformBlock->isReferencedByFragmentShader())
{
continue;
}
if (uniformBlock->isReferencedByVertexShader())
{
unsigned int registerIndex = uniformBlock->vsRegisterIndex - reservedBuffersInVS;
ASSERT(vertexUniformBuffers[registerIndex] == NULL);
ASSERT(registerIndex < caps.maxVertexUniformBlocks);
vertexUniformBuffers[registerIndex] = uniformBuffer;
}
if (uniformBlock->isReferencedByFragmentShader())
{
unsigned int registerIndex = uniformBlock->psRegisterIndex - reservedBuffersInFS;
ASSERT(fragmentUniformBuffers[registerIndex] == NULL);
ASSERT(registerIndex < caps.maxFragmentUniformBlocks);
fragmentUniformBuffers[registerIndex] = uniformBuffer;
}
}
return mRenderer->setUniformBuffers(vertexUniformBuffers, fragmentUniformBuffers);
}
bool ProgramD3D::assignUniformBlockRegister(gl::InfoLog &infoLog, gl::UniformBlock *uniformBlock, GLenum shader,
unsigned int registerIndex, const gl::Caps &caps)
{
if (shader == GL_VERTEX_SHADER)
{
uniformBlock->vsRegisterIndex = registerIndex;
if (registerIndex - mRenderer->getReservedVertexUniformBuffers() >= caps.maxVertexUniformBlocks)
{
infoLog.append("Vertex shader uniform block count exceed GL_MAX_VERTEX_UNIFORM_BLOCKS (%u)", caps.maxVertexUniformBlocks);
return false;
}
}
else if (shader == GL_FRAGMENT_SHADER)
{
uniformBlock->psRegisterIndex = registerIndex;
if (registerIndex - mRenderer->getReservedFragmentUniformBuffers() >= caps.maxFragmentUniformBlocks)
{
infoLog.append("Fragment shader uniform block count exceed GL_MAX_FRAGMENT_UNIFORM_BLOCKS (%u)", caps.maxFragmentUniformBlocks);
return false;
}
}
else UNREACHABLE();
return true;
}
unsigned int ProgramD3D::getReservedUniformVectors(GLenum shader)
{
if (shader == GL_VERTEX_SHADER)
{
return mRenderer->getReservedVertexUniformVectors();
}
else if (shader == GL_FRAGMENT_SHADER)
{
return mRenderer->getReservedFragmentUniformVectors();
}
else UNREACHABLE();
return 0;
}
void ProgramD3D::reset()
{
SafeDeleteContainer(mVertexExecutables);
SafeDeleteContainer(mPixelExecutables);
SafeDelete(mGeometryExecutable);
mTransformFeedbackBufferMode = GL_NONE;
mTransformFeedbackLinkedVaryings.clear();
mVertexHLSL.clear();
mVertexWorkarounds = ANGLE_D3D_WORKAROUND_NONE;
mShaderVersion = 100;
mPixelHLSL.clear();
mPixelWorkarounds = ANGLE_D3D_WORKAROUND_NONE;
mUsesFragDepth = false;
mPixelShaderKey.clear();
mUsesPointSize = false;
SafeDelete(mVertexUniformStorage);
SafeDelete(mFragmentUniformStorage);
}
}

Просмотреть файл

@ -0,0 +1,150 @@
//
// Copyright (c) 2014 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.
//
// ProgramD3D.h: Defines the rx::ProgramD3D class which implements rx::ProgramImpl.
#ifndef LIBGLESV2_RENDERER_PROGRAMD3D_H_
#define LIBGLESV2_RENDERER_PROGRAMD3D_H_
#include "libGLESv2/renderer/ProgramImpl.h"
#include "libGLESv2/renderer/Workarounds.h"
#include <string>
#include <vector>
namespace gl
{
struct LinkedUniform;
struct VariableLocation;
struct VertexFormat;
}
namespace rx
{
class UniformStorage;
class ProgramD3D : public ProgramImpl
{
public:
ProgramD3D(rx::Renderer *renderer);
virtual ~ProgramD3D();
static ProgramD3D *makeProgramD3D(ProgramImpl *impl);
static const ProgramD3D *makeProgramD3D(const ProgramImpl *impl);
const std::vector<rx::PixelShaderOutputVariable> &getPixelShaderKey() { return mPixelShaderKey; }
int getShaderVersion() const { return mShaderVersion; }
GLenum getTransformFeedbackBufferMode() const { return mTransformFeedbackBufferMode; }
std::vector<gl::LinkedVarying> &getTransformFeedbackLinkedVaryings() { return mTransformFeedbackLinkedVaryings; }
sh::Attribute *getShaderAttributes() { return mShaderAttributes; }
bool usesPointSize() const { return mUsesPointSize; }
bool usesPointSpriteEmulation() const;
bool usesGeometryShader() const;
GLenum getBinaryFormat() { return GL_PROGRAM_BINARY_ANGLE; }
bool load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream);
bool save(gl::BinaryOutputStream *stream);
ShaderExecutable *getPixelExecutableForFramebuffer(const gl::Framebuffer *fbo);
ShaderExecutable *getPixelExecutableForOutputLayout(const std::vector<GLenum> &outputLayout);
ShaderExecutable *getVertexExecutableForInputLayout(const gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS]);
ShaderExecutable *getGeometryExecutable() const { return mGeometryExecutable; }
bool compileProgramExecutables(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader,
int registers);
bool link(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader,
const std::vector<std::string> &transformFeedbackVaryings, GLenum transformFeedbackBufferMode,
int *registers, std::vector<gl::LinkedVarying> *linkedVaryings,
std::map<int, gl::VariableLocation> *outputVariables, const gl::Caps &caps);
void getInputLayoutSignature(const gl::VertexFormat inputLayout[], GLenum signature[]) const;
void initializeUniformStorage(const std::vector<gl::LinkedUniform*> &uniforms);
gl::Error applyUniforms(const std::vector<gl::LinkedUniform*> &uniforms);
gl::Error applyUniformBuffers(const std::vector<gl::UniformBlock*> uniformBlocks, const std::vector<gl::Buffer*> boundBuffers,
const gl::Caps &caps);
bool assignUniformBlockRegister(gl::InfoLog &infoLog, gl::UniformBlock *uniformBlock, GLenum shader,
unsigned int registerIndex, const gl::Caps &caps);
unsigned int getReservedUniformVectors(GLenum shader);
const UniformStorage &getVertexUniformStorage() const { return *mVertexUniformStorage; }
const UniformStorage &getFragmentUniformStorage() const { return *mFragmentUniformStorage; }
void reset();
private:
DISALLOW_COPY_AND_ASSIGN(ProgramD3D);
class VertexExecutable
{
public:
VertexExecutable(const gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS],
const GLenum signature[gl::MAX_VERTEX_ATTRIBS],
rx::ShaderExecutable *shaderExecutable);
~VertexExecutable();
bool matchesSignature(const GLenum convertedLayout[gl::MAX_VERTEX_ATTRIBS]) const;
const gl::VertexFormat *inputs() const { return mInputs; }
const GLenum *signature() const { return mSignature; }
rx::ShaderExecutable *shaderExecutable() const { return mShaderExecutable; }
private:
gl::VertexFormat mInputs[gl::MAX_VERTEX_ATTRIBS];
GLenum mSignature[gl::MAX_VERTEX_ATTRIBS];
rx::ShaderExecutable *mShaderExecutable;
};
class PixelExecutable
{
public:
PixelExecutable(const std::vector<GLenum> &outputSignature, rx::ShaderExecutable *shaderExecutable);
~PixelExecutable();
bool matchesSignature(const std::vector<GLenum> &signature) const { return mOutputSignature == signature; }
const std::vector<GLenum> &outputSignature() const { return mOutputSignature; }
rx::ShaderExecutable *shaderExecutable() const { return mShaderExecutable; }
private:
std::vector<GLenum> mOutputSignature;
rx::ShaderExecutable *mShaderExecutable;
};
Renderer *mRenderer;
DynamicHLSL *mDynamicHLSL;
std::vector<VertexExecutable *> mVertexExecutables;
std::vector<PixelExecutable *> mPixelExecutables;
rx::ShaderExecutable *mGeometryExecutable;
std::string mVertexHLSL;
rx::D3DWorkaroundType mVertexWorkarounds;
std::string mPixelHLSL;
rx::D3DWorkaroundType mPixelWorkarounds;
bool mUsesFragDepth;
std::vector<rx::PixelShaderOutputVariable> mPixelShaderKey;
bool mUsesPointSize;
UniformStorage *mVertexUniformStorage;
UniformStorage *mFragmentUniformStorage;
GLenum mTransformFeedbackBufferMode;
std::vector<gl::LinkedVarying> mTransformFeedbackLinkedVaryings;
sh::Attribute mShaderAttributes[gl::MAX_VERTEX_ATTRIBS];
int mShaderVersion;
};
}
#endif // LIBGLESV2_RENDERER_PROGRAMD3D_H_

Просмотреть файл

@ -16,19 +16,36 @@
namespace rx
{
template <typename VarT>
void FilterInactiveVariables(std::vector<VarT> *variableList)
{
ASSERT(variableList);
for (size_t varIndex = 0; varIndex < variableList->size();)
{
if (!(*variableList)[varIndex].staticUse)
{
variableList->erase(variableList->begin() + varIndex);
}
else
{
varIndex++;
}
}
}
void *ShaderD3D::mFragmentCompiler = NULL;
void *ShaderD3D::mVertexCompiler = NULL;
template <typename VarT>
const std::vector<VarT> *GetShaderVariables(const std::vector<VarT> *variableList)
{
// TODO: handle staticUse. for now, assume all returned variables are active.
ASSERT(variableList);
return variableList;
}
ShaderD3D::ShaderD3D(rx::Renderer *renderer)
: ShaderImpl(),
ShaderD3D::ShaderD3D(GLenum type, rx::Renderer *renderer)
: mType(type),
mRenderer(renderer),
mShaderVersion(100)
{
@ -111,12 +128,12 @@ void ShaderD3D::parseVaryings(void *compiler)
{
if (!mHlsl.empty())
{
const std::vector<sh::Varying> *activeVaryings = ShGetVaryings(compiler);
ASSERT(activeVaryings);
const std::vector<sh::Varying> *varyings = ShGetVaryings(compiler);
ASSERT(varyings);
for (size_t varyingIndex = 0; varyingIndex < activeVaryings->size(); varyingIndex++)
for (size_t varyingIndex = 0; varyingIndex < varyings->size(); varyingIndex++)
{
mVaryings.push_back(gl::PackedVarying((*activeVaryings)[varyingIndex]));
mVaryings.push_back(gl::PackedVarying((*varyings)[varyingIndex]));
}
mUsesMultipleRenderTargets = mHlsl.find("GL_USES_MRT") != std::string::npos;
@ -135,7 +152,7 @@ void ShaderD3D::parseVaryings(void *compiler)
void ShaderD3D::resetVaryingsRegisterAssignment()
{
for (unsigned int varyingIndex = 0; varyingIndex < mVaryings.size(); varyingIndex++)
for (size_t varyingIndex = 0; varyingIndex < mVaryings.size(); varyingIndex++)
{
mVaryings[varyingIndex].resetRegisterAssignment();
}
@ -148,9 +165,6 @@ void ShaderD3D::uncompile()
mHlsl.clear();
mInfoLog.clear();
// set by parseVaryings
mVaryings.clear();
mUsesMultipleRenderTargets = false;
mUsesFragColor = false;
mUsesFragData = false;
@ -164,8 +178,11 @@ void ShaderD3D::uncompile()
mUsesDiscardRewriting = false;
mUsesNestedBreak = false;
mActiveUniforms.clear();
mActiveInterfaceBlocks.clear();
mVaryings.clear();
mUniforms.clear();
mInterfaceBlocks.clear();
mActiveAttributes.clear();
mActiveOutputVariables.clear();
}
void ShaderD3D::compileToHLSL(void *compiler, const std::string &source)
@ -173,7 +190,7 @@ void ShaderD3D::compileToHLSL(void *compiler, const std::string &source)
// ensure the compiler is loaded
initializeCompiler();
int compileOptions = SH_OBJECT_CODE;
int compileOptions = (SH_OBJECT_CODE | SH_VARIABLES);
std::string sourcePath;
if (gl::perfActive())
{
@ -218,8 +235,8 @@ void ShaderD3D::compileToHLSL(void *compiler, const std::string &source)
size_t objCodeLen = 0;
ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &objCodeLen);
char* outputHLSL = new char[objCodeLen];
ShGetObjectCode(compiler, outputHLSL);
std::vector<char> outputHLSL(objCodeLen);
ShGetObjectCode(compiler, outputHLSL.data());
#ifdef _DEBUG
std::ostringstream hlslStream;
@ -237,40 +254,44 @@ void ShaderD3D::compileToHLSL(void *compiler, const std::string &source)
curPos = (nextLine == std::string::npos) ? std::string::npos : (nextLine + 1);
}
hlslStream << "\n\n";
hlslStream << outputHLSL;
hlslStream << outputHLSL.data();
mHlsl = hlslStream.str();
#else
mHlsl = outputHLSL;
mHlsl = outputHLSL.data();
#endif
SafeDeleteArray(outputHLSL);
mUniforms = *GetShaderVariables(ShGetUniforms(compiler));
mActiveUniforms = *GetShaderVariables(ShGetUniforms(compiler));
for (size_t uniformIndex = 0; uniformIndex < mActiveUniforms.size(); uniformIndex++)
for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); uniformIndex++)
{
const sh::Uniform &uniform = mActiveUniforms[uniformIndex];
const sh::Uniform &uniform = mUniforms[uniformIndex];
unsigned int index = -1;
bool result = ShGetUniformRegister(compiler, uniform.name.c_str(), &index);
UNUSED_ASSERTION_VARIABLE(result);
ASSERT(result);
if (uniform.staticUse)
{
unsigned int index = -1;
bool result = ShGetUniformRegister(compiler, uniform.name.c_str(), &index);
UNUSED_ASSERTION_VARIABLE(result);
ASSERT(result);
mUniformRegisterMap[uniform.name] = index;
mUniformRegisterMap[uniform.name] = index;
}
}
mActiveInterfaceBlocks = *GetShaderVariables(ShGetInterfaceBlocks(compiler));
mInterfaceBlocks = *GetShaderVariables(ShGetInterfaceBlocks(compiler));
for (size_t blockIndex = 0; blockIndex < mActiveInterfaceBlocks.size(); blockIndex++)
for (size_t blockIndex = 0; blockIndex < mInterfaceBlocks.size(); blockIndex++)
{
const sh::InterfaceBlock &interfaceBlock = mActiveInterfaceBlocks[blockIndex];
const sh::InterfaceBlock &interfaceBlock = mInterfaceBlocks[blockIndex];
unsigned int index = -1;
bool result = ShGetInterfaceBlockRegister(compiler, interfaceBlock.name.c_str(), &index);
UNUSED_ASSERTION_VARIABLE(result);
ASSERT(result);
if (interfaceBlock.staticUse)
{
unsigned int index = -1;
bool result = ShGetInterfaceBlockRegister(compiler, interfaceBlock.name.c_str(), &index);
UNUSED_ASSERTION_VARIABLE(result);
ASSERT(result);
mInterfaceBlockRegisterMap[interfaceBlock.name] = index;
mInterfaceBlockRegisterMap[interfaceBlock.name] = index;
}
}
}
else
@ -278,11 +299,11 @@ void ShaderD3D::compileToHLSL(void *compiler, const std::string &source)
size_t infoLogLen = 0;
ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &infoLogLen);
char* infoLog = new char[infoLogLen];
ShGetInfoLog(compiler, infoLog);
mInfoLog = infoLog;
std::vector<char> infoLog(infoLogLen);
ShGetInfoLog(compiler, infoLog.data());
mInfoLog = infoLog.data();
TRACE("\n%s", mInfoLog.c_str());
TRACE("\n%s", infoLog.data());
}
}
@ -325,7 +346,7 @@ bool ShaderD3D::compareVarying(const gl::PackedVarying &x, const gl::PackedVaryi
return true;
}
return gl::VariableSortOrder(x.type) <= gl::VariableSortOrder(y.type);
return gl::VariableSortOrder(x.type) < gl::VariableSortOrder(y.type);
}
unsigned int ShaderD3D::getUniformRegister(const std::string &uniformName) const
@ -340,15 +361,28 @@ unsigned int ShaderD3D::getInterfaceBlockRegister(const std::string &blockName)
return mInterfaceBlockRegisterMap.find(blockName)->second;
}
void *ShaderD3D::getCompiler()
{
if (mType == GL_VERTEX_SHADER)
{
return mVertexCompiler;
}
else
{
ASSERT(mType == GL_FRAGMENT_SHADER);
return mFragmentCompiler;
}
}
ShShaderOutput ShaderD3D::getCompilerOutputType(GLenum shader)
{
void *compiler = NULL;
switch (shader)
{
case GL_VERTEX_SHADER: compiler = mVertexCompiler; break;
case GL_FRAGMENT_SHADER: compiler = mFragmentCompiler; break;
default: UNREACHABLE(); return SH_HLSL9_OUTPUT;
case GL_VERTEX_SHADER: compiler = mVertexCompiler; break;
case GL_FRAGMENT_SHADER: compiler = mFragmentCompiler; break;
default: UNREACHABLE(); return SH_HLSL9_OUTPUT;
}
size_t outputType = 0;
@ -357,60 +391,52 @@ ShShaderOutput ShaderD3D::getCompilerOutputType(GLenum shader)
return static_cast<ShShaderOutput>(outputType);
}
VertexShaderD3D::VertexShaderD3D(rx::Renderer *renderer) : ShaderD3D(renderer)
{
}
VertexShaderD3D::~VertexShaderD3D()
{
}
VertexShaderD3D *VertexShaderD3D::makeVertexShaderD3D(ShaderImpl *impl)
{
ASSERT(HAS_DYNAMIC_TYPE(VertexShaderD3D*, impl));
return static_cast<VertexShaderD3D*>(impl);
}
const VertexShaderD3D *VertexShaderD3D::makeVertexShaderD3D(const ShaderImpl *impl)
{
ASSERT(HAS_DYNAMIC_TYPE(const VertexShaderD3D*, impl));
return static_cast<const VertexShaderD3D*>(impl);
}
bool VertexShaderD3D::compile(const std::string &source)
bool ShaderD3D::compile(const std::string &source)
{
uncompile();
compileToHLSL(mVertexCompiler, source);
parseAttributes();
parseVaryings(mVertexCompiler);
void *compiler = getCompiler();
compileToHLSL(compiler, source);
if (mType == GL_VERTEX_SHADER)
{
parseAttributes(compiler);
}
parseVaryings(compiler);
if (mType == GL_FRAGMENT_SHADER)
{
std::sort(mVaryings.begin(), mVaryings.end(), compareVarying);
const std::string &hlsl = getTranslatedSource();
if (!hlsl.empty())
{
mActiveOutputVariables = *GetShaderVariables(ShGetOutputVariables(compiler));
FilterInactiveVariables(&mActiveOutputVariables);
}
}
return !getTranslatedSource().empty();
}
void VertexShaderD3D::uncompile()
{
ShaderD3D::uncompile();
// set by ParseAttributes
mActiveAttributes.clear();
}
void VertexShaderD3D::parseAttributes()
void ShaderD3D::parseAttributes(void *compiler)
{
const std::string &hlsl = getTranslatedSource();
if (!hlsl.empty())
{
mActiveAttributes = *GetShaderVariables(ShGetAttributes(mVertexCompiler));
mActiveAttributes = *GetShaderVariables(ShGetAttributes(compiler));
FilterInactiveVariables(&mActiveAttributes);
}
}
int VertexShaderD3D::getSemanticIndex(const std::string &attributeName)
int ShaderD3D::getSemanticIndex(const std::string &attributeName) const
{
if (!attributeName.empty())
{
int semanticIndex = 0;
for (unsigned int attributeIndex = 0; attributeIndex < mActiveAttributes.size(); attributeIndex++)
for (size_t attributeIndex = 0; attributeIndex < mActiveAttributes.size(); attributeIndex++)
{
const sh::ShaderVariable &attribute = mActiveAttributes[attributeIndex];
@ -426,48 +452,4 @@ int VertexShaderD3D::getSemanticIndex(const std::string &attributeName)
return -1;
}
FragmentShaderD3D::FragmentShaderD3D(rx::Renderer *renderer) : ShaderD3D(renderer)
{
}
FragmentShaderD3D::~FragmentShaderD3D()
{
}
FragmentShaderD3D *FragmentShaderD3D::makeFragmentShaderD3D(ShaderImpl *impl)
{
ASSERT(HAS_DYNAMIC_TYPE(FragmentShaderD3D*, impl));
return static_cast<FragmentShaderD3D*>(impl);
}
const FragmentShaderD3D *FragmentShaderD3D::makeFragmentShaderD3D(const ShaderImpl *impl)
{
ASSERT(HAS_DYNAMIC_TYPE(const FragmentShaderD3D*, impl));
return static_cast<const FragmentShaderD3D*>(impl);
}
bool FragmentShaderD3D::compile(const std::string &source)
{
uncompile();
compileToHLSL(mFragmentCompiler, source);
parseVaryings(mFragmentCompiler);
std::sort(mVaryings.begin(), mVaryings.end(), compareVarying);
const std::string &hlsl = getTranslatedSource();
if (!hlsl.empty())
{
mActiveOutputVariables = *GetShaderVariables(ShGetOutputVariables(mFragmentCompiler));
return true;
}
return false;
}
void FragmentShaderD3D::uncompile()
{
ShaderD3D::uncompile();
mActiveOutputVariables.clear();
}
}

Просмотреть файл

@ -10,12 +10,14 @@
#define LIBGLESV2_RENDERER_SHADERD3D_H_
#include "libGLESv2/renderer/ShaderImpl.h"
#include "libGLESv2/renderer/Workarounds.h"
#include "libGLESv2/Shader.h"
#include <map>
namespace rx
{
class DynamicHLSL;
class Renderer;
class ShaderD3D : public ShaderImpl
@ -23,7 +25,7 @@ class ShaderD3D : public ShaderImpl
friend class DynamicHLSL;
public:
ShaderD3D(rx::Renderer *renderer);
ShaderD3D(GLenum type, rx::Renderer *renderer);
virtual ~ShaderD3D();
static ShaderD3D *makeShaderD3D(ShaderImpl *impl);
@ -38,31 +40,36 @@ class ShaderD3D : public ShaderImpl
void resetVaryingsRegisterAssignment();
unsigned int getUniformRegister(const std::string &uniformName) const;
unsigned int getInterfaceBlockRegister(const std::string &blockName) const;
int getSemanticIndex(const std::string &attributeName) const;
rx::D3DWorkaroundType getD3DWorkarounds() const;
int getShaderVersion() const { return mShaderVersion; }
bool usesDepthRange() const { return mUsesDepthRange; }
bool usesPointSize() const { return mUsesPointSize; }
std::vector<gl::PackedVarying> &getVaryings() { return mVaryings; }
const std::vector<sh::Uniform> &getUniforms() const { return mActiveUniforms; }
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
static void releaseCompiler();
static ShShaderOutput getCompilerOutputType(GLenum shader);
protected:
virtual bool compile(const std::string &source);
private:
DISALLOW_COPY_AND_ASSIGN(ShaderD3D);
void compileToHLSL(void *compiler, const std::string &source);
void parseVaryings(void *compiler);
void initializeCompiler();
void parseAttributes(void *compiler);
void *getCompiler();
static bool compareVarying(const gl::PackedVarying &x, const gl::PackedVarying &y);
static void *mFragmentCompiler;
static void *mVertexCompiler;
GLenum mType;
rx::Renderer *mRenderer;
std::vector<gl::PackedVarying> mVaryings;
int mShaderVersion;
bool mUsesMultipleRenderTargets;
@ -77,66 +84,12 @@ class ShaderD3D : public ShaderImpl
bool mUsesDiscardRewriting;
bool mUsesNestedBreak;
private:
DISALLOW_COPY_AND_ASSIGN(ShaderD3D);
void initializeCompiler();
std::string mHlsl;
std::string mInfoLog;
std::vector<sh::Uniform> mActiveUniforms;
std::vector<sh::InterfaceBlock> mActiveInterfaceBlocks;
std::map<std::string, unsigned int> mUniformRegisterMap;
std::map<std::string, unsigned int> mInterfaceBlockRegisterMap;
};
class VertexShaderD3D : public ShaderD3D
{
friend class DynamicHLSL;
public:
VertexShaderD3D(rx::Renderer *renderer);
virtual ~VertexShaderD3D();
static VertexShaderD3D *makeVertexShaderD3D(ShaderImpl *impl);
static const VertexShaderD3D *makeVertexShaderD3D(const ShaderImpl *impl);
virtual bool compile(const std::string &source);
virtual void uncompile();
int getSemanticIndex(const std::string &attributeName);
virtual const std::vector<sh::Attribute> &getActiveAttributes() const { return mActiveAttributes; }
private:
DISALLOW_COPY_AND_ASSIGN(VertexShaderD3D);
void parseAttributes();
std::vector<sh::Attribute> mActiveAttributes;
};
class FragmentShaderD3D : public ShaderD3D
{
friend class DynamicHLSL;
public:
FragmentShaderD3D(rx::Renderer *renderer);
virtual ~FragmentShaderD3D();
static FragmentShaderD3D *makeFragmentShaderD3D(ShaderImpl *impl);
static const FragmentShaderD3D *makeFragmentShaderD3D(const ShaderImpl *impl);
virtual bool compile(const std::string &source);
virtual void uncompile();
virtual const std::vector<sh::Attribute> &getOutputVariables() const { return mActiveOutputVariables; }
private:
DISALLOW_COPY_AND_ASSIGN(FragmentShaderD3D);
std::vector<sh::Attribute> mActiveOutputVariables;
};
}
#endif // LIBGLESV2_RENDERER_SHADERD3D_H_

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -24,11 +24,8 @@ namespace rx
class Image;
class ImageD3D;
class Renderer;
class TextureStorageInterface;
class TextureStorageInterface2D;
class TextureStorageInterfaceCube;
class TextureStorageInterface3D;
class TextureStorageInterface2DArray;
class RenderTarget;
class TextureStorage;
class TextureD3D : public TextureImpl
{
@ -38,7 +35,7 @@ class TextureD3D : public TextureImpl
static TextureD3D *makeTextureD3D(TextureImpl *texture);
virtual TextureStorageInterface *getNativeTexture();
virtual TextureStorage *getNativeTexture();
virtual void setUsage(GLenum usage) { mUsage = usage; }
bool hasDirtyImages() const { return mDirtyImages; }
@ -51,19 +48,40 @@ class TextureD3D : public TextureImpl
bool isImmutable() const { return mImmutable; }
virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index) = 0;
virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index) = 0;
// Returns an iterator over all "Images" for this particular Texture.
virtual gl::ImageIndexIterator imageIterator() const = 0;
// Returns an ImageIndex for a particular "Image". 3D Textures do not have images for
// slices of their depth texures, so 3D textures ignore the layer parameter.
virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const = 0;
virtual void generateMipmaps();
TextureStorage *getStorage();
Image *getBaseLevelImage() const;
protected:
void setImage(const gl::PixelUnpackState &unpack, GLenum type, const void *pixels, Image *image);
bool subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels, Image *image);
void setCompressedImage(GLsizei imageSize, const void *pixels, Image *image);
bool subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLsizei imageSize, const void *pixels, Image *image);
gl::Error setImage(const gl::PixelUnpackState &unpack, GLenum type, const void *pixels, Image *image);
gl::Error subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels, const gl::ImageIndex &index);
gl::Error setCompressedImage(GLsizei imageSize, const void *pixels, Image *image);
gl::Error subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLsizei imageSize, const void *pixels, Image *image);
bool isFastUnpackable(const gl::PixelUnpackState &unpack, GLenum sizedInternalFormat);
bool fastUnpackPixels(const gl::PixelUnpackState &unpack, const void *pixels, const gl::Box &destArea,
GLenum sizedInternalFormat, GLenum type, RenderTarget *destRenderTarget);
gl::Error fastUnpackPixels(const gl::PixelUnpackState &unpack, const void *pixels, const gl::Box &destArea,
GLenum sizedInternalFormat, GLenum type, RenderTarget *destRenderTarget);
GLint creationLevels(GLsizei width, GLsizei height, GLsizei depth) const;
int mipLevels() const;
virtual void initMipmapsImages() = 0;
bool isBaseImageZeroSize() const;
virtual bool ensureRenderTarget();
virtual TextureStorage *createCompleteStorage(bool renderTarget) const = 0;
virtual void setCompleteTexStorage(TextureStorage *newCompleteTexStorage) = 0;
Renderer *mRenderer;
@ -72,6 +90,7 @@ class TextureD3D : public TextureImpl
bool mDirtyImages;
bool mImmutable;
TextureStorage *mTexStorage;
private:
DISALLOW_COPY_AND_ASSIGN(TextureD3D);
@ -79,8 +98,6 @@ class TextureD3D : public TextureImpl
virtual void initializeStorage(bool renderTarget) = 0;
virtual void updateStorage() = 0;
virtual TextureStorageInterface *getBaseLevelStorage() = 0;
virtual const ImageD3D *getBaseLevelImage() const = 0;
};
class TextureD3D_2D : public TextureD3D
@ -90,6 +107,7 @@ class TextureD3D_2D : public TextureD3D
virtual ~TextureD3D_2D();
virtual Image *getImage(int level, int layer) const;
virtual Image *getImage(const gl::ImageIndex &index) const;
virtual GLsizei getLayerCount(int level) const;
GLsizei getWidth(GLint level) const;
@ -98,10 +116,10 @@ class TextureD3D_2D : public TextureD3D
GLenum getActualFormat(GLint level) const;
bool isDepth(GLint level) const;
virtual void setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
virtual void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual gl::Error setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual gl::Error subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
virtual void storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
@ -109,23 +127,21 @@ class TextureD3D_2D : public TextureD3D
virtual void bindTexImage(egl::Surface *surface);
virtual void releaseTexImage();
virtual void generateMipmaps();
virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index);
virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index);
virtual unsigned int getRenderTargetSerial(GLint level, GLint layer);
virtual RenderTarget *getRenderTarget(GLint level, GLint layer);
virtual gl::ImageIndexIterator imageIterator() const;
virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const;
private:
DISALLOW_COPY_AND_ASSIGN(TextureD3D_2D);
virtual void initializeStorage(bool renderTarget);
TextureStorageInterface2D *createCompleteStorage(bool renderTarget) const;
void setCompleteTexStorage(TextureStorageInterface2D *newCompleteTexStorage);
virtual TextureStorage *createCompleteStorage(bool renderTarget) const;
virtual void setCompleteTexStorage(TextureStorage *newCompleteTexStorage);
virtual void updateStorage();
bool ensureRenderTarget();
virtual TextureStorageInterface *getBaseLevelStorage();
virtual const ImageD3D *getBaseLevelImage() const;
virtual void initMipmapsImages();
bool isValidLevel(int level) const;
bool isLevelComplete(int level) const;
@ -133,9 +149,8 @@ class TextureD3D_2D : public TextureD3D
void updateStorageLevel(int level);
void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height);
void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
gl::Error commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
TextureStorageInterface2D *mTexStorage;
ImageD3D *mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
};
@ -146,6 +161,7 @@ class TextureD3D_Cube : public TextureD3D
virtual ~TextureD3D_Cube();
virtual Image *getImage(int level, int layer) const;
virtual Image *getImage(const gl::ImageIndex &index) const;
virtual GLsizei getLayerCount(int level) const;
virtual bool hasDirtyImages() const { return mDirtyImages; }
@ -155,10 +171,10 @@ class TextureD3D_Cube : public TextureD3D
GLenum getInternalFormat(GLint level, GLint layer) const;
bool isDepth(GLint level, GLint layer) const;
virtual void setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
virtual void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual gl::Error setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual gl::Error subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
virtual void storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
@ -166,23 +182,21 @@ class TextureD3D_Cube : public TextureD3D
virtual void bindTexImage(egl::Surface *surface);
virtual void releaseTexImage();
virtual void generateMipmaps();
virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index);
virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index);
virtual unsigned int getRenderTargetSerial(GLint level, GLint layer);
virtual RenderTarget *getRenderTarget(GLint level, GLint layer);
virtual gl::ImageIndexIterator imageIterator() const;
virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const;
private:
DISALLOW_COPY_AND_ASSIGN(TextureD3D_Cube);
virtual void initializeStorage(bool renderTarget);
TextureStorageInterfaceCube *createCompleteStorage(bool renderTarget) const;
void setCompleteTexStorage(TextureStorageInterfaceCube *newCompleteTexStorage);
virtual TextureStorage *createCompleteStorage(bool renderTarget) const;
virtual void setCompleteTexStorage(TextureStorage *newCompleteTexStorage);
virtual void updateStorage();
bool ensureRenderTarget();
virtual TextureStorageInterface *getBaseLevelStorage();
virtual const ImageD3D *getBaseLevelImage() const;
virtual void initMipmapsImages();
bool isValidFaceLevel(int faceIndex, int level) const;
bool isFaceLevelComplete(int faceIndex, int level) const;
@ -190,11 +204,9 @@ class TextureD3D_Cube : public TextureD3D
void updateStorageFaceLevel(int faceIndex, int level);
void redefineImage(int faceIndex, GLint level, GLenum internalformat, GLsizei width, GLsizei height);
void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
gl::Error commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
ImageD3D *mImageArray[6][gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
TextureStorageInterfaceCube *mTexStorage;
};
class TextureD3D_3D : public TextureD3D
@ -204,6 +216,7 @@ class TextureD3D_3D : public TextureD3D
virtual ~TextureD3D_3D();
virtual Image *getImage(int level, int layer) const;
virtual Image *getImage(const gl::ImageIndex &index) const;
virtual GLsizei getLayerCount(int level) const;
GLsizei getWidth(GLint level) const;
@ -212,10 +225,10 @@ class TextureD3D_3D : public TextureD3D
GLenum getInternalFormat(GLint level) const;
bool isDepth(GLint level) const;
virtual void setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
virtual void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual gl::Error setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual gl::Error subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
virtual void storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
@ -223,35 +236,30 @@ class TextureD3D_3D : public TextureD3D
virtual void bindTexImage(egl::Surface *surface);
virtual void releaseTexImage();
virtual void generateMipmaps();
virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index);
virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index);
virtual unsigned int getRenderTargetSerial(GLint level, GLint layer);
virtual RenderTarget *getRenderTarget(GLint level);
virtual RenderTarget *getRenderTarget(GLint level, GLint layer);
virtual gl::ImageIndexIterator imageIterator() const;
virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const;
private:
DISALLOW_COPY_AND_ASSIGN(TextureD3D_3D);
virtual void initializeStorage(bool renderTarget);
TextureStorageInterface3D *createCompleteStorage(bool renderTarget) const;
void setCompleteTexStorage(TextureStorageInterface3D *newCompleteTexStorage);
virtual TextureStorage *createCompleteStorage(bool renderTarget) const;
virtual void setCompleteTexStorage(TextureStorage *newCompleteTexStorage);
virtual void updateStorage();
bool ensureRenderTarget();
virtual TextureStorageInterface *getBaseLevelStorage();
virtual const ImageD3D *getBaseLevelImage() const;
virtual void initMipmapsImages();
bool isValidLevel(int level) const;
bool isLevelComplete(int level) const;
void updateStorageLevel(int level);
void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
gl::Error commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
ImageD3D *mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
TextureStorageInterface3D *mTexStorage;
};
class TextureD3D_2DArray : public TextureD3D
@ -261,18 +269,18 @@ class TextureD3D_2DArray : public TextureD3D
virtual ~TextureD3D_2DArray();
virtual Image *getImage(int level, int layer) const;
virtual Image *getImage(const gl::ImageIndex &index) const;
virtual GLsizei getLayerCount(int level) const;
GLsizei getWidth(GLint level) const;
GLsizei getHeight(GLint level) const;
GLsizei getLayers(GLint level) const;
GLenum getInternalFormat(GLint level) const;
bool isDepth(GLint level) const;
virtual void setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
virtual void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual gl::Error setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual gl::Error subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
virtual void storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
@ -280,23 +288,21 @@ class TextureD3D_2DArray : public TextureD3D
virtual void bindTexImage(egl::Surface *surface);
virtual void releaseTexImage();
virtual void generateMipmaps();
virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index);
virtual unsigned int getRenderTargetSerial(const gl::ImageIndex &index);
virtual unsigned int getRenderTargetSerial(GLint level, GLint layer);
virtual RenderTarget *getRenderTarget(GLint level, GLint layer);
virtual gl::ImageIndexIterator imageIterator() const;
virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const;
private:
DISALLOW_COPY_AND_ASSIGN(TextureD3D_2DArray);
virtual void initializeStorage(bool renderTarget);
TextureStorageInterface2DArray *createCompleteStorage(bool renderTarget) const;
void setCompleteTexStorage(TextureStorageInterface2DArray *newCompleteTexStorage);
virtual TextureStorage *createCompleteStorage(bool renderTarget) const;
virtual void setCompleteTexStorage(TextureStorage *newCompleteTexStorage);
virtual void updateStorage();
bool ensureRenderTarget();
virtual TextureStorageInterface *getBaseLevelStorage();
virtual const ImageD3D *getBaseLevelImage() const;
virtual void initMipmapsImages();
bool isValidLevel(int level) const;
bool isLevelComplete(int level) const;
@ -304,7 +310,7 @@ class TextureD3D_2DArray : public TextureD3D
void deleteImages();
void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint layerTarget, GLsizei width, GLsizei height);
gl::Error commitRect(GLint level, GLint xoffset, GLint yoffset, GLint layerTarget, GLsizei width, GLsizei height);
// Storing images as an array of single depth textures since D3D11 treats each array level of a
// Texture2D object as a separate subresource. Each layer would have to be looped over
@ -312,8 +318,6 @@ class TextureD3D_2DArray : public TextureD3D
// sense for the Image class to not have to worry about layer subresource as well as mip subresources.
GLsizei mLayerCounts[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
ImageD3D **mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
TextureStorageInterface2DArray *mTexStorage;
};
}

Просмотреть файл

@ -4,9 +4,7 @@
// found in the LICENSE file.
//
// TextureStorage.cpp: Implements the abstract rx::TextureStorageInterface class and its concrete derived
// classes TextureStorageInterface2D and TextureStorageInterfaceCube, which act as the interface to the
// GPU-side texture.
// TextureStorage.cpp: Shared members of abstract rx::TextureStorage class.
#include "libGLESv2/renderer/d3d/TextureStorage.h"
#include "libGLESv2/renderer/d3d/TextureD3D.h"
@ -19,162 +17,35 @@
namespace rx
{
unsigned int TextureStorageInterface::mCurrentTextureSerial = 1;
TextureStorageInterface::TextureStorageInterface()
unsigned int TextureStorage::mCurrentTextureSerial = 1;
TextureStorage::TextureStorage()
: mTextureSerial(issueTextureSerial()),
mInstance(NULL)
mFirstRenderTargetSerial(0),
mRenderTargetSerialsLayerStride(0)
{}
void TextureStorage::initializeSerials(unsigned int rtSerialsToReserve, unsigned int rtSerialsLayerStride)
{
mFirstRenderTargetSerial = gl::RenderbufferStorage::issueSerials(rtSerialsToReserve);
mRenderTargetSerialsLayerStride = rtSerialsLayerStride;
}
TextureStorageInterface::~TextureStorageInterface()
unsigned int TextureStorage::getRenderTargetSerial(const gl::ImageIndex &index) const
{
delete mInstance;
unsigned int layerOffset = (index.hasLayer() ? (static_cast<unsigned int>(index.layerIndex) * mRenderTargetSerialsLayerStride) : 0);
return mFirstRenderTargetSerial + static_cast<unsigned int>(index.mipIndex) + layerOffset;
}
bool TextureStorageInterface::isRenderTarget() const
{
return mInstance->isRenderTarget();
}
bool TextureStorageInterface::isManaged() const
{
return mInstance->isManaged();
}
unsigned int TextureStorageInterface::getTextureSerial() const
unsigned int TextureStorage::getTextureSerial() const
{
return mTextureSerial;
}
unsigned int TextureStorageInterface::issueTextureSerial()
unsigned int TextureStorage::issueTextureSerial()
{
return mCurrentTextureSerial++;
}
int TextureStorageInterface::getTopLevel() const
{
return mInstance->getTopLevel();
}
int TextureStorageInterface::getLevelCount() const
{
return mInstance->getLevelCount();
}
TextureStorageInterface2D::TextureStorageInterface2D(Renderer *renderer, SwapChain *swapchain)
{
mFirstRenderTargetSerial = gl::RenderbufferStorage::issueSerials(1);
mInstance = renderer->createTextureStorage2D(swapchain);
}
TextureStorageInterface2D::TextureStorageInterface2D(Renderer *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels)
{
mInstance = renderer->createTextureStorage2D(internalformat, renderTarget, width, height, levels);
mFirstRenderTargetSerial = gl::RenderbufferStorage::issueSerials(static_cast<GLuint>(mInstance->getLevelCount()));
}
TextureStorageInterface2D::~TextureStorageInterface2D()
{
}
RenderTarget *TextureStorageInterface2D::getRenderTarget(GLint level) const
{
return mInstance->getRenderTarget(level);
}
void TextureStorageInterface2D::generateMipmap(int level)
{
mInstance->generateMipmap(level);
}
unsigned int TextureStorageInterface2D::getRenderTargetSerial(GLint level) const
{
return mFirstRenderTargetSerial + level;
}
TextureStorageInterfaceCube::TextureStorageInterfaceCube(Renderer *renderer, GLenum internalformat, bool renderTarget, int size, int levels)
{
mInstance = renderer->createTextureStorageCube(internalformat, renderTarget, size, levels);
mFirstRenderTargetSerial = gl::RenderbufferStorage::issueSerials(static_cast<GLuint>(mInstance->getLevelCount() * 6));
}
TextureStorageInterfaceCube::~TextureStorageInterfaceCube()
{
}
RenderTarget *TextureStorageInterfaceCube::getRenderTarget(GLenum faceTarget, GLint level) const
{
return mInstance->getRenderTargetFace(faceTarget, level);
}
void TextureStorageInterfaceCube::generateMipmap(int faceIndex, int level)
{
mInstance->generateMipmap(faceIndex, level);
}
unsigned int TextureStorageInterfaceCube::getRenderTargetSerial(GLenum target, GLint level) const
{
return mFirstRenderTargetSerial + (level * 6) + gl::TextureCubeMap::targetToLayerIndex(target);
}
TextureStorageInterface3D::TextureStorageInterface3D(Renderer *renderer, GLenum internalformat, bool renderTarget,
GLsizei width, GLsizei height, GLsizei depth, int levels)
{
mInstance = renderer->createTextureStorage3D(internalformat, renderTarget, width, height, depth, levels);
mFirstRenderTargetSerial = gl::RenderbufferStorage::issueSerials(static_cast<GLuint>(mInstance->getLevelCount() * depth));
}
TextureStorageInterface3D::~TextureStorageInterface3D()
{
}
void TextureStorageInterface3D::generateMipmap(int level)
{
mInstance->generateMipmap(level);
}
RenderTarget *TextureStorageInterface3D::getRenderTarget(GLint level) const
{
return mInstance->getRenderTarget(level);
}
RenderTarget *TextureStorageInterface3D::getRenderTarget(GLint level, GLint layer) const
{
return mInstance->getRenderTargetLayer(level, layer);
}
unsigned int TextureStorageInterface3D::getRenderTargetSerial(GLint level, GLint layer) const
{
return mFirstRenderTargetSerial + static_cast<unsigned int>((layer * mInstance->getLevelCount()) + level);
}
TextureStorageInterface2DArray::TextureStorageInterface2DArray(Renderer *renderer, GLenum internalformat, bool renderTarget,
GLsizei width, GLsizei height, GLsizei depth, int levels)
{
mInstance = renderer->createTextureStorage2DArray(internalformat, renderTarget, width, height, depth, levels);
mFirstRenderTargetSerial = gl::RenderbufferStorage::issueSerials(static_cast<GLuint>(mInstance->getLevelCount() * depth));
}
TextureStorageInterface2DArray::~TextureStorageInterface2DArray()
{
}
void TextureStorageInterface2DArray::generateMipmap(int level)
{
mInstance->generateMipmap(level);
}
RenderTarget *TextureStorageInterface2DArray::getRenderTarget(GLint level, GLint layer) const
{
return mInstance->getRenderTargetLayer(level, layer);
}
unsigned int TextureStorageInterface2DArray::getRenderTargetSerial(GLint level, GLint layer) const
{
return mFirstRenderTargetSerial + static_cast<unsigned int>((layer * mInstance->getLevelCount()) + level);
}
}

Просмотреть файл

@ -4,17 +4,21 @@
// found in the LICENSE file.
//
// TextureStorage.h: Defines the abstract rx::TextureStorageInterface class and its concrete derived
// classes TextureStorageInterface2D and TextureStorageInterfaceCube, which act as the interface to the
// GPU-side texture.
// TextureStorage.h: Defines the abstract rx::TextureStorage class.
#ifndef LIBGLESV2_RENDERER_TEXTURESTORAGE_H_
#define LIBGLESV2_RENDERER_TEXTURESTORAGE_H_
#include "common/debug.h"
#include "libGLESv2/Error.h"
#include <GLES2/gl2.h>
namespace gl
{
struct ImageIndex;
}
namespace rx
{
class Renderer;
@ -24,7 +28,7 @@ class RenderTarget;
class TextureStorage
{
public:
TextureStorage() {};
TextureStorage();
virtual ~TextureStorage() {};
virtual int getTopLevel() const = 0;
@ -32,114 +36,27 @@ class TextureStorage
virtual bool isManaged() const = 0;
virtual int getLevelCount() const = 0;
virtual RenderTarget *getRenderTarget(int level) = 0;
virtual RenderTarget *getRenderTargetFace(GLenum faceTarget, int level) = 0;
virtual RenderTarget *getRenderTargetLayer(int mipLevel, int layer) = 0;
virtual void generateMipmap(int level) = 0;
virtual void generateMipmap(int face, int level) = 0;
virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index) = 0;
virtual void generateMipmap(const gl::ImageIndex &sourceIndex, const gl::ImageIndex &destIndex) = 0;
virtual gl::Error copyToStorage(TextureStorage *destStorage) = 0;
unsigned int getRenderTargetSerial(const gl::ImageIndex &index) const;
unsigned int getTextureSerial() const;
protected:
void initializeSerials(unsigned int rtSerialsToReserve, unsigned int rtSerialsLayerStride);
private:
DISALLOW_COPY_AND_ASSIGN(TextureStorage);
};
class TextureStorageInterface
{
public:
TextureStorageInterface();
virtual ~TextureStorageInterface();
TextureStorage *getStorageInstance() { return mInstance; }
unsigned int getTextureSerial() const;
virtual int getTopLevel() const;
virtual bool isRenderTarget() const;
virtual bool isManaged() const;
virtual int getLevelCount() const;
protected:
TextureStorage *mInstance;
private:
DISALLOW_COPY_AND_ASSIGN(TextureStorageInterface);
const unsigned int mTextureSerial;
static unsigned int issueTextureSerial();
static unsigned int mCurrentTextureSerial;
};
class TextureStorageInterface2D : public TextureStorageInterface
{
public:
TextureStorageInterface2D(Renderer *renderer, SwapChain *swapchain);
TextureStorageInterface2D(Renderer *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels);
virtual ~TextureStorageInterface2D();
void generateMipmap(int level);
RenderTarget *getRenderTarget(GLint level) const;
unsigned int getRenderTargetSerial(GLint level) const;
private:
DISALLOW_COPY_AND_ASSIGN(TextureStorageInterface2D);
unsigned int mFirstRenderTargetSerial;
};
class TextureStorageInterfaceCube : public TextureStorageInterface
{
public:
TextureStorageInterfaceCube(Renderer *renderer, GLenum internalformat, bool renderTarget, int size, int levels);
virtual ~TextureStorageInterfaceCube();
void generateMipmap(int faceIndex, int level);
RenderTarget *getRenderTarget(GLenum faceTarget, GLint level) const;
virtual unsigned int getRenderTargetSerial(GLenum target, GLint level) const;
private:
DISALLOW_COPY_AND_ASSIGN(TextureStorageInterfaceCube);
unsigned int mFirstRenderTargetSerial;
};
class TextureStorageInterface3D : public TextureStorageInterface
{
public:
TextureStorageInterface3D(Renderer *renderer, GLenum internalformat, bool renderTarget,
GLsizei width, GLsizei height, GLsizei depth, int levels);
virtual ~TextureStorageInterface3D();
void generateMipmap(int level);
RenderTarget *getRenderTarget(GLint level) const;
RenderTarget *getRenderTarget(GLint level, GLint layer) const;
virtual unsigned int getRenderTargetSerial(GLint level, GLint layer) const;
private:
DISALLOW_COPY_AND_ASSIGN(TextureStorageInterface3D);
unsigned int mFirstRenderTargetSerial;
};
class TextureStorageInterface2DArray : public TextureStorageInterface
{
public:
TextureStorageInterface2DArray(Renderer *renderer, GLenum internalformat, bool renderTarget,
GLsizei width, GLsizei height, GLsizei depth, int levels);
virtual ~TextureStorageInterface2DArray();
void generateMipmap(int level);
RenderTarget *getRenderTarget(GLint level, GLint layer) const;
virtual unsigned int getRenderTargetSerial(GLint level, GLint layer) const;
private:
DISALLOW_COPY_AND_ASSIGN(TextureStorageInterface2DArray);
unsigned int mFirstRenderTargetSerial;
unsigned int mRenderTargetSerialsLayerStride;
};
}

Просмотреть файл

@ -62,7 +62,7 @@ unsigned int VertexBufferInterface::getBufferSize() const
return mVertexBuffer->getBufferSize();
}
bool VertexBufferInterface::setBufferSize(unsigned int size)
gl::Error VertexBufferInterface::setBufferSize(unsigned int size)
{
if (mVertexBuffer->getBufferSize() == 0)
{
@ -84,34 +84,39 @@ void VertexBufferInterface::setWritePosition(unsigned int writePosition)
mWritePosition = writePosition;
}
bool VertexBufferInterface::discard()
gl::Error VertexBufferInterface::discard()
{
return mVertexBuffer->discard();
}
bool VertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset)
gl::Error VertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset)
{
gl::Error error(GL_NO_ERROR);
unsigned int spaceRequired;
if (!mVertexBuffer->getSpaceRequired(attrib, count, instances, &spaceRequired))
error = mVertexBuffer->getSpaceRequired(attrib, count, instances, &spaceRequired);
if (error.isError())
{
return false;
return error;
}
if (mWritePosition + spaceRequired < mWritePosition)
{
return false;
return gl::Error(GL_OUT_OF_MEMORY, "Internal error, new vertex buffer write position would overflow.");
}
if (!reserveSpace(mReservedSpace))
error = reserveSpace(mReservedSpace);
if (error.isError())
{
return false;
return error;
}
mReservedSpace = 0;
if (!mVertexBuffer->storeVertexAttributes(attrib, currentValue, start, count, instances, mWritePosition))
error = mVertexBuffer->storeVertexAttributes(attrib, currentValue, start, count, instances, mWritePosition);
if (error.isError())
{
return false;
return error;
}
if (outStreamOffset)
@ -124,21 +129,25 @@ bool VertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute &att
// Align to 16-byte boundary
mWritePosition = rx::roundUp(mWritePosition, 16u);
return true;
return gl::Error(GL_NO_ERROR);
}
bool VertexBufferInterface::reserveVertexSpace(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances)
gl::Error VertexBufferInterface::reserveVertexSpace(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances)
{
gl::Error error(GL_NO_ERROR);
unsigned int requiredSpace;
if (!mVertexBuffer->getSpaceRequired(attrib, count, instances, &requiredSpace))
error = mVertexBuffer->getSpaceRequired(attrib, count, instances, &requiredSpace);
if (error.isError())
{
return false;
return error;
}
// Protect against integer overflow
if (mReservedSpace + requiredSpace < mReservedSpace)
{
return false;
return gl::Error(GL_OUT_OF_MEMORY, "Unable to reserve %u extra bytes in internal vertex buffer, "
"it would result in an overflow.", requiredSpace);
}
mReservedSpace += requiredSpace;
@ -146,7 +155,7 @@ bool VertexBufferInterface::reserveVertexSpace(const gl::VertexAttribute &attrib
// Align to 16-byte boundary
mReservedSpace = rx::roundUp(mReservedSpace, 16u);
return true;
return gl::Error(GL_NO_ERROR);
}
VertexBuffer* VertexBufferInterface::getVertexBuffer() const
@ -197,25 +206,29 @@ StreamingVertexBufferInterface::~StreamingVertexBufferInterface()
{
}
bool StreamingVertexBufferInterface::reserveSpace(unsigned int size)
gl::Error StreamingVertexBufferInterface::reserveSpace(unsigned int size)
{
bool result = true;
unsigned int curBufferSize = getBufferSize();
if (size > curBufferSize)
{
result = setBufferSize(std::max(size, 3 * curBufferSize / 2));
gl::Error error = setBufferSize(std::max(size, 3 * curBufferSize / 2));
if (error.isError())
{
return error;
}
setWritePosition(0);
}
else if (getWritePosition() + size > curBufferSize)
{
if (!discard())
gl::Error error = discard();
if (error.isError())
{
return false;
return error;
}
setWritePosition(0);
}
return result;
return gl::Error(GL_NO_ERROR);
}
StaticVertexBufferInterface::StaticVertexBufferInterface(rx::Renderer *renderer) : VertexBufferInterface(renderer, false)
@ -251,46 +264,44 @@ bool StaticVertexBufferInterface::lookupAttribute(const gl::VertexAttribute &att
return false;
}
bool StaticVertexBufferInterface::reserveSpace(unsigned int size)
gl::Error StaticVertexBufferInterface::reserveSpace(unsigned int size)
{
unsigned int curSize = getBufferSize();
if (curSize == 0)
{
setBufferSize(size);
return true;
return setBufferSize(size);
}
else if (curSize >= size)
{
return true;
return gl::Error(GL_NO_ERROR);
}
else
{
UNREACHABLE(); // Static vertex buffers can't be resized
return false;
UNREACHABLE();
return gl::Error(GL_INVALID_OPERATION, "Internal error, Static vertex buffers can't be resized.");
}
}
bool StaticVertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset)
gl::Error StaticVertexBufferInterface::storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset)
{
unsigned int streamOffset;
if (VertexBufferInterface::storeVertexAttributes(attrib, currentValue, start, count, instances, &streamOffset))
gl::Error error = VertexBufferInterface::storeVertexAttributes(attrib, currentValue, start, count, instances, &streamOffset);
if (error.isError())
{
size_t attributeOffset = static_cast<size_t>(attrib.offset) % ComputeVertexAttributeStride(attrib);
VertexElement element = { attrib.type, attrib.size, ComputeVertexAttributeStride(attrib), attrib.normalized, attrib.pureInteger, attributeOffset, streamOffset };
mCache.push_back(element);
if (outStreamOffset)
{
*outStreamOffset = streamOffset;
}
return true;
return error;
}
else
size_t attributeOffset = static_cast<size_t>(attrib.offset) % ComputeVertexAttributeStride(attrib);
VertexElement element = { attrib.type, attrib.size, ComputeVertexAttributeStride(attrib), attrib.normalized, attrib.pureInteger, attributeOffset, streamOffset };
mCache.push_back(element);
if (outStreamOffset)
{
return false;
*outStreamOffset = streamOffset;
}
return gl::Error(GL_NO_ERROR);
}
}

Просмотреть файл

@ -11,6 +11,7 @@
#define LIBGLESV2_RENDERER_VERTEXBUFFER_H_
#include "common/angleutils.h"
#include "libGLESv2/Error.h"
#include <GLES2/gl2.h>
@ -33,16 +34,16 @@ class VertexBuffer
VertexBuffer();
virtual ~VertexBuffer();
virtual bool initialize(unsigned int size, bool dynamicUsage) = 0;
virtual gl::Error initialize(unsigned int size, bool dynamicUsage) = 0;
virtual bool storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
GLint start, GLsizei count, GLsizei instances, unsigned int offset) = 0;
virtual bool getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances,
unsigned int *outSpaceRequired) const = 0;
virtual gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
GLint start, GLsizei count, GLsizei instances, unsigned int offset) = 0;
virtual gl::Error getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances,
unsigned int *outSpaceRequired) const = 0;
virtual unsigned int getBufferSize() const = 0;
virtual bool setBufferSize(unsigned int size) = 0;
virtual bool discard() = 0;
virtual gl::Error setBufferSize(unsigned int size) = 0;
virtual gl::Error discard() = 0;
unsigned int getSerial() const;
@ -62,14 +63,14 @@ class VertexBufferInterface
VertexBufferInterface(rx::Renderer *renderer, bool dynamic);
virtual ~VertexBufferInterface();
bool reserveVertexSpace(const gl::VertexAttribute &attribute, GLsizei count, GLsizei instances);
gl::Error reserveVertexSpace(const gl::VertexAttribute &attribute, GLsizei count, GLsizei instances);
unsigned int getBufferSize() const;
unsigned int getSerial() const;
virtual bool storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset);
virtual gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset);
bool directStoragePossible(const gl::VertexAttribute &attrib,
const gl::VertexAttribCurrentValueData &currentValue) const;
@ -77,14 +78,14 @@ class VertexBufferInterface
VertexBuffer* getVertexBuffer() const;
protected:
virtual bool reserveSpace(unsigned int size) = 0;
virtual gl::Error reserveSpace(unsigned int size) = 0;
unsigned int getWritePosition() const;
void setWritePosition(unsigned int writePosition);
bool discard();
gl::Error discard();
bool setBufferSize(unsigned int size);
gl::Error setBufferSize(unsigned int size);
private:
DISALLOW_COPY_AND_ASSIGN(VertexBufferInterface);
@ -105,7 +106,7 @@ class StreamingVertexBufferInterface : public VertexBufferInterface
~StreamingVertexBufferInterface();
protected:
bool reserveSpace(unsigned int size);
gl::Error reserveSpace(unsigned int size);
};
class StaticVertexBufferInterface : public VertexBufferInterface
@ -114,13 +115,13 @@ class StaticVertexBufferInterface : public VertexBufferInterface
explicit StaticVertexBufferInterface(rx::Renderer *renderer);
~StaticVertexBufferInterface();
bool storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset);
gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib, const gl::VertexAttribCurrentValueData &currentValue,
GLint start, GLsizei count, GLsizei instances, unsigned int *outStreamOffset);
bool lookupAttribute(const gl::VertexAttribute &attribute, unsigned int* outStreamFffset);
protected:
bool reserveSpace(unsigned int size);
gl::Error reserveSpace(unsigned int size);
private:
struct VertexElement

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше