BsSamplerOverrides.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsRenderBeastPrerequisites.h"
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup RenderBeast
  8. * @{
  9. */
  10. /** Contains data about an overridden sampler states for a single pass stage. */
  11. struct StageSamplerOverrides
  12. {
  13. UINT32* stateOverrides;
  14. UINT32 numStates;
  15. };
  16. /** Contains data about an overridden sampler states for a single pass. */
  17. struct PassSamplerOverrides
  18. {
  19. StageSamplerOverrides* stages;
  20. UINT32 numStages;
  21. };
  22. /** Contains data about a single overriden sampler state. */
  23. struct SamplerOverride
  24. {
  25. UINT32 paramIdx;
  26. UINT64 originalStateHash;
  27. SPtr<SamplerStateCore> state;
  28. };
  29. /** Contains data about an overridden sampler states in the entire material. */
  30. struct MaterialSamplerOverrides
  31. {
  32. PassSamplerOverrides* passes;
  33. SamplerOverride* overrides;
  34. UINT32 numPasses;
  35. UINT32 numOverrides;
  36. UINT32 refCount;
  37. };
  38. /** Helper class for generating sampler overrides. */
  39. class BS_BSRND_EXPORT SamplerOverrideUtility
  40. {
  41. public:
  42. /**
  43. * Generates a set of sampler overrides for the specified set of GPU program parameters. Overrides are generates
  44. * according to the provided render options.
  45. */
  46. static MaterialSamplerOverrides* generateSamplerOverrides(const SPtr<ShaderCore>& shader,
  47. const SPtr<MaterialParamsCore>& params,
  48. const SPtr<GpuParamsSetCore>& paramsSet,
  49. const SPtr<RenderBeastOptions>& options);
  50. /** Destroys sampler overrides previously generated with generateSamplerOverrides(). */
  51. static void destroySamplerOverrides(MaterialSamplerOverrides* overrides);
  52. /**
  53. * Checks if the provided sampler state requires an override, in case the render options have requirements not
  54. * fulfilled by current sampler state (for example filtering type).
  55. */
  56. static bool checkNeedsOverride(const SPtr<SamplerStateCore>& samplerState,
  57. const SPtr<RenderBeastOptions>& options);
  58. /**
  59. * Generates a new sampler state override using the provided state as the basis. Overridden properties are taken
  60. * from the provided render options.
  61. */
  62. static SPtr<SamplerStateCore> generateSamplerOverride(const SPtr<SamplerStateCore>& samplerState,
  63. const SPtr<RenderBeastOptions>& options);
  64. };
  65. /** @} */
  66. }