Provide an API for accessing the uniform array.

TRAC #22239
Signed-off-by: Daniel Koch
Signed-off-by: Shannon Woods
Author: Nicolas Capens

git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1625 736b8ea6-26fd-11df-bfd4-992fa37f6226
This commit is contained in:
daniel@transgaming.com 2012-12-20 21:12:22 +00:00
Родитель f4d9feff26
Коммит 043da138a7
7 изменённых файлов: 53 добавлений и 6 удалений

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

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2012 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.
//
@ -36,7 +36,7 @@ extern "C" {
// Version number for shader translation API.
// It is incremented everytime the API changes.
#define SH_VERSION 107
#define SH_VERSION 108
//
// The names of the following enums have been derived by replacing GL prefix
@ -115,7 +115,8 @@ typedef enum {
SH_MAPPED_NAME_MAX_LENGTH = 0x6000,
SH_NAME_MAX_LENGTH = 0x6001,
SH_HASHED_NAME_MAX_LENGTH = 0x6002,
SH_HASHED_NAMES_COUNT = 0x6003
SH_HASHED_NAMES_COUNT = 0x6003,
SH_ACTIVE_UNIFORMS_ARRAY = 0x6004
} ShShaderInfo;
// Compile options.
@ -384,6 +385,18 @@ COMPILER_EXPORT void ShGetNameHashingEntry(const ShHandle handle,
char* name,
char* hashedName);
// Returns a parameter from a compiled shader.
// Parameters:
// handle: Specifies the compiler
// pname: Specifies the parameter to query.
// The following parameters are defined:
// SH_ACTIVE_UNIFORMS_ARRAY: an STL vector of active uniforms. Valid only for
// HLSL output.
// params: Requested parameter
COMPILER_EXPORT void ShGetInfoPointer(const ShHandle handle,
ShShaderInfo pname,
void** params);
#ifdef __cplusplus
}
#endif

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

@ -115,6 +115,11 @@ TInfoSinkBase &OutputHLSL::getBodyStream()
return mBody;
}
const ActiveUniforms &OutputHLSL::getUniforms()
{
return mActiveUniforms;
}
int OutputHLSL::vectorSize(const TType &type) const
{
int elementSize = type.isMatrix() ? type.getNominalSize() : 1;

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

@ -31,6 +31,7 @@ class OutputHLSL : public TIntermTraverser
void output();
TInfoSinkBase &getBodyStream();
const ActiveUniforms &getUniforms();
TString typeString(const TType &type);
static TString qualifierString(TQualifier qualifier);

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

@ -26,6 +26,7 @@
class LongNameMap;
class TCompiler;
class TDependencyGraph;
class TranslatorHLSL;
//
// Helper function to identify specs that are based on the WebGL spec,
@ -41,6 +42,7 @@ public:
TShHandleBase();
virtual ~TShHandleBase();
virtual TCompiler* getAsCompiler() { return 0; }
virtual TranslatorHLSL* getAsTranslatorHLSL() { return 0; }
protected:
// Memory allocator. Allocates and tracks memory required by the compiler.

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

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2012 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.
//
@ -14,6 +14,7 @@
#include "compiler/InitializeDll.h"
#include "compiler/preprocessor/length_limits.h"
#include "compiler/ShHandle.h"
#include "compiler/TranslatorHLSL.h"
//
// This is the platform independent interface between an OGL driver
@ -345,3 +346,21 @@ void ShGetNameHashingEntry(const ShHandle handle,
// To be on the safe side in case the source is longer than expected.
hashedName[len] = '\0';
}
void ShGetInfoPointer(const ShHandle handle, ShShaderInfo pname, void** params)
{
if (!handle || !params)
return;
TShHandleBase* base = static_cast<TShHandleBase*>(handle);
TranslatorHLSL* translator = base->getAsTranslatorHLSL();
if (!translator) return;
switch(pname)
{
case SH_ACTIVE_UNIFORMS_ARRAY:
*params = (void*)&translator->getUniforms();
break;
default: UNREACHABLE();
}
}

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

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2012 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.
//
@ -20,4 +20,5 @@ void TranslatorHLSL::translate(TIntermNode *root)
sh::OutputHLSL outputHLSL(parseContext);
outputHLSL.output();
mActiveUniforms = outputHLSL.getUniforms();
}

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

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2012 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.
//
@ -8,13 +8,19 @@
#define COMPILER_TRANSLATORHLSL_H_
#include "compiler/ShHandle.h"
#include "compiler/Uniform.h"
class TranslatorHLSL : public TCompiler {
public:
TranslatorHLSL(ShShaderType type, ShShaderSpec spec);
virtual TranslatorHLSL *getAsTranslatorHLSL() { return this; }
const sh::ActiveUniforms &getUniforms() { return mActiveUniforms; }
protected:
virtual void translate(TIntermNode* root);
sh::ActiveUniforms mActiveUniforms;
};
#endif // COMPILER_TRANSLATORHLSL_H_