Skip to content

Commit 2af3118

Browse files
committed
Update on "[ET-VK] Fake u16vecn for devserver"
## Context Copy-pasted from the newly added `maybe_fake_u16vec3` function in the codegen script: > There is a latency benefit to using u16vecn variables to store texture position variables instead of ivecn, likely due to reduced register pressure. However, SwiftShader does not support 16 bit integer types in shaders, so this is a crude way to fallback to using ivecn to store texture positions so that testing with SwiftShader is still possible. Differential Revision: [D65501674](https://our.internmc.facebook.com/intern/diff/D65501674/) [ghstack-poisoned]
1 parent 77f3f0e commit 2af3118

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

backends/vulkan/runtime/gen_vulkan_spv.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def __init__(
540540
env: Dict[Any, Any],
541541
glslc_path: Optional[str],
542542
glslc_flags: str = "",
543-
fake_u16vecn: bool = False,
543+
replace_u16vecn: bool = False,
544544
) -> None:
545545
if isinstance(src_dir_paths, str):
546546
self.src_dir_paths = [src_dir_paths]
@@ -550,7 +550,7 @@ def __init__(
550550
self.env = env
551551
self.glslc_path = glslc_path
552552
self.glslc_flags = glslc_flags
553-
self.fake_u16vecn = fake_u16vecn
553+
self.replace_u16vecn = replace_u16vecn
554554

555555
self.glsl_src_files: Dict[str, str] = {}
556556
self.template_yaml_files: List[str] = []
@@ -707,15 +707,15 @@ def constructOutputMap(self) -> None:
707707
self.create_shader_params(),
708708
)
709709

710-
def maybe_fake_u16vecn(self, input_text: str) -> str:
710+
def maybe_replace_u16vecn(self, input_text: str) -> str:
711711
"""
712712
There is a latency benefit to using u16vecn variables to store texture position
713713
variables instead of ivecn, likely due to reduced register pressure. However,
714714
SwiftShader does not support 16 bit integer types in shaders, so this is a crude
715715
way to fallback to using ivecn to store texture positions so that testing with
716716
SwiftShader is still possible.
717717
"""
718-
if not self.fake_u16vecn:
718+
if not self.replace_u16vecn:
719719
return input_text
720720
if "codegen-nosub" in input_text:
721721
return input_text
@@ -734,7 +734,7 @@ def process_shader(shader_paths_pair):
734734

735735
with codecs.open(source_glsl, "r", encoding="utf-8") as input_file:
736736
input_text = input_file.read()
737-
input_text = self.maybe_fake_u16vecn(input_text)
737+
input_text = self.maybe_replace_u16vecn(input_text)
738738
output_text = preprocess(input_text, shader_params)
739739

740740
glsl_out_path = os.path.join(output_dir, f"{shader_name}.glsl")
@@ -1048,7 +1048,7 @@ def main(argv: List[str]) -> int:
10481048
parser.add_argument("-c", "--glslc-path", required=True, help="")
10491049
parser.add_argument("-t", "--tmp-dir-path", required=True, help="/tmp")
10501050
parser.add_argument("-o", "--output-path", required=True, help="")
1051-
parser.add_argument("--fake-u16vecn", action="store_true", default=False)
1051+
parser.add_argument("--replace-u16vecn", action="store_true", default=False)
10521052
parser.add_argument("--optimize_size", action="store_true", help="")
10531053
parser.add_argument("--optimize", action="store_true", help="")
10541054
parser.add_argument(
@@ -1079,8 +1079,8 @@ def main(argv: List[str]) -> int:
10791079
options.glsl_paths,
10801080
env,
10811081
options.glslc_path,
1082-
glslc_flags,
1083-
fake_u16vecn=options.fake_u16vecn,
1082+
glslc_flags=glslc_flags,
1083+
replace_u16vecn=options.replace_u16vecn,
10841084
)
10851085
output_spv_files = shader_generator.generateSPV(options.tmp_dir_path)
10861086

backends/vulkan/targets.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def vulkan_spv_shader_lib(name, spv_filegroups, is_fbcode = False):
2727
select({
2828
"DEFAULT": "",
2929
"ovr_config//os:android": "--optimize",
30-
"ovr_config//os:linux": "--fake-u16vecn",
30+
"ovr_config//os:linux": "--replace-u16vecn",
3131
})
3232
)
3333

0 commit comments

Comments
 (0)