Table of Contents

Class MgfxSamplerStateResolver

Namespace
ShadowDusk.Core
Assembly
ShadowDusk.Core.dll

Resolves parsed sampler_state { … } members into the baked MgfxSamplerStateInfo mgfxc writes into the .mgfx sampler record (Phase 43, F9). Mirrors mgfxc v3.8.2's TPGParser/SamplerStateInfo exactly:

  • State is only present (hasState = 1) when at least one recognized state member is set — a block containing only Texture = <…> resolves to null.
  • Defaults are MonoGame's SamplerState constructor values: Wrap addressing, white border color, MaxAnisotropy 4, MaxMipLevel 0, LOD bias 0.
  • The separate Min/Mag/Mip filter members combine into ONE MonoGame TextureFilter via mgfxc's UpdateSamplerState if-chain ("None" treated like "Point"); MipFilter = None additionally forces MipMapLevelOfDetailBias = -16 (mgfxc's only mip-disable mechanism).
  • Unrecognized KEYS are ignored (the parser accepted them; fxc tolerates many D3D9 states MonoGame has no analog for), but a recognized key with an unparseable VALUE fails loudly (SD0024) — mgfxc's grammar would reject it, so silently dropping it would diverge from the mgfxc build.
public static class MgfxSamplerStateResolver
Inheritance
MgfxSamplerStateResolver
Inherited Members

Methods

Resolve(string, IEnumerable<(string Key, string Value)>, string)

Resolves a sampler's parsed state entries. Returns Ok(null) when no recognized state member is present.

public static Result<MgfxSamplerStateInfo?, ShaderError> Resolve(string samplerName, IEnumerable<(string Key, string Value)> entries, string sourceFile)

Parameters

samplerName string

The sampler's name (diagnostics only).

entries IEnumerable<(string Key, string Value)>

The raw (key, value) pairs from the sampler_state block, in source order.

sourceFile string

The source file (diagnostics only).

Returns

Result<MgfxSamplerStateInfo, ShaderError>