Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ jobs:
esac

- name: "Run tests"
if: matrix.architecture_string != 'Win32'
run: |
if [[ "${{ matrix.target }}" == windows* ]]; then
cd "bin/${{ matrix.cmake_preset }}"
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
IF (${DAS_ENABLE_DLL})
# relative RPATH from install location
if(UNIXAPPLE)
if(APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path/../lib")
set(CMAKE_MACOSX_RPATH ON)
elseif(UNIX)
Expand Down
10 changes: 2 additions & 8 deletions examples/pathTracer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,11 @@ TARGET_LINK_LIBRARIES(path_tracer libDaScriptAot ${DAS_MODULES_LIBS})
ADD_DEPENDENCIES(path_tracer libDaScriptAot pathtracer_dasAotStub)
SETUP_CPP11(path_tracer)

install(DIRECTORY ${PROJECT_SOURCE_DIR}/examples/pathTracer
DESTINATION ${DAS_INSTALL_EXAMPLESDIR}
FILES_MATCHING
PATTERN "*.das"
)

IF(NOT ${DAS_BGFX_DISABLED})
install(FILES
${PROJECT_SOURCE_DIR}/examples/pathTracer/toy_path_tracer_bgfx.das
${PROJECT_SOURCE_DIR}/examples/pathTracer/toy_path_tracer_bgfx_hdr.das
DESTINATION ${DAS_INSTALL_EXAMPLESDIR}
DESTINATION ${DAS_INSTALL_EXAMPLESDIR}/pathTracer
)
ENDIF()

Expand All @@ -48,4 +42,4 @@ install(FILES
${PROJECT_SOURCE_DIR}/examples/pathTracer/toy_path_tracer_opengl.das
${PROJECT_SOURCE_DIR}/examples/pathTracer/toy_path_tracer_opengl_hdr.das
${PROJECT_SOURCE_DIR}/examples/pathTracer/toy_path_tracer_profile.das
DESTINATION ${DAS_INSTALL_EXAMPLESDIR})
DESTINATION ${DAS_INSTALL_EXAMPLESDIR}/pathTracer)
31 changes: 30 additions & 1 deletion examples/test/unit_tests/bitfields.das
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,49 @@ bitfield bits123 {
three,
}

bitfield bits123_8 : uint8 {
one,
two,
three,
}

bitfield bits123_16 : uint16 {
one,
two,
three,
}

bitfield bits123_64 : uint64 {
one,
two,
three,
}

[sideeffects]
def bit(b : int) {
return bitfield(1 << b)
}

// Use global mutable variables to avoid optimizations.
var t : bitfield < one; two; three > = bitfield(1 << 1) | bit(2)
var bf_8 : bits123_8 = bits123_8.one
var bf_16 : bits123_16 = bits123_16.two
var bf : bits123 = bits123.three
var bf_64 : bits123_64 = bits123_64.one

[export]
def test() {
var t : bitfield < one; two; three > = bitfield(1 << 1) | bit(2)
assert(!t.one && t.two && t.three)
assert("{t}" == "(two|three)")
t ^= bitfield(1 << 1)
assert(!t.one && !t.two && t.three)
assert(t == bits123.three)
t |= bitfield(1 << 0)
assert(t.one && !t.two && t.three)

assert(bf_8.one && !bf_8.two)
assert(bf_16.two && !bf_8.three)
assert(bf.three && !bf.one)
assert(bf_64.one && !bf_64.two)
return true
}
2 changes: 1 addition & 1 deletion modules/dasGlfw
2 changes: 1 addition & 1 deletion modules/dasImgui
Submodule dasImgui updated 1 files
+0 −18 CMakeLists.txt
8 changes: 8 additions & 0 deletions modules/dasLLVM/daslib/llvm_boost.das
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ class PrimitiveTypes {
return LLVMPointerType(t_int8, 0u)
}

def ConstI8(val : int8) {
return LLVMConstInt(t_int8, val |> uint64(), 0);
}

def ConstI16(val : int16) {
return LLVMConstInt(t_int16, val |> uint64, 0);
}

def ConstI32(val : uint64) {
return LLVMConstInt(t_int32, val, 0);
}
Expand Down
8 changes: 8 additions & 0 deletions modules/dasLLVM/daslib/llvm_dll_utils.das
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ class UidGen : AstVisitor {
add(get_ptr(expr))
}

def override preVisitExprMakeBlock(expr : smart_ptr<ExprMakeBlock>) {
add(get_ptr(expr))
}

}

class public UidNodes {
Expand Down Expand Up @@ -166,6 +170,10 @@ class public UidNodes {
return get_base(get_ptr(blk), "block_{get_mangled_name(blk)}")
}

def public get_block_ann(mk_blk : smart_ptr<ExprMakeBlock>) : DllName {
return get_base(get_ptr(mk_blk), "makeblock_ann")
}

def reset(var func : Function?) {
thisFunc = func
}
Expand Down
43 changes: 36 additions & 7 deletions modules/dasLLVM/daslib/llvm_jit.das
Original file line number Diff line number Diff line change
Expand Up @@ -4343,10 +4343,26 @@ class LlvmJitVisitor : AstVisitor {

def override visitExprField(expr : smart_ptr<ExprField>) : ExpressionPtr {
var field_ptr : LLVMOpaqueValue?;
if (expr.value._type.isBitfield) {
assume value_t = expr.value._type
if (value_t.isBitfield) {
let mask = 1u << uint(expr.fieldIndex)
let mand = LLVMBuildAnd(g_builder, getE(expr.value), types.ConstI32(uint64(mask)), "")
let if_not_zero = LLVMBuildICmp(g_builder, LLVMIntPredicate.LLVMIntNE, mand, types.ConstI32(uint64(0)), "")
var llvm_mask : LLVMOpaqueValue? = null
var llvm_zero : LLVMOpaqueValue? = null
if (value_t.baseType == Type.tBitfield) {
llvm_mask = types.ConstI32(uint64(mask))
llvm_zero = types.ConstI32(uint64(0))
} elif (value_t.baseType == Type.tBitfield8) {
llvm_mask = types.ConstI8(mask |> int8)
llvm_zero = types.ConstI8(0 |> int8)
} elif (value_t.baseType == Type.tBitfield16) {
llvm_mask = types.ConstI16(mask |> int16)
llvm_zero = types.ConstI16(0 |> int16)
} elif (value_t.baseType == Type.tBitfield64) {
llvm_mask = types.ConstI64(uint64(mask))
llvm_zero = types.ConstI64(uint64(0))
}
let mand = LLVMBuildAnd(g_builder, getE(expr.value), llvm_mask, "")
let if_not_zero = LLVMBuildICmp(g_builder, LLVMIntPredicate.LLVMIntNE, mand, llvm_zero, "")
var res_type = type_to_llvm_type(expr._type)
var res = build_select(if_not_zero, res_type) <| $() {
return LLVMConstInt(types.t_int1, uint64(1), 0)
Expand Down Expand Up @@ -4954,14 +4970,21 @@ class LlvmJitVisitor : AstVisitor {
// call jit_make_block
var blk_ptr = LLVMBuildPointerCast(g_builder, blk, LLVMPointerType(g_t_block, 0u), "")
let argStackTop = (expr._block as ExprBlock).stackTop
let annotationData = (expr._block as ExprBlock).annotationData
let annotationData = (expr._block as ExprBlock).annotationData |> uint64()
var ann_data_ptr : LLVMOpaqueValue? = null
if (annotationData != 0 |> uint64()) {
ann_data_ptr = LLVMBuildPtrToInt(g_builder, save_address_global(uid.get_block_ann(expr), unsafe(reinterpret<void?>(annotationData))), types.LLVMIntPtrType(), "")
} else {
// Just an optimization.
ann_data_ptr = LLVMConstInt(types.t_int64, 0 |> uint64(), 0)
}
let null_ptr = LLVMConstPointerNull(types.LLVMVoidPtrType())
let func_ptr = LLVMBuildPointerCast(g_builder, blk_make.func, types.LLVMVoidPtrType(), "")
let impl_ptr = LLVMBuildPointerCast(g_builder, blk_make.impl, types.LLVMVoidPtrType(), "")
var params = fixed_array(
blk_ptr, // blk
types.ConstI32(uint64(argStackTop)), // argStackTop
LLVMConstInt(types.t_int64, uint64(annotationData), 0), // annotation data
types.ConstI32(uint64(argStackTop)), // argStackTop
ann_data_ptr, // annotation data
func_ptr, // bodyNode
impl_ptr, // jitImpl
null_ptr, // TODO: funcInfo
Expand Down Expand Up @@ -5012,13 +5035,14 @@ class LlvmJitVisitor : AstVisitor {

// ExprConstInt8
def override visitExprConstInt8(expr : smart_ptr<ExprConstInt8>) : ExpressionPtr {
setE(expr, types.ConstI8(expr.value))
setE(expr, LLVMConstInt(types.t_int8, uint64(expr.value), 0))
return expr
}

// ExprConstInt16
def override visitExprConstInt16(expr : smart_ptr<ExprConstInt16>) : ExpressionPtr {
setE(expr, LLVMConstInt(types.t_int16, uint64(expr.value), 0))
setE(expr, types.ConstI16(expr.value))
return expr
}

Expand Down Expand Up @@ -5839,6 +5863,11 @@ class ResolveExternVisitor : AstVisitor {

def override preVisitExprMakeBlock(expr : smart_ptr<ExprMakeBlock>) : void {
thisBlock |> push <| get_ptr(unsafe(reinterpret<smart_ptr<ExprBlock>> expr._block))

let annotationData = (expr._block as ExprBlock).annotationData
if (annotationData != 0 |> uint64()) {
dll.set_glob_address(uid.get_block_ann(expr), unsafe(reinterpret<void?>(annotationData)))
}
}

def override visitExprMakeBlock(expr : smart_ptr<ExprMakeBlock>) : ExpressionPtr {
Expand Down
15 changes: 6 additions & 9 deletions modules/dasOpenGL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@ IF(NOT DAS_OPENGL_INCLUDED)
install(FILES ${DAS_OPENGL_EXAMPLES}
DESTINATION ${DAS_INSTALL_EXAMPLESDIR}/opengl
)
install(FILES ${PROJECT_SOURCE_DIR}/modules/dasOpenGL/examples/image.png
install(FILES
${PROJECT_SOURCE_DIR}/modules/dasOpenGL/examples/image.png
# This mesh was taken from BGFX `modules/dasBGFX/bgfx/bgfx/examples/assets/meshes`
${PROJECT_SOURCE_DIR}/modules/dasOpenGL/examples/orb.obj
# This font was taken from BGFX `modules/dasBGFX/bgfx/bgfx/examples/runtime/font`
${PROJECT_SOURCE_DIR}/modules/dasOpenGL/examples/droidsansmono.ttf
DESTINATION ${DAS_INSTALL_EXAMPLESDIR}/media
)

IF (((${DAS_BGFX_DISABLED}) OR (NOT DEFINED DAS_BGFX_DISABLED)) AND (EXISTS "${PROJECT_SOURCE_DIR}/modules/dasBGFX/bgfx"))
install(FILES
${PROJECT_SOURCE_DIR}/modules/dasBGFX/bgfx/bgfx/examples/assets/meshes/orb.obj
${PROJECT_SOURCE_DIR}/modules/dasBGFX/bgfx/bgfx/examples/runtime/font/droidsansmono.ttf
DESTINATION ${DAS_INSTALL_EXAMPLESDIR}/media
)
ENDIF ()
ENDIF()
2 changes: 1 addition & 1 deletion modules/dasOpenGL/examples/06_hello_ttf.das
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def main {
create_ttf_objects()
font <- load_ttf([
fname = "droidsansmono.ttf",
path1 = "{get_das_root()}/modules/dasBGFX/bgfx/bgfx/examples/runtime/font",
path1 = "{get_das_root()}/modules/dasOpenGL/examples/",
path2 = "{get_das_root()}/examples/media",
canfail = true
])
Expand Down
2 changes: 1 addition & 1 deletion modules/dasOpenGL/examples/09_hello_mesh.das
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def main {
var program = create_shader_program(@@vs_preview, @@fs_preview)
// var mesh <- gen_sphere(32,16,false) |> create_geometry_fragment
var mesh <- load_obj_mesh("orb.obj",
"{get_das_root()}/modules/dasBGFX/bgfx/bgfx/examples/assets/meshes",
"{get_das_root()}/modules/dasOpenGL/examples/",
"{get_das_root()}/examples/media"
) |> create_geometry_fragment
let checkerboard_texture = gen_image_checkerboard(16, 16, 0xff404040, 0xff808080) |> create_texture
Expand Down
Binary file added modules/dasOpenGL/examples/droidsansmono.ttf
Binary file not shown.
Loading