Skip to content

Commit

Permalink
refactor: srmd (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tohrusky authored Dec 30, 2023
1 parent 0b8eeaf commit f920a91
Show file tree
Hide file tree
Showing 16 changed files with 1,118 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "src/pybind11"]
path = src/pybind11
url = https://github.com/pybind/pybind11
[submodule "src/srmd-ncnn-vulkan"]
path = src/srmd-ncnn-vulkan
url = https://github.com/nihui/srmd-ncnn-vulkan
[submodule "src/srmd-ncnn-vulkan/src/ncnn"]
path = src/srmd-ncnn-vulkan/src/ncnn
url = https://github.com/Tencent/ncnn
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ repos:
rev: v1.7.1
hooks:
- id: mypy
args: [src, tests]
args: [src/srmd_ncnn_py, tests]
pass_filenames: false
additional_dependencies:
- types-requests
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ license = {text = "BSD-3-Clause"}
name = "srmd-ncnn-py"
readme = "README.md"
requires-python = ">=3.8"
version = "1.3.2"
version = "2.0.0"

[project.urls]
Homepage = "https://github.com/Final2x/srmd-ncnn-py"
Expand Down
1 change: 0 additions & 1 deletion src/srmd-ncnn-vulkan
Submodule srmd-ncnn-vulkan deleted from 40604f
21 changes: 21 additions & 0 deletions src/srmd-ncnn-vulkan/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 nihui

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 22 additions & 0 deletions src/srmd-ncnn-vulkan/src/generate_shader_comp_header.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

# must define SHADER_COMP_HEADER SHADER_SRC

file(READ ${SHADER_SRC} comp_data)

# skip leading comment
string(FIND "${comp_data}" "#version" version_start)
string(SUBSTRING "${comp_data}" ${version_start} -1 comp_data)

# remove whitespace
string(REGEX REPLACE "\n +" "\n" comp_data "${comp_data}")

get_filename_component(SHADER_SRC_NAME_WE ${SHADER_SRC} NAME_WE)

# text to hex
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${SHADER_SRC_NAME_WE}.text2hex.txt "${comp_data}")
file(READ ${CMAKE_CURRENT_BINARY_DIR}/${SHADER_SRC_NAME_WE}.text2hex.txt comp_data_hex HEX)
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," comp_data_hex ${comp_data_hex})
string(FIND "${comp_data_hex}" "," tail_comma REVERSE)
string(SUBSTRING "${comp_data_hex}" 0 ${tail_comma} comp_data_hex)

file(WRITE ${SHADER_COMP_HEADER} "static const char ${SHADER_SRC_NAME_WE}_comp_data[] = {${comp_data_hex}};\n")
1 change: 1 addition & 0 deletions src/srmd-ncnn-vulkan/src/ncnn
Submodule ncnn added at b4ba20
Loading

0 comments on commit f920a91

Please sign in to comment.