Skip to content

Commit

Permalink
Merge pull request #100 from defold/update-1.9.0
Browse files Browse the repository at this point in the history
Update to Defold 1.9.0
  • Loading branch information
JCash committed Jun 12, 2024
2 parents 0b63b3c + 221d22e commit 5b66fb5
Show file tree
Hide file tree
Showing 95 changed files with 8,775 additions and 176 deletions.
1 change: 1 addition & 0 deletions .defignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/utils
8 changes: 4 additions & 4 deletions .github/workflows/bob.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ jobs:
run: java -jar bob.jar --platform=${{ matrix.platform }} bundle

# macOS is not technically needed for building, but we want to test bundling as well, since we're also testing the manifest merging
build_with_bob_macos:
build_with_bob_darwin:
strategy:
matrix:
platform: [arm64-macos, x86_64-macos]
platform: [arm64-macos, x86_64-macos, arm64-ios]
runs-on: macOS-latest

name: Build
Expand All @@ -118,6 +118,6 @@ jobs:
- name: Resolve libraries
run: java -jar bob.jar resolve --email a@b.com --auth 123456
- name: Build
run: java -jar bob.jar --platform=x86_64-macos --architectures=${{ matrix.platform }} build --archive --build-server=${{env.BUILD_SERVER}}
run: java -jar bob.jar --platform=${{ matrix.platform }} --architectures=${{ matrix.platform }} build --archive --build-server=${{env.BUILD_SERVER}}
- name: Bundle
run: java -jar bob.jar --platform=x86_64-macos --architectures=${{ matrix.platform }} bundle
run: java -jar bob.jar --platform=${{ matrix.platform }} --architectures=${{ matrix.platform }} bundle
13 changes: 7 additions & 6 deletions defold-rive/ext.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ platforms:

x86_64-linux:
context:
flags: ["-std=c++17"]
flags: ["-std=c++17", "-fno-rtti"]
excludeLibs: [graphics]
excludeSymbols: [GraphicsAdapterOpenGL]
symbols: [GraphicsAdapterVulkan]
Expand Down Expand Up @@ -37,7 +37,7 @@ platforms:

ios:
context:
flags: ["-std=c++17", "-fno-aligned-allocation"]
flags: ["-std=c++17", "-fno-aligned-allocation", "-fno-rtti"]
excludeLibs: [graphics]
excludeSymbols: [GraphicsAdapterOpenGL]
symbols: [GraphicsAdapterVulkan]
Expand All @@ -50,7 +50,8 @@ platforms:

android:
context:
excludeLibs: [graphics]
excludeSymbols: [GraphicsAdapterOpenGL]
symbols: [GraphicsAdapterVulkan]
libs: [graphics_vulkan]
excludeLibs: [graphics]
excludeSymbols: [GraphicsAdapterOpenGL]
symbols: [GraphicsAdapterVulkan]
libs: [graphics_vulkan]
flags: ["-std=c++17", "-fno-rtti"]
1 change: 1 addition & 0 deletions defold-rive/include/common/vertices.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ namespace dmRive
m2[2] = m4[1][0];
m2[3] = m4[1][1];

// This should be the translation
m2[4] = m4[3][0];
m2[5] = m4[3][1];
}
Expand Down
244 changes: 244 additions & 0 deletions defold-rive/include/private/defold_graphics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
// Copyright 2020-2024 The Defold Foundation
// Copyright 2014-2020 King
// Copyright 2009-2014 Ragnar Svensson, Christian Murray
// Licensed under the Defold License version 1.0 (the "License"); you may not use
// this file except in compliance with the License.
//
// You may obtain a copy of the License, together with FAQs at
// https://www.defold.com/license
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.

#ifndef DM_DEFOLD_GRAPHICS_H
#define DM_DEFOLD_GRAPHICS_H

#include <stdint.h>
#include <dmsdk/dlib/vmath.h>
#include <dmsdk/graphics/graphics.h>

namespace dmGraphics
{
// Texture filter
enum TextureFilter
{
TEXTURE_FILTER_DEFAULT = 0,
TEXTURE_FILTER_NEAREST = 1,
TEXTURE_FILTER_LINEAR = 2,
TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST = 3,
TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR = 4,
TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST = 5,
TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR = 6,
};

enum TextureUsageHint
{
TEXTURE_USAGE_HINT_NONE = 0,
TEXTURE_USAGE_HINT_SAMPLE = 1,
TEXTURE_USAGE_HINT_MEMORYLESS = 2,
TEXTURE_USAGE_HINT_INPUT = 4,
TEXTURE_USAGE_HINT_COLOR = 8,
TEXTURE_USAGE_HINT_STORAGE = 16,
};

enum TextureType
{
TEXTURE_TYPE_2D = 0,
TEXTURE_TYPE_2D_ARRAY = 1,
TEXTURE_TYPE_CUBE_MAP = 2,
TEXTURE_TYPE_IMAGE_2D = 3,
};

enum TextureWrap
{
TEXTURE_WRAP_CLAMP_TO_BORDER = 0,
TEXTURE_WRAP_CLAMP_TO_EDGE = 1,
TEXTURE_WRAP_MIRRORED_REPEAT = 2,
TEXTURE_WRAP_REPEAT = 3,
};

enum FaceType
{
FACE_TYPE_FRONT = 0,
FACE_TYPE_BACK = 1,
FACE_TYPE_FRONT_AND_BACK = 2,
};

enum State
{
STATE_DEPTH_TEST = 0,
STATE_SCISSOR_TEST = 1,
STATE_STENCIL_TEST = 2,
STATE_ALPHA_TEST = 3,
STATE_BLEND = 4,
STATE_CULL_FACE = 5,
STATE_POLYGON_OFFSET_FILL = 6,
STATE_ALPHA_TEST_SUPPORTED = 7,
};

struct TextureCreationParams
{
TextureCreationParams()
: m_Type(TEXTURE_TYPE_2D)
, m_Width(0)
, m_Height(0)
, m_Depth(1)
, m_OriginalWidth(0)
, m_OriginalHeight(0)
, m_MipMapCount(1)
, m_UsageHintBits(TEXTURE_USAGE_HINT_SAMPLE)
{}

TextureType m_Type;
uint16_t m_Width;
uint16_t m_Height;
uint16_t m_Depth;
uint16_t m_OriginalWidth;
uint16_t m_OriginalHeight;
uint8_t m_MipMapCount;
uint8_t m_UsageHintBits;
};

struct TextureParams
{
TextureParams()
: m_Data(0x0)
, m_DataSize(0)
, m_Format(TEXTURE_FORMAT_RGBA)
, m_MinFilter(TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST)
, m_MagFilter(TEXTURE_FILTER_LINEAR)
, m_UWrap(TEXTURE_WRAP_CLAMP_TO_EDGE)
, m_VWrap(TEXTURE_WRAP_CLAMP_TO_EDGE)
, m_X(0)
, m_Y(0)
, m_Z(0)
, m_Width(0)
, m_Height(0)
, m_Depth(0)
, m_MipMap(0)
, m_SubUpdate(false)
{}

const void* m_Data;
uint32_t m_DataSize;
TextureFormat m_Format;
TextureFilter m_MinFilter;
TextureFilter m_MagFilter;
TextureWrap m_UWrap;
TextureWrap m_VWrap;

// For sub texture updates
uint32_t m_X;
uint32_t m_Y;
uint32_t m_Z; // For array texture, this is the slice to set

uint16_t m_Width;
uint16_t m_Height;
uint16_t m_Depth; // For array texture, this is slice count
uint8_t m_MipMap : 7;
uint8_t m_SubUpdate : 1;
};

struct RenderTargetCreationParams
{
TextureCreationParams m_ColorBufferCreationParams[MAX_BUFFER_COLOR_ATTACHMENTS];
TextureCreationParams m_DepthBufferCreationParams;
TextureCreationParams m_StencilBufferCreationParams;
TextureParams m_ColorBufferParams[MAX_BUFFER_COLOR_ATTACHMENTS];
TextureParams m_DepthBufferParams;
TextureParams m_StencilBufferParams;
AttachmentOp m_ColorBufferLoadOps[MAX_BUFFER_COLOR_ATTACHMENTS];
AttachmentOp m_ColorBufferStoreOps[MAX_BUFFER_COLOR_ATTACHMENTS];
float m_ColorBufferClearValue[MAX_BUFFER_COLOR_ATTACHMENTS][4];
// TODO: Depth/Stencil

uint8_t m_DepthTexture : 1;
uint8_t m_StencilTexture : 1;
};

struct PipelineState
{
uint64_t m_WriteColorMask : 4;
uint64_t m_WriteDepth : 1;
uint64_t m_PrimtiveType : 3;
// Depth Test
uint64_t m_DepthTestEnabled : 1;
uint64_t m_DepthTestFunc : 3;
// Stencil Test
uint64_t m_StencilEnabled : 1;

// Front
uint64_t m_StencilFrontOpFail : 3;
uint64_t m_StencilFrontOpPass : 3;
uint64_t m_StencilFrontOpDepthFail : 3;
uint64_t m_StencilFrontTestFunc : 3;

// Back
uint64_t m_StencilBackOpFail : 3;
uint64_t m_StencilBackOpPass : 3;
uint64_t m_StencilBackOpDepthFail : 3;
uint64_t m_StencilBackTestFunc : 3;

uint64_t m_StencilWriteMask : 8;
uint64_t m_StencilCompareMask : 8;
uint64_t m_StencilReference : 8;
// Blending
uint64_t m_BlendEnabled : 1;
uint64_t m_BlendSrcFactor : 4;
uint64_t m_BlendDstFactor : 4;
// Culling
uint64_t m_CullFaceEnabled : 1;
uint64_t m_CullFaceType : 2;
// Face winding
uint64_t m_FaceWinding : 1;
// Polygon offset
uint64_t m_PolygonOffsetFillEnabled : 1;
};

HTexture NewTexture(HContext context, const TextureCreationParams& params);
void SetTexture(HTexture texture, const TextureParams& params);

HRenderTarget NewRenderTarget(HContext context, uint32_t buffer_type_flags, const RenderTargetCreationParams params);
void DeleteRenderTarget(HRenderTarget render_target);
void SetRenderTarget(HContext context, HRenderTarget render_target, uint32_t transient_buffer_types);

HUniformLocation GetUniformLocation(HProgram prog, const char* name);
uint32_t GetUniformName(HProgram prog, uint32_t index, char* buffer, uint32_t buffer_size, Type* type, int32_t* size);
uint32_t GetUniformCount(HProgram prog);
HProgram NewProgram(HContext context, HVertexProgram vertex_program, HFragmentProgram fragment_program);

uint32_t GetWindowWidth(HContext context);
uint32_t GetWindowHeight(HContext context);

void SetCullFace(HContext context, FaceType face_type);

void EnableState(HContext context, State state);
void DisableState(HContext context, State state);

void SetViewport(HContext context, int32_t x, int32_t y, int32_t width, int32_t height);

void EnableVertexBuffer(HContext context, HVertexBuffer vertex_buffer, uint32_t binding_index);
void DisableVertexBuffer(HContext context, HVertexBuffer vertex_buffer);

void EnableVertexDeclaration(HContext context, HVertexDeclaration vertex_declaration, uint32_t binding_index, HProgram program);
void DisableVertexDeclaration(HContext context, HVertexDeclaration vertex_declaration);

void EnableTexture(HContext context, uint32_t unit, uint8_t id_index, HTexture texture);
void SetSampler(HContext context, HUniformLocation location, int32_t unit);
void DisableTexture(HContext context, uint32_t unit, HTexture texture);

void DrawElements(HContext context, PrimitiveType prim_type, uint32_t first, uint32_t count, Type type, HIndexBuffer index_buffer);
void Draw(HContext context, PrimitiveType prim_type, uint32_t first, uint32_t count);

void EnableProgram(HContext context, HProgram program);
void DisableProgram(HContext context);

PipelineState GetPipelineState(HContext context);

void SetTextureParams(HTexture texture, TextureFilter minfilter, TextureFilter magfilter, TextureWrap uwrap, TextureWrap vwrap, float max_anisotropy);
}

#endif

Loading

0 comments on commit 5b66fb5

Please sign in to comment.