video_helper.cpp 1.0 KB

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