#include "../Include/Common.h"
#include "../Include/InfoSink.h"
#include "../Include/Types.h"
#include "gl_types.h"
#include "iomapper.h"
#include "SymbolTable.h"
namespace glslang {
class TVarGatherTraverser : public TLiveTraverser { … };
class TVarSetTraverser : public TLiveTraverser
{ … };
struct TNotifyUniformAdaptor
{ … };
struct TNotifyInOutAdaptor
{ … };
struct TResolverUniformAdaptor { … };
struct TResolverInOutAdaptor { … };
struct TSymbolValidater
{ … };
struct TSlotCollector { … };
TDefaultIoResolverBase::TDefaultIoResolverBase(const TIntermediate& intermediate)
: … { … }
int TDefaultIoResolverBase::getBaseBinding(EShLanguage stage, TResourceType res, unsigned int set) const { … }
const std::vector<std::string>& TDefaultIoResolverBase::getResourceSetBinding(EShLanguage stage) const { … }
bool TDefaultIoResolverBase::doAutoBindingMapping() const { … }
bool TDefaultIoResolverBase::doAutoLocationMapping() const { … }
TDefaultIoResolverBase::TSlotSet::iterator TDefaultIoResolverBase::findSlot(int set, int slot) { … }
bool TDefaultIoResolverBase::checkEmpty(int set, int slot) { … }
int TDefaultIoResolverBase::reserveSlot(int set, int slot, int size) { … }
int TDefaultIoResolverBase::getFreeSlot(int set, int base, int size) { … }
int TDefaultIoResolverBase::resolveSet(EShLanguage stage, TVarEntryInfo& ent) { … }
int TDefaultIoResolverBase::resolveUniformLocation(EShLanguage , TVarEntryInfo& ent) { … }
int TDefaultIoResolverBase::resolveInOutLocation(EShLanguage stage, TVarEntryInfo& ent) { … }
int TDefaultIoResolverBase::resolveInOutComponent(EShLanguage , TVarEntryInfo& ent) { … }
int TDefaultIoResolverBase::resolveInOutIndex(EShLanguage , TVarEntryInfo& ent) { … }
uint32_t TDefaultIoResolverBase::computeTypeLocationSize(const TType& type, EShLanguage stage) { … }
TResourceType TDefaultGlslIoResolver::getResourceType(const glslang::TType& type) { … }
TDefaultGlslIoResolver::TDefaultGlslIoResolver(const TIntermediate& intermediate)
: … { … }
int TDefaultGlslIoResolver::resolveInOutLocation(EShLanguage stage, TVarEntryInfo& ent) { … }
int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage , TVarEntryInfo& ent) { … }
int TDefaultGlslIoResolver::resolveBinding(EShLanguage stage, TVarEntryInfo& ent) { … }
void TDefaultGlslIoResolver::beginResolve(EShLanguage stage) { … }
void TDefaultGlslIoResolver::endResolve(EShLanguage ) { … }
void TDefaultGlslIoResolver::beginCollect(EShLanguage stage) { … }
void TDefaultGlslIoResolver::endCollect(EShLanguage ) { … }
void TDefaultGlslIoResolver::reserverStorageSlot(TVarEntryInfo& ent, TInfoSink& infoSink) { … }
void TDefaultGlslIoResolver::reserverResourceSlot(TVarEntryInfo& ent, TInfoSink& infoSink) { … }
struct TDefaultIoResolver : public TDefaultIoResolverBase { … };
#ifdef ENABLE_HLSL
struct TDefaultHlslIoResolver : public TDefaultIoResolverBase {
TDefaultHlslIoResolver(const TIntermediate& intermediate) : TDefaultIoResolverBase(intermediate) { }
bool validateBinding(EShLanguage , TVarEntryInfo& ) override { return true; }
TResourceType getResourceType(const glslang::TType& type) override {
if (isUavType(type)) {
return EResUav;
}
if (isSrvType(type)) {
return EResTexture;
}
if (isSamplerType(type)) {
return EResSampler;
}
if (isUboType(type)) {
return EResUbo;
}
return EResCount;
}
int resolveBinding(EShLanguage stage, TVarEntryInfo& ent) override {
const TType& type = ent.symbol->getType();
const int set = getLayoutSet(type);
TResourceType resource = getResourceType(type);
if (resource < EResCount) {
if (type.getQualifier().hasBinding()) {
return ent.newBinding = reserveSlot(set, getBaseBinding(stage, resource, set) + type.getQualifier().layoutBinding);
} else if (ent.live && doAutoBindingMapping()) {
return ent.newBinding = getFreeSlot(set, getBaseBinding(stage, resource, set));
}
}
return ent.newBinding = -1;
}
};
#endif
bool TIoMapper::addStage(EShLanguage stage, TIntermediate& intermediate, TInfoSink& infoSink, TIoMapResolver* resolver) { … }
bool TGlslIoMapper::addStage(EShLanguage stage, TIntermediate& intermediate, TInfoSink& infoSink, TIoMapResolver* resolver) { … }
bool TGlslIoMapper::doMap(TIoMapResolver* resolver, TInfoSink& infoSink) { … }
}