Skip to content

Commit

Permalink
a few more tweaks for #3681
Browse files Browse the repository at this point in the history
expose TIoMapper::setAutoPushConstantBlock()
add overload for MapToSpirvToolsEnv() that takes TIntermediate instead of SpvVersion.
  • Loading branch information
mbechard authored and arcady-lunarg committed Sep 25, 2024
1 parent 96899e0 commit 4a9f088
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
5 changes: 5 additions & 0 deletions SPIRV/SpvTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ spv_target_env MapToSpirvToolsEnv(const SpvVersion& spvVersion, spv::SpvBuildLog
return spv_target_env::SPV_ENV_UNIVERSAL_1_0;
}

spv_target_env MapToSpirvToolsEnv(const glslang::TIntermediate& intermediate, spv::SpvBuildLogger* logger)
{
return MapToSpirvToolsEnv(intermediate.getSpv(), logger);
}

// Callback passed to spvtools::Optimizer::SetMessageConsumer
void OptimizerMesssageConsumer(spv_message_level_t level, const char *source,
const spv_position_t &position, const char *message)
Expand Down
1 change: 1 addition & 0 deletions SPIRV/SpvTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class TIntermediate;

// Translate glslang's view of target versioning to what SPIRV-Tools uses.
GLSLANG_EXPORT spv_target_env MapToSpirvToolsEnv(const SpvVersion& spvVersion, spv::SpvBuildLogger* logger);
GLSLANG_EXPORT spv_target_env MapToSpirvToolsEnv(const glslang::TIntermediate& intermediate, spv::SpvBuildLogger* logger);

// Use the SPIRV-Tools disassembler to print SPIR-V using a SPV_ENV_UNIVERSAL_1_3 environment.
GLSLANG_EXPORT void SpirvToolsDisassemble(std::ostream& out, const std::vector<unsigned int>& spirv);
Expand Down
15 changes: 0 additions & 15 deletions glslang/Include/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,21 +307,6 @@ typedef TVector<TTypeLoc> TTypeList;

typedef TVector<TString*> TIdentifierList;

//
// Following are a series of helper enums for managing layouts and qualifiers,
// used for TPublicType, TType, others.
//

enum TLayoutPacking {
ElpNone,
ElpShared, // default, but different than saying nothing
ElpStd140,
ElpStd430,
ElpPacked,
ElpScalar,
ElpCount // If expanding, see bitfield width below
};

enum TLayoutMatrix {
ElmNone,
ElmRowMajor,
Expand Down
3 changes: 2 additions & 1 deletion glslang/MachineIndependent/iomapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,11 @@ class TGlslIoMapper : public TIoMapper {
virtual ~TGlslIoMapper();
// If set, the uniform block with the given name will be changed to be backed by
// push_constant if it's size is <= maxSize
void setAutoPushConstantBlock(const char* name, unsigned int maxSize, TLayoutPacking packing) {
bool setAutoPushConstantBlock(const char* name, unsigned int maxSize, TLayoutPacking packing) override {
autoPushConstantBlockName = name;
autoPushConstantMaxSize = maxSize;
autoPushConstantBlockPacking = packing;
return true;
}
// grow the reflection stage by stage
bool addStage(EShLanguage, TIntermediate&, TInfoSink&, TIoMapResolver*) override;
Expand Down
16 changes: 16 additions & 0 deletions glslang/Public/ShaderLang.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,21 @@ typedef enum {
LAST_ELEMENT_MARKER(EShTargetLanguageVersionCount = 7),
} EShTargetLanguageVersion;

//
// Following are a series of helper enums for managing layouts and qualifiers,
// used for TPublicType, TType, others.
//

enum TLayoutPacking {
ElpNone,
ElpShared, // default, but different than saying nothing
ElpStd140,
ElpStd430,
ElpPacked,
ElpScalar,
ElpCount // If expanding, see bitfield width below
};

struct TInputLanguage {
EShSource languageFamily; // redundant information with other input, this one overrides when not EShSourceNone
EShLanguage stage; // redundant information with other input, this one overrides when not EShSourceNone
Expand Down Expand Up @@ -847,6 +862,7 @@ class TIoMapper {
// grow the reflection stage by stage
bool virtual addStage(EShLanguage, TIntermediate&, TInfoSink&, TIoMapResolver*);
bool virtual doMap(TIoMapResolver*, TInfoSink&) { return true; }
bool virtual setAutoPushConstantBlock(const char*, unsigned int, TLayoutPacking) { return false; }
};

// Get the default GLSL IO mapper
Expand Down

0 comments on commit 4a9f088

Please sign in to comment.