ADLXJavaBind

Demonstrates how to wrap ADLX with SWIG when programming with ADLX.

Sample Path

/Samples/java/ADLXJavaBind

Code

Copied!

//
// Copyright (c) 2021 - 2025 Advanced Micro Devices, Inc. All rights reserved.
//
//-------------------------------------------------------------------------------------------------

%module(directors="1") ADLX
%{
#include <Windows.h>
#include "../../../../SDK/Include/ADLXDefines.h"
#include "../../../../SDK/Include/ICollections.h"
#include "../../../../SDK/Include/IDisplays.h"
#include "../../../../SDK/Include/ISystem.h"
#include "../../../../SDK/Include/ILog.h"
#include "../../../../SDK/ADLXHelper/Windows/Cpp/ADLXHelper.h"

typedef     int64_t             adlx_int64;
typedef     int32_t             adlx_int32;
typedef     int16_t             adlx_int16;
typedef     int8_t              adlx_int8;
typedef     uint64_t            adlx_uint64;
typedef     uint32_t            adlx_uint32;
typedef     uint16_t            adlx_uint16;
typedef     uint8_t             adlx_uint8;
typedef     size_t              adlx_size;
typedef     void*               adlx_handle;
typedef     double              adlx_double;
typedef     float               adlx_float;
typedef     void                adlx_void;
typedef     long                adlx_long;
typedef     adlx_int32          adlx_int;
typedef     unsigned long       adlx_ulong;
typedef     adlx_uint32         adlx_uint;
typedef     bool                adlx_bool;
typedef wchar_t WCHAR;    // wc,   16-bit UNICODE character
typedef WCHAR TCHAR;

// Microsoft
#define ADLX_CORE_LINK          __declspec(dllexport)
#define ADLX_STD_CALL           __stdcall
#define ADLX_CDECL_CALL         __cdecl
#define ADLX_FAST_CALL          __fastcall
#define ADLX_INLINE              __inline
#define ADLX_FORCEINLINE         __forceinline
#define ADLX_NO_VTABLE          __declspec(novtable)

//IID's
#define ADLX_DECLARE_IID(X) static ADLX_INLINE const wchar_t* IID()  { return X; }
#define ADLX_IS_IID(X, Y) (!wcscmp (X, Y))
#define ADLX_DECLARE_ITEM_IID(X) static ADLX_INLINE const wchar_t* ITEM_IID()  { return X; }

using namespace adlx;
%}
/* Force the generated Java code to use the C enum values rather than making a JNI call */
//%include "java.swg"
//%javaconst(1);

typedef     int64_t             adlx_int64;
typedef     int32_t             adlx_int32;
typedef     int16_t             adlx_int16;
typedef     int8_t              adlx_int8;
typedef     uint64_t            adlx_uint64;
typedef     uint32_t            adlx_uint32;
typedef     uint16_t            adlx_uint16;
typedef     uint8_t             adlx_uint8;
typedef     size_t              adlx_size;
typedef     void*               adlx_handle;
typedef     double              adlx_double;
typedef     float               adlx_float;
typedef     void                adlx_void;
typedef     long                adlx_long;
typedef     adlx_int32          adlx_int;
typedef     unsigned long       adlx_ulong;
typedef     adlx_uint32         adlx_uint;
typedef     bool                adlx_bool;
typedef wchar_t WCHAR;    // wc,   16-bit UNICODE character
typedef WCHAR TCHAR;

// Microsoft
#define ADLX_CORE_LINK          __declspec(dllexport)
#define ADLX_STD_CALL           __stdcall
#define ADLX_CDECL_CALL         __cdecl
#define ADLX_FAST_CALL          __fastcall
#define ADLX_INLINE              __inline
#define ADLX_FORCEINLINE         __forceinline
#define ADLX_NO_VTABLE          __declspec(novtable)

//IID's
#define ADLX_DECLARE_IID(X) static ADLX_INLINE const wchar_t* IID()  { return X; }
#define ADLX_IS_IID(X, Y) (!wcscmp (X, Y))

#define ADLX_DECLARE_ITEM_IID(X) static ADLX_INLINE const wchar_t* ITEM_IID()  { return X; }

/* Callback to turn on director wrapping */
%feature("director") IADLXDisplayListChangedListener;

%include stdint.i
%include carrays.i
%include windows.i
%include typemaps.i

%include "../../../../SDK/Include/ADLXDefines.h"
%include "../../../../SDK/Include/ICollections.h"
%include "../../../../SDK/Include/IDisplays.h"
%include "../../../../SDK/Include/ISystem.h"
%include "../../../../SDK/Include/ILog.h"
%include "../../../../SDK/ADLXHelper/Windows/Cpp/ADLXHelper.h"
using namespace adlx;

// T* pointer
%include cpointer.i
%pointer_functions(adlx_int, intP);
%pointer_functions(double, doubleP);
%pointer_functions(adlx_uint, uintP);
%pointer_functions(ADLX_DISPLAY_TYPE, displayTypeP);
%pointer_functions(ADLX_DISPLAY_CONNECTOR_TYPE, disConnectTypeP);
%pointer_functions(ADLX_DISPLAY_SCAN_TYPE, disScanTypeP);
%pointer_functions(adlx_size, adlx_sizeP)

// T** ppointer
%define %ppointer_functions(TYPE,NAME)
%{
static TYPE *new_##NAME() { %}
%{  return new TYPE(); %}
%{}

static TYPE *copy_##NAME(TYPE value) { %}
%{  return new TYPE(value); %}
%{}

static void delete_##NAME(TYPE *obj) { %}
%{  if (*obj) delete *obj; %}
%{}

static void NAME ##_assign(TYPE *obj, TYPE value) {
  *obj = value;
}

static TYPE NAME ##_value(TYPE *obj) {
  return *obj;
}
%}

TYPE *new_##NAME();
TYPE *copy_##NAME(TYPE value);
void  delete_##NAME(TYPE *obj);
void  NAME##_assign(TYPE *obj, TYPE value);
TYPE  NAME##_value(TYPE *obj);

%enddef

%define %pointer_cast(TYPE1,TYPE2,NAME)
%inline %{
TYPE2 NAME(TYPE1 x) {
   return (TYPE2) x;
}
%}
%enddef
%ppointer_functions(IADLXDisplayServices*, displaySerP_Ptr);
%ppointer_functions(IADLXDisplayList*, displayListP_Ptr);
%ppointer_functions(IADLXDisplay*, displayP_Ptr);
%ppointer_functions(IADLXDisplayChangedHandling*, displayChangeHandlP_Ptr);
%ppointer_functions(char*, charP_Ptr);

Related pages

  • Visit the Adlx product page for download links and more information.

Looking for more documentation on GPUOpen?

AMD GPUOpen software blogs

Our handy software release blogs will help you make good use of our tools, SDKs, and effects, as well as sharing the latest features with new releases.

GPUOpen Manuals

Don’t miss our manual documentation! And if slide decks are what you’re after, you’ll find 100+ of our finest presentations here.

AMD GPUOpen Performance Guides

The home of great performance and optimization advice for AMD RDNA™ 2 GPUs, AMD Ryzen™ CPUs, and so much more.

Getting started: AMD GPUOpen software

New or fairly new to AMD’s tools, libraries, and effects? This is the best place to get started on GPUOpen!

AMD GPUOpen Getting Started Development and Performance

Looking for tips on getting started with developing and/or optimizing your game, whether on AMD hardware or generally? We’ve got you covered!

AMD GPUOpen Technical blogs

Browse our technical blogs, and find valuable advice on developing with AMD hardware, ray tracing, Vulkan®, DirectX®, Unreal Engine, and lots more.

Find out more about our software!

AMD GPUOpen Effects - AMD FidelityFX technologies

Create wonder. No black boxes. Meet the AMD FidelityFX SDK!

AMD GPUOpen Samples

Browse all our useful samples. Perfect for when you’re needing to get started, want to integrate one of our libraries, and much more.

AMD GPUOpen developer SDKs

Discover what our SDK technologies can offer you. Query hardware or software, manage memory, create rendering applications or machine learning, and much more!

AMD GPUOpen Developer Tools

Analyze, Optimize, Profile, Benchmark. We provide you with the developer tools you need to make sure your game is the best it can be!