1
0
mirror of https://github.com/Yours3lf/rpi-vk-driver.git synced 2024-11-29 11:24:14 +01:00
rpi-vk-driver/driver/ControlListUtil.h

163 lines
6.1 KiB
C
Raw Normal View History

2018-05-19 14:40:25 +02:00
#pragma once
#if defined (__cplusplus)
extern "C" {
#endif
#include <stdint.h>
typedef struct ControlListAddress
{
2018-05-19 18:35:24 +02:00
uint32_t handle; //handle to buffer object
uint32_t offset; //offset within buffer object
2018-05-19 14:40:25 +02:00
} ControlListAddress;
2018-05-20 18:13:46 +02:00
#define CONTROL_LIST_SIZE 4096
2018-05-19 18:42:10 +02:00
typedef struct ControlList
{
2018-05-20 18:13:46 +02:00
uint8_t* buffer; //TODO size?
uint32_t numBlocks;
2018-05-19 18:42:10 +02:00
uint8_t* nextFreeByte; //pointer to the next available free byte
} ControlList;
2018-10-14 12:12:17 +02:00
void clEmitShaderRelocation(ControlList* relocCl, ControlList* handlesCl, const ControlListAddress* address);
void clDummyRelocation(ControlList* relocCl, const ControlListAddress* address);
2018-05-19 14:40:25 +02:00
#define __gen_user_data struct ControlList
#define __gen_address_type ControlListAddress
#define __gen_address_offset(reloc) ((reloc)->offset)
2018-10-14 12:12:17 +02:00
#define __gen_emit_reloc clDummyRelocation
2018-05-19 14:40:25 +02:00
2018-08-21 22:03:43 +02:00
#include "brcm/cle/v3d_packet_v21_pack.h"
2018-05-19 14:40:25 +02:00
2018-08-26 15:11:43 +02:00
uint32_t divRoundUp(uint32_t n, uint32_t d);
uint32_t moveBits(uint32_t d, uint32_t bits, uint32_t offset);
uint32_t clSize(ControlList* cl);
uint32_t clHasEnoughSpace(ControlList* cl, uint32_t size);
void clInit(ControlList* cl, void* buffer);
void clInsertHalt(ControlList* cl);
void clInsertNop(ControlList* cl);
void clInsertFlush(ControlList* cl);
void clInsertFlushAllState(ControlList* cl);
void clInsertStartTileBinning(ControlList* cl);
void clInsertIncrementSemaphore(ControlList* cl);
void clInsertWaitOnSemaphore(ControlList* cl);
void clInsertBranch(ControlList* cls, ControlListAddress address);
void clInsertBranchToSubList(ControlList* cls, ControlListAddress address);
void clInsertReturnFromSubList(ControlList* cl);
void clInsertStoreMultiSampleResolvedTileColorBuffer(ControlList* cl);
void clInsertStoreMultiSampleResolvedTileColorBufferAndEOF(ControlList* cl);
2018-05-19 14:40:25 +02:00
void clInsertIndexedPrimitiveList(ControlList* cl,
uint32_t maxIndex,
uint32_t indicesAddress,
uint32_t length,
uint32_t indexType, //0/1: 8 or 16 bit
2018-08-26 15:11:43 +02:00
enum V3D21_Primitive primitiveMode);
2018-05-19 14:40:25 +02:00
void clInsertVertexArrayPrimitives(ControlList* cl,
uint32_t firstVertexIndex,
uint32_t length,
2018-08-26 15:11:43 +02:00
enum V3D21_Primitive primitiveMode);
2018-05-19 14:40:25 +02:00
void clInsertPrimitiveListFormat(ControlList* cl,
uint32_t dataType, //1/3: 16 or 32 bit
2018-08-26 15:11:43 +02:00
uint32_t primitiveType); //0/1/2/3: point/line/tri/rhy
2018-05-19 14:40:25 +02:00
void clInsertShaderState(ControlList* cl,
uint32_t address,
uint32_t extendedShaderRecord, //0/1: true/false
2018-08-26 15:11:43 +02:00
uint32_t numberOfAttributeArrays);
2018-05-19 14:40:25 +02:00
void clInsertConfigurationBits(ControlList* cl,
uint32_t earlyZUpdatesEnable, //0/1
uint32_t earlyZEnable, //0/1
uint32_t zUpdatesEnable, //0/1
enum V3D21_Compare_Function depthTestFunction,
uint32_t coverageReadMode, //0/1 clear/leave as is
uint32_t coveragePipeSelect, //0/1
uint32_t coverageUpdateMode, //0/1/2/3 nonzero, odd, or, zero
uint32_t coverageReadType, //0/1 4*8bit, 16 bit mask
uint32_t rasterizerOversampleMode, //0/1/2 none, 4x, 16x
uint32_t enableDepthOffset, //0/1
uint32_t clockwisePrimitives, //0/1
uint32_t enableReverseFacingPrimitive, //0/1
2018-08-26 15:11:43 +02:00
uint32_t enableForwardFacingPrimitive); //0/1
2018-05-19 14:40:25 +02:00
void clInsertFlatShadeFlags(ControlList* cl,
2018-08-26 15:11:43 +02:00
uint32_t flags);
2018-05-19 14:40:25 +02:00
void clInsertPointSize(ControlList* cl,
2018-08-26 15:11:43 +02:00
float size);
2018-05-19 14:40:25 +02:00
void clInsertLineWidth(ControlList* cl,
2018-08-26 15:11:43 +02:00
float width);
2018-05-19 14:40:25 +02:00
void clInsertRHTXBoundary(ControlList* cl,
2018-08-26 15:11:43 +02:00
uint32_t boundary); //sint16
2018-05-19 14:40:25 +02:00
void clInsertDepthOffset(ControlList* cl,
uint32_t units, //float 187
2018-08-26 15:11:43 +02:00
uint32_t factor); //float 187
2018-05-19 14:40:25 +02:00
void clInsertClipWindow(ControlList* cl,
uint32_t width, //uint16
uint32_t height, //uint16
uint32_t bottomPixelCoord, //uint16
2018-08-26 15:11:43 +02:00
uint32_t leftPixelCoord); //uint16
2018-05-19 14:40:25 +02:00
void clInsertViewPortOffset(ControlList* cl,
2018-10-14 12:12:17 +02:00
int16_t x, //sint16
int16_t y //sint16
2018-08-26 15:11:43 +02:00
);
2018-05-19 14:40:25 +02:00
void clInsertZMinMaxClippingPlanes(ControlList* cl,
float minZw,
2018-05-19 18:42:10 +02:00
float maxZw
2018-08-26 15:11:43 +02:00
);
2018-05-19 14:40:25 +02:00
void clInsertClipperXYScaling(ControlList* cl,
float width, //half height in 1/16 of pixel
2018-05-19 18:42:10 +02:00
float height //half width in 1/16 of pixel
2018-08-26 15:11:43 +02:00
);
2018-05-19 14:40:25 +02:00
void clInsertClipperZScaleOffset(ControlList* cl,
float zOffset, //zc to zs
2018-05-19 18:42:10 +02:00
float zScale //zc to zs
2018-08-26 15:11:43 +02:00
);
2018-05-19 14:40:25 +02:00
void clInsertTileBinningModeConfiguration(ControlList* cl,
uint32_t doubleBufferInNonMsMode, //0/1
uint32_t tileAllocationBlockSize, //0/1/2/3 32/64/128/256 bytes
uint32_t tileAllocationInitialBlockSize, //0/1/2/3 32/64/128/256 bytes
uint32_t autoInitializeTileStateDataArray, //0/1
uint32_t tileBuffer64BitColorDepth, //0/1
uint32_t multisampleMode4x, //0/1
uint32_t widthInPixels,
uint32_t heightInPixels,
uint32_t tileStateDataArrayAddress, //16 byte aligned, size of 48 bytes * num tiles
uint32_t tileAllocationMemorySize,
uint32_t tileAllocationMemoryAddress
2018-08-26 15:11:43 +02:00
);
2018-05-19 14:40:25 +02:00
void clInsertGEMRelocations(ControlList* cl,
uint32_t buffer0,
2018-08-26 15:11:43 +02:00
uint32_t buffer1);
2018-05-19 18:35:24 +02:00
void clInsertShaderRecord(ControlList* cls,
2018-10-14 12:12:17 +02:00
ControlList* relocCl,
ControlList* handlesCl,
2018-05-19 14:40:25 +02:00
uint32_t fragmentShaderIsSingleThreaded, //0/1
uint32_t pointSizeIncludedInShadedVertexData, //0/1
uint32_t enableClipping, //0/1
uint32_t fragmentNumberOfUnusedUniforms,
uint32_t fragmentNumberOfVaryings,
uint32_t fragmentUniformsAddress,
2018-05-19 18:35:24 +02:00
ControlListAddress fragmentCodeAddress,
2018-05-19 14:40:25 +02:00
uint32_t vertexNumberOfUnusedUniforms,
uint32_t vertexAttributeArraySelectBits,
uint32_t vertexTotalAttributesSize,
2018-05-19 18:35:24 +02:00
uint32_t vertexUniformsAddress,
ControlListAddress vertexCodeAddress,
uint32_t coordinateNumberOfUnusedUniforms,
uint32_t coordinateAttributeArraySelectBits,
uint32_t coordinateTotalAttributesSize,
uint32_t coordinateUniformsAddress,
ControlListAddress coordinateCodeAddress);
2018-05-19 18:35:24 +02:00
void clInsertAttributeRecord(ControlList* cls,
2018-10-14 12:12:17 +02:00
ControlList* relocCl,
ControlList* handlesCl,
2018-05-19 14:40:25 +02:00
ControlListAddress address,
uint32_t sizeBytes,
uint32_t stride,
uint32_t vertexVPMOffset,
uint32_t coordinateVPMOffset);
2018-08-26 15:11:43 +02:00
uint32_t clGetHandleIndex(ControlList* handlesCl, uint32_t handle);
2018-05-19 14:40:25 +02:00
#if defined (__cplusplus)
}
#endif