1
0
mirror of https://github.com/Yours3lf/rpi-vk-driver.git synced 2025-01-30 22:52:14 +01:00

now compiles properly to armv8-a or others

This commit is contained in:
yours3lf 2020-05-17 17:29:04 +01:00
parent c1b282cc64
commit dc89f5c558
30 changed files with 73 additions and 91 deletions

View File

@ -22,6 +22,13 @@ link_directories(${EXTERNAL_PATH}/lib)
include_directories(${EXTERNAL_PATH}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(RPI_ARCH
armv8-a #RPi support: 2B 1.2, 3B, 3B+
#armv7-a #RPi support: 2B
#armv8 #RPi support: 3A+
#armv6z #RPi support: 1A, 1A+, 1B, Zero 1.2, Zero 1.3, Zero W
)
add_subdirectory(brcm)
add_subdirectory(QPUassembler)
add_subdirectory(driver)

View File

@ -8,7 +8,7 @@ file(GLOB asmSrc
)
add_library(QPUassembler OBJECT ${asmSrc})
target_compile_options(QPUassembler PRIVATE -Wall -Werror=implicit-function-declaration -std=c11)
target_compile_options(QPUassembler PRIVATE -Wall -Werror=implicit-function-declaration -std=c11 -march=${RPI_ARCH} -fPIC)
add_executable(QPUassemblerExe ${asmSrc} main.c shaders.h)
target_compile_options(QPUassemblerExe PRIVATE -Wall -Werror=implicit-function-declaration -std=c11)
target_compile_options(QPUassemblerExe PRIVATE -Wall -Werror=implicit-function-declaration -std=c11 -march=${RPI_ARCH} -fPIC)

View File

@ -23,6 +23,9 @@ else(CMD_ERROR2 STREQUAL "")
endif(CMD_ERROR2 STREQUAL "")
add_library(brcm OBJECT ${brcmSrc})
target_compile_options(brcm PRIVATE -Wall -std=c99)
target_compile_options(brcm PRIVATE -Wall -std=c99
-march=${RPI_ARCH}
-fPIC
)
#target_link_libraries(brcm expat z)
target_compile_definitions(brcm PRIVATE V3D_VERSION=21)

View File

@ -4,6 +4,8 @@ file(GLOB driverSrc
)
add_library(rpi-vk-driver SHARED ${driverSrc})
target_compile_options(rpi-vk-driver PRIVATE -Wall -Wextra -Wpacked -Wcast-align -std=c11)
target_compile_options(rpi-vk-driver PRIVATE -Wall -Wextra -Wpacked -Wcast-align -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(rpi-vk-driver drm pthread expat z $<TARGET_OBJECTS:brcm> $<TARGET_OBJECTS:QPUassembler>)

View File

@ -182,8 +182,6 @@ uint32_t consecutivePoolReAllocate(ConsecutivePoolAllocator* pa, void* currentMe
assert(currentMem);
assert(currNumBlocks);
fprintf(stderr, "CPA realloc begin \n");
uint32_t* nextCandidate = (char*)currentMem + pa->blockSize * currNumBlocks;
uint32_t* prevPtr = 0;
@ -202,8 +200,6 @@ uint32_t consecutivePoolReAllocate(ConsecutivePoolAllocator* pa, void* currentMe
pa->nextFreeBlock = *listPtr;
}
fprintf(stderr, "CPA realloc end continue \n");
return (char*)currentMem - pa->buf;
}
@ -218,17 +214,11 @@ uint32_t consecutivePoolReAllocate(ConsecutivePoolAllocator* pa, void* currentMe
{
return -1;
}
fprintf(stderr, "CPA realloc pre-copy \n");
fprintf(stderr, "new offset %u, buf %p, max size %u, to copy %u\n", newMemOffset, pa->buf, pa->size, currNumBlocks * pa->blockSize);
//copy over old content
memcpy(pa->buf + newMemOffset, currentMem, currNumBlocks * pa->blockSize);
//free current element
consecutivePoolFree(pa, currentMem, currNumBlocks);
fprintf(stderr, "CPA realloc end copy \n");
return newMemOffset;
}
}

View File

@ -337,22 +337,6 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkQueueSubmit(
uint32_t writeMSAAimageIdx = writeMSAAimage ? clGetHandleIndex(&cmdbuf->handlesCl, marker->handlesSize, marker->handlesBufOffset + cmdbuf->handlesCl.offset, writeMSAAimage->boundMem->bo) : 0;
uint32_t writeMSAAdepthStencilImageIdx = writeMSAAdepthStencilImage ? clGetHandleIndex(&cmdbuf->handlesCl, marker->handlesBufOffset + cmdbuf->handlesCl.offset, marker->handlesSize, writeMSAAdepthStencilImage->boundMem->bo) : 0;
// fprintf(stderr, "writeImage: %u\n", writeImage);
// fprintf(stderr, "readImage: %u\n", readImage);
// fprintf(stderr, "writeDepthStencilImage: %u\n", writeDepthStencilImage);
// fprintf(stderr, "readDepthStencilImage: %u\n", readDepthStencilImage);
// fprintf(stderr, "writeMSAAimage: %u\n", writeMSAAimage);
// fprintf(stderr, "writeMSAAdepthStencilImage: %u\n", writeMSAAdepthStencilImage);
// fprintf(stderr, "performResolve: %u\n", performResolve);
// fprintf(stderr, "readMSAAimage: %u\n", readMSAAimage);
// fprintf(stderr, "readMSAAdepthStencilImage: %u\n", readMSAAdepthStencilImage);
// fprintf(stderr, "writeImageIdx: %u\n", writeImageIdx);
// fprintf(stderr, "readImageIdx: %u\n", readImageIdx);
// fprintf(stderr, "writeDepthStencilImageIdx: %u\n", writeDepthStencilImageIdx);
// fprintf(stderr, "readDepthStencilImageIdx: %u\n", readDepthStencilImageIdx);
// fprintf(stderr, "writeMSAAimageIdx: %u\n", writeMSAAimageIdx);
// fprintf(stderr, "writeMSAAdepthStencilImageIdx: %u\n", writeMSAAdepthStencilImageIdx);
submitCl.clear_color[0] = 0;
submitCl.clear_color[1] = 0;
submitCl.clear_z = 0;

View File

@ -535,12 +535,10 @@ void clFit(VkCommandBuffer cb, ControlList* cl, uint32_t commandSize)
{
uint32_t currSize = cl->nextFreeByteOffset - cl->offset;
uint32_t currMarkerOffset = cl->currMarkerOffset - cl->offset;
fprintf(stderr, "currOffset %u nextFreeByteOffset %u currMarkerOffset %u\n", cl->offset, cl->nextFreeByteOffset, cl->currMarkerOffset);
cl->offset = consecutivePoolReAllocate(cl->CPA, getCPAptrFromOffset(cl->CPA, cl->offset), cl->numBlocks); assert(cl->offset != -1);
cl->nextFreeByteOffset = cl->offset + currSize;
cl->numBlocks++;
cl->currMarkerOffset = cl->currMarkerOffset == -1 ? -1 : cl->offset + currMarkerOffset;
fprintf(stderr, "currOffset %u nextFreeByteOffset %u currMarkerOffset %u\n", cl->offset, cl->nextFreeByteOffset, cl->currMarkerOffset);
if(cl->currMarkerOffset != -1)
{
assert(((CLMarker*)getCPAptrFromOffset(cl->CPA, cl->currMarkerOffset))->memGuard == 0xDDDDDDDD);

View File

@ -53,10 +53,6 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateDescriptorPool(
dp->descriptorSetPA = createPoolAllocator(dsmem, sizeof(_descriptorSet), sizeof(_descriptorSet) * pCreateInfo->maxSets);
// fprintf(stderr, "imageDescriptorCount %u\n", imageDescriptorCount);
// fprintf(stderr, "bufferDescriptorCount %u\n", bufferDescriptorCount);
// fprintf(stderr, "texelBufferDescriptorCount %u\n", texelBufferDescriptorCount);
uint32_t mapElemBlockSize = sizeof(mapElem);
uint32_t mapBufSize = mapElemBlockSize * (imageDescriptorCount + bufferDescriptorCount + texelBufferDescriptorCount);
@ -156,10 +152,6 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkAllocateDescriptorSets(
ds->bufferDescriptors = 0;
ds->texelBufferDescriptors = 0;
// fprintf(stderr, "imageDescriptorCount %u\n", imageDescriptorCount);
// fprintf(stderr, "bufferDescriptorCount %u\n", bufferDescriptorCount);
// fprintf(stderr, "texelBufferDescriptorCount %u\n", texelBufferDescriptorCount);
if(imageDescriptorCount > 0)
{
ds->imageDescriptors = getCPAptrFromOffset(&dp->imageDescriptorCPA, consecutivePoolAllocate(&dp->imageDescriptorCPA, imageDescriptorCount));

View File

@ -143,10 +143,6 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset)
vertModule = cb->graphicsPipeline->modules[ulog2(VK_SHADER_STAGE_VERTEX_BIT)];
}
// fprintf(stderr, "==============\n", fragModule);
// fprintf(stderr, "fragModule %p\n", fragModule);
// fprintf(stderr, "vertModule %p\n", vertModule);
if(!vertModule)
{
vertModule = fragModule;
@ -157,9 +153,6 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset)
fragModule = vertModule;
}
// fprintf(stderr, "fragModule %p\n", fragModule);
// fprintf(stderr, "vertModule %p\n", vertModule);
assert(fragModule);
assert(vertModule);
assert(fragModule->bos[VK_RPI_ASSEMBLY_TYPE_FRAGMENT]);
@ -299,15 +292,6 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset)
- cb->vertexBuffers[cb->graphicsPipeline->vertexAttributeDescriptions[c].binding]->boundOffset
- formatByteSize) / stride;
// fprintf(stderr, "usedIndices %i\n", usedIndices);
// fprintf(stderr, "boundMemsize %i\n", cb->vertexBuffers[cb->graphicsPipeline->vertexAttributeDescriptions[c].binding]->boundMem->size);
// fprintf(stderr, "vertexattrib offset %i\n", cb->graphicsPipeline->vertexAttributeDescriptions[c].offset);
// fprintf(stderr, "vertex offset %i\n", vertexOffset * stride);
// fprintf(stderr, "vertex buffer offset %i\n", cb->vertexBufferOffsets[cb->graphicsPipeline->vertexAttributeDescriptions[c].binding]);
// fprintf(stderr, "bound offset %i\n", cb->vertexBuffers[cb->graphicsPipeline->vertexAttributeDescriptions[c].binding]->boundOffset);
// fprintf(stderr, "format size %i\n", formatByteSize);
// fprintf(stderr, "stride %i\n", stride);
if(usedIndices < maxIndex)
{
maxIndex = usedIndices;

View File

@ -403,10 +403,6 @@ VkResult rpi_vkCreateShaderModule(VkDevice device, const VkShaderModuleCreateInf
assert(hadVertex == hadCoordinate);
// fprintf(stderr, "pixel shader bo %i\n", shader->bos[2]);
// fprintf(stderr, "vertex shader bo %i\n", shader->bos[1]);
// fprintf(stderr, "coord shader bo %i\n", shader->bos[0]);
*pShaderModule = shader;
return VK_SUCCESS;

View File

@ -275,12 +275,6 @@ void createClearShaderModule(VkDevice device, VkShaderModule* blitShaderModule,
rpi_vkCreateShaderModule(device, &smci, 0, blitShaderModuleNoColor);
assert(*blitShaderModuleNoColor);
// _shaderModule* s = *blitShaderModule;
// fprintf(stderr, "=================\n");
// fprintf(stderr, "pixel shader bo %i\n", s->bos[2]);
// fprintf(stderr, "vertex shader bo %i\n", s->bos[1]);
// fprintf(stderr, "coord shader bo %i\n", s->bos[0]);
for(uint32_t c = 0; c < 4; ++c)
{
free(asm_ptrs[c]);
@ -652,12 +646,6 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkCmdClearAttachments(
createClearPipeline(device, &dsci, clearColor ? device->emulClearShaderModule : device->emulClearNoColorShaderModule, device->emulClearDsl, &blitPipelineLayout, cmdBuf->currRenderPass, &blitPipeline);
// _shaderModule* s = device->emulClearShaderModule;
// fprintf(stderr, "=================\n");
// fprintf(stderr, "pixel shader bo %i\n", s->bos[2]);
// fprintf(stderr, "vertex shader bo %i\n", s->bos[1]);
// fprintf(stderr, "coord shader bo %i\n", s->bos[0]);
rpi_vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, blitPipeline);
VkDeviceSize offsets = 0;

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(CPAtest ${testSrc})
target_compile_options(CPAtest PRIVATE -Wall -std=c++11)
target_compile_options(CPAtest PRIVATE -Wall -std=c++11
-march=${RPI_ARCH}
)
target_link_libraries(CPAtest rpi-vk-driver)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(ETC ${testSrc} )
target_compile_options(ETC PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(ETC PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(ETC vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(HDR ${testSrc} )
target_compile_options(HDR PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(HDR PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(HDR vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(MSAA ${testSrc} )
target_compile_options(MSAA PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(MSAA PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(MSAA vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(attribTest ${testSrc} )
target_compile_options(attribTest PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(attribTest PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(attribTest vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(blending ${testSrc} )
target_compile_options(blending PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(blending PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(blending vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(clear ${testSrc})
target_compile_options(clear PRIVATE -Wall -std=c++11)
target_compile_options(clear PRIVATE -Wall -std=c++11
-march=${RPI_ARCH}
)
target_link_libraries(clear vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(clearTest ${testSrc} )
target_compile_options(clearTest PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(clearTest PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(clearTest vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(cubemapping ${testSrc} )
target_compile_options(cubemapping PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(cubemapping PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(cubemapping vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(depthTest ${testSrc} )
target_compile_options(depthTest PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(depthTest PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(depthTest vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(depthTex ${testSrc} )
target_compile_options(depthTex PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(depthTex PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(depthTex vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(indexedTriangle ${testSrc} )
target_compile_options(indexedTriangle PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(indexedTriangle PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(indexedTriangle vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,7 +4,9 @@ file(GLOB testSrc
)
add_executable(inputTest ${testSrc})
target_compile_options(inputTest PRIVATE -Wall -std=c++11)
target_compile_options(inputTest PRIVATE -Wall -std=c++11
-march=${RPI_ARCH}
)
target_link_libraries(inputTest mtdev evdev udev input)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(mipmapping ${testSrc} )
target_compile_options(mipmapping PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(mipmapping PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(mipmapping vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(query ${testSrc} )
target_compile_options(query PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(query PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(query vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(stencilTest ${testSrc} )
target_compile_options(stencilTest PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(stencilTest PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(stencilTest vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(texturing ${testSrc} )
target_compile_options(texturing PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(texturing PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(texturing vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(triangle ${testSrc} )
target_compile_options(triangle PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(triangle PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(triangle vulkan $<TARGET_OBJECTS:QPUassembler>)

View File

@ -4,6 +4,8 @@ file(GLOB testSrc
)
add_executable(varyings ${testSrc} )
target_compile_options(varyings PRIVATE -Wall -std=c++11 -std=c11)
target_compile_options(varyings PRIVATE -Wall -std=c++11 -std=c11
-march=${RPI_ARCH}
)
target_link_libraries(varyings vulkan $<TARGET_OBJECTS:QPUassembler>)