video_helper.cpp 1.0 KB

123456789101112131415161718192021222324252627282930
  1. // Copyright 2021 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "shader_recompiler/exception.h"
  5. #include "shader_recompiler/frontend/maxwell/translate/impl/video_helper.h"
  6. namespace Shader::Maxwell {
  7. IR::U32 ExtractVideoOperandValue(IR::IREmitter& ir, const IR::U32& value, VideoWidth width,
  8. u32 selector, bool is_signed) {
  9. switch (width) {
  10. case VideoWidth::Byte:
  11. case VideoWidth::Unknown:
  12. return ir.BitFieldExtract(value, ir.Imm32(selector * 8), ir.Imm32(8), is_signed);
  13. case VideoWidth::Short:
  14. return ir.BitFieldExtract(value, ir.Imm32(selector * 16), ir.Imm32(16), is_signed);
  15. case VideoWidth::Word:
  16. return value;
  17. default:
  18. throw NotImplementedException("Unknown VideoWidth {}", width);
  19. }
  20. }
  21. VideoWidth GetVideoSourceWidth(VideoWidth width, bool is_immediate) {
  22. // immediates must be 16-bit format.
  23. return is_immediate ? VideoWidth::Short : width;
  24. }
  25. } // namespace Shader::Maxwell