Fix compiler warnings and hints.

This commit is contained in:
Alberto Torres 2025-03-18 18:34:54 +01:00
parent 8ef4748412
commit 2219f8c9ad
10 changed files with 17 additions and 26 deletions

View file

@ -48,7 +48,6 @@ import std/tables
import std/times
import std/os
import arr_ref # for SliceMem
import sugar
type LoadableResourceStatus* = enum
NotStarted

View file

@ -1,6 +1,4 @@
import std/strformat
{.compile("oiio.cpp","-std=c++14").}
{.passL: "-lOpenImageIO -lOpenImageIO_Util".}

View file

@ -39,9 +39,10 @@ proc swap_lines(p: pointer, line_stride, line_count: int) {.gcsafe.}
import std/strformat
import vmath except Quat, quat
import arr_ref
import float16
const myouConvertHdrToFloat16 {.booldefine.} = not defined(myouUseOpenImageIO)
when myouConvertHdrToFloat16:
import float16
when defined(myouUseOpenImageIO):
import oiio
@ -104,9 +105,10 @@ template toOpenArrayByte(p: pointer, a,b: untyped): untyped =
# template toOpenArray[T](p: pointer, a,b: untyped): untyped =
# cast[ptr UncheckedArray[T]](p).toOpenArray(a,b)
proc f32_to_f16(source: ptr UncheckedArray[float32], dest: ptr UncheckedArray[Float16], len: int) =
for i in 0 ..< len:
dest[i] = source[i].tofloat16(clamp=true)
when myouConvertHdrToFloat16:
proc f32_to_f16(source: ptr UncheckedArray[float32], dest: ptr UncheckedArray[Float16], len: int) =
for i in 0 ..< len:
dest[i] = source[i].tofloat16(clamp=true)
proc getDimensionsFormat*(p: pointer, len: int, min_channels=0): (int, int, TextureFormat) =
when defined(myouUseOpenImageIO):

View file

@ -52,8 +52,6 @@ import std/monotimes
import std/marshal
import std/bitops
import std/json
import std/uri
import std/os
# TODO: don't import it here
from ../platform/gl import nil
@ -80,11 +78,7 @@ template has_astc_support: bool = gl.GLAD_GL_OES_texture_compression_astc or
const myouMinTextureChannels {.intdefine.} = 0
const myouEngineNumTextureThreads {.intdefine.} = 4
const myouBC7VerboseMode {.booldefine.} = false
const myouAllCacheFilesExist {.booldefine.} = false
const myouLoadUncompressedTextures {.booldefine.} = false
when defined(myouAllCacheFilesExist):
import ../platform/platform
import std/strutils
template u32(x: untyped): uint32 = cast[uint32](x)
@ -202,13 +196,13 @@ when defined(myouUseBC7Encoder):
)
callback(tex, KtxInfoParts(info: info, parts: parts), data_refs)
template first(bs: BlockSize): uint8 =
bs.uint8 shr 4'u8
template second(bs: BlockSize): uint8 =
bs.uint8 and 0xf'u8
when defined(myouUseAstcEncoder):
template first(bs: BlockSize): uint8 =
bs.uint8 shr 4'u8
template second(bs: BlockSize): uint8 =
bs.uint8 and 0xf'u8
proc atsc_compress*(tex: Texture, pixels: SliceMem[byte], callback: CallbackCompressed, blk_size: BlockSize, speed: EncodingSpeed) =
let profile = case tex.format.component_type:
of UByte:

View file

@ -32,7 +32,6 @@
import ../types
import ../platform/gl
import ../postprocessing/effect_shaders
import arr_ref
import vmath except Quat, quat
@ -65,7 +64,6 @@ import ../objects/gameobject
import ../objects/mesh
import ../platform/platform
import ../shadows/shadow_common
import ../quat
import ../scene
import ../util
import ./framebuffer

View file

@ -284,7 +284,8 @@ proc idPropertiesToJsonTable(prop: FNode): Table[string, JsonNode] =
of 1: # int
result[name] = %val
of 5: # array
let subtype = prop.subtype.i8[0]
# let subtype = prop.subtype.i8[0]
discard
of 8: # float
let f = cast[ptr float64](prop.data.val.i32[0].addr)[]
result[name] = %f

View file

@ -33,7 +33,6 @@
import ../types
import vmath except Quat, quat
import ../util
import ../graphics/material
when defined(nimdoc):
type TYPES* = LightType | Light

View file

@ -23,7 +23,7 @@ proc get_program_info_log*(program: GLuint): string =
when compileOption("threads"):
let main_thread_id = getThreadID()
template handleError(x: untyped, t: string) =
template handleError(x: untyped, t: untyped) =
when compileOption("threads"):
assert main_thread_id == getThreadID()
try:

View file

@ -50,7 +50,8 @@ when compileOption("threads"):
from loadable import terminateLoadableWorkerThreads
from ../gpu_formats/texture_optimize import terminateTextureWorkerThreads
func c_strstr(haystack, needle: cstring): cstring {.importc: "strstr", header: "<string.h>".}
when not defined(release) and defined(myouForceAstc):
func c_strstr(haystack, needle: cstring): cstring {.importc: "strstr", header: "<string.h>".}
proc screen*(window: Window): Screen {.inline.} =
cast[Screen](window.getWindowUserPointer)

View file

@ -41,7 +41,6 @@ import ../graphics/ubo
import ../objects/mesh
import ../objects/gameobject
import ../quat
import ../scene
import ../util
import ./shadow_common