Skip to content

Commit 0753056

Browse files
committed
Address default value blob review feedback
1 parent c479554 commit 0753056

5 files changed

Lines changed: 560 additions & 69 deletions

File tree

include/slang-deprecated.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,14 +710,30 @@ extern "C"
710710
SlangReflectionVariable* var,
711711
SlangSession* globalSession,
712712
char const* name);
713-
/** DEPRECATED: use `spReflectionVariable_GetDefaultValueBlob` instead. */
713+
/** DEPRECATED: use `spReflectionVariable_GetDefaultValueBlob` and check for a null blob
714+
* instead. */
714715
SLANG_API bool spReflectionVariable_HasDefaultValue(SlangReflectionVariable* inVar);
715716
/** DEPRECATED: use `spReflectionVariable_GetDefaultValueBlob` instead. */
716717
SLANG_API SlangResult
717718
spReflectionVariable_GetDefaultValueInt(SlangReflectionVariable* inVar, int64_t* rs);
718719
/** DEPRECATED: use `spReflectionVariable_GetDefaultValueBlob` instead. */
719720
SLANG_API SlangResult
720721
spReflectionVariable_GetDefaultValueFloat(SlangReflectionVariable* inVar, float* rs);
722+
/** Retrieves a variable's default initializer as a blob.
723+
*
724+
* If no explicit initializer exists, returns `SLANG_OK` and sets `*outBlob` to `nullptr`.
725+
* On success with an initializer, `*outBlob` receives an `ISlangBlob*` with an added
726+
* reference.
727+
*
728+
* Supported types include scalar values, vectors, matrices, fixed-size arrays,
729+
* structs/aggregates, and enums. The blob stores scalar-layout bytes in natural scalar/field
730+
* order without aggregate padding; bool values are emitted as 4-byte values to match Slang's
731+
* GPU scalar layout. Matrices are emitted row-by-row, struct base fields are emitted before
732+
* derived fields, and enum values use the enum's underlying tag type.
733+
*
734+
* Returns `SLANG_E_INVALID_ARG` for invalid arguments and `SLANG_E_NOT_AVAILABLE` when the
735+
* initializer cannot be represented as a default-value blob.
736+
*/
721737
SLANG_API SlangResult
722738
spReflectionVariable_GetDefaultValueBlob(SlangReflectionVariable* inVar, ISlangBlob** outBlob);
723739
SLANG_API SlangReflectionGeneric* spReflectionVariable_GetGenericContainer(

include/slang.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,7 +3113,7 @@ struct VariableReflection
31133113
return findAttributeByName(globalSession, name);
31143114
}
31153115

3116-
/// Deprecated: use getDefaultValueBlob instead.
3116+
/// Deprecated: call getDefaultValueBlob and check for a null blob instead.
31173117
SLANG_DEPRECATED bool hasDefaultValue()
31183118
{
31193119
return spReflectionVariable_HasDefaultValue((SlangReflectionVariable*)this);
@@ -3137,10 +3137,19 @@ struct VariableReflection
31373137
return spReflectionVariable_GetDefaultValueFloat((SlangReflectionVariable*)this, value);
31383138
}
31393139

3140-
/// Gets default value bytes for scalar and aggregate variables with explicit initializers.
3141-
/// If the variable has no explicit initializer, this succeeds with a null blob.
3142-
/// The returned blob stores values in natural scalar/field order, without constant-buffer
3143-
/// padding.
3140+
/// Gets default initializer bytes for variables with representable initializers.
3141+
///
3142+
/// If the variable has no explicit initializer, this succeeds with a null blob. On success with
3143+
/// an initializer, `outBlob` receives an `ISlangBlob*` with an added reference.
3144+
///
3145+
/// Supported types include scalar values, vectors, matrices, fixed-size arrays,
3146+
/// structs/aggregates, and enums. The returned blob stores scalar-layout bytes in natural
3147+
/// scalar/field order without aggregate padding; bool values are emitted as 4-byte values to
3148+
/// match Slang's GPU scalar layout. Matrices are emitted row-by-row, struct base fields are
3149+
/// emitted before derived fields, and enum values use the enum's underlying tag type.
3150+
///
3151+
/// Returns SLANG_E_INVALID_ARG for invalid arguments and SLANG_E_NOT_AVAILABLE when an
3152+
/// initializer cannot be represented as a default-value blob.
31443153
SlangResult getDefaultValueBlob(ISlangBlob** outBlob)
31453154
{
31463155
return spReflectionVariable_GetDefaultValueBlob((SlangReflectionVariable*)this, outBlob);

0 commit comments

Comments
 (0)