first commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
class RenderChunksSpuDataIn
|
||||
{
|
||||
public:
|
||||
CellGcmContextData m_PPUGcmContext;
|
||||
int m_numLists;
|
||||
int m_padding[3];
|
||||
int m_listArray[8000];
|
||||
};
|
||||
|
||||
class RenderChunksSpuDataOut
|
||||
{
|
||||
public:
|
||||
uint32_t m_commandBuffer[16*1024]; // 16*4 Kb
|
||||
int m_commandBufferSize;
|
||||
};
|
||||
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="us-ascii"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|PS3">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>PS3</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|PS3">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>PS3</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="LevelRenderChunks_main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="LevelRenderChunks.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{47EBEE93-F9E1-4AD3-B746-0D7D7ADCB0DA}</ProjectGuid>
|
||||
<RootNamespace>task_hello.spu</RootNamespace>
|
||||
<ProjectName>LevelRenderChunks</ProjectName>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|PS3'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>SPU</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>SPU</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|PS3'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">$(SolutionDir)$(Platform)_$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">$(Configuration)\</IntDir>
|
||||
<ExtensionsToDeleteOnClean Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">*.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);$(ExtensionsToDeleteOnClean)</ExtensionsToDeleteOnClean>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">$(SolutionDir)$(Platform)_$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">$(Configuration)\</IntDir>
|
||||
<ExtensionsToDeleteOnClean Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">*.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);undefined;$(ExtensionsToDeleteOnClean)</ExtensionsToDeleteOnClean>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">$(ProjectName)</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">$(ProjectName)</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<PreprocessorDefinitions>SN_TARGET_PS3_SPU;_DEBUG;__GCC__;SPU;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<OptimizationLevel>Levels</OptimizationLevel>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalOptions>-mspurs-task %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>$(SCE_PS3_ROOT)\target\spu\lib\libspurs.a;$(SCE_PS3_ROOT)\target\spu\lib\libdma.a;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<OptimizationLevel>Levels</OptimizationLevel>
|
||||
<PreprocessorDefinitions>SN_TARGET_PS3_SPU;NDEBUG;__GCC__;SPU;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalOptions>-mspurs-task %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>$(SCE_PS3_ROOT)\target\spu\lib\libspurs.a;$(SCE_PS3_ROOT)\target\spu\lib\libdma.a;$(SCE_PS3_ROOT)\target\spu\lib\libgcm_spu.a;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
</Link>
|
||||
<SpuElfConversion>
|
||||
<OutputFile>..\$(TargetName).ppu$(ObjectExt)</OutputFile>
|
||||
</SpuElfConversion>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{881f28ee-ca74-4afc-94a6-2346cb88f86d}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;cc;s;asm</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="LevelRenderChunks_main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="LevelRenderChunks.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,117 @@
|
||||
/* SCE CONFIDENTIAL
|
||||
PlayStation(R)3 Programmer Tool Runtime Library 430.001
|
||||
* Copyright (C) 2007 Sony Computer Entertainment Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
/* common headers */
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <spu_intrinsics.h>
|
||||
#include <cell/spurs.h>
|
||||
#include <spu_printf.h>
|
||||
#include <cell/dma.h>
|
||||
#include <cell/gcm_spu.h>
|
||||
#include <cell/gcm_spu.h>
|
||||
|
||||
|
||||
#include "..\Common\DmaData.h"
|
||||
#include "LevelRenderChunks.h"
|
||||
#include <cell/gcm_spu.h>
|
||||
|
||||
#define SPU_HEAPSIZE (128*1024)
|
||||
#define SPU_STACKSIZE (16*1024)
|
||||
|
||||
CELL_SPU_LS_PARAM(128*1024, 16*1024); // can't use #defines here as it seems to create an asm instruction
|
||||
|
||||
|
||||
static const bool sc_verbose = false;
|
||||
|
||||
|
||||
|
||||
static int32_t gcmReserveFailed(CellGcmContextData *context, uint32_t count)
|
||||
{
|
||||
(void)count;
|
||||
spu_assert(0);
|
||||
context->current = context->begin; // Back to the beginning so we don't trample memory.
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
||||
int cellSpursTaskMain(qword argTask, uint64_t argTaskset)
|
||||
{
|
||||
(void)argTaskset;
|
||||
int ret;
|
||||
CellSpursTaskId idTask = cellSpursGetTaskId();
|
||||
unsigned int idSpu = cellSpursGetCurrentSpuId();
|
||||
|
||||
// if(sc_verbose)
|
||||
spu_printf("[Task#%02u][SPU#%u] start\n", idTask, idSpu);
|
||||
|
||||
void* pVolatileMem = NULL;
|
||||
uint32_t volatileSize = 0;
|
||||
ret = cellSpursGetTaskVolatileArea(&pVolatileMem, &volatileSize);
|
||||
spu_printf( "----------------- LevelRenderChunks SPU Memory ------------------\n"
|
||||
"Stack : %dKb\n"
|
||||
"Heap : %dKb\n"
|
||||
"Prog : %dKb\n"
|
||||
"Free : %dKb\n"
|
||||
"-------------------------------------------------------------\n",
|
||||
SPU_STACKSIZE/1024,
|
||||
SPU_HEAPSIZE/1024,
|
||||
256 - ((SPU_HEAPSIZE+SPU_STACKSIZE+volatileSize)/1024),
|
||||
volatileSize/1024);
|
||||
|
||||
uint32_t eaEventFlag = spu_extract((vec_uint4)argTask, 0);
|
||||
uint32_t eaDataIn = spu_extract((vec_uint4)argTask, 1);
|
||||
uint32_t eaDataOut = spu_extract((vec_uint4)argTask, 2);
|
||||
|
||||
cell::Spurs::EventFlagStub eventFlag;
|
||||
eventFlag.setObject(eaEventFlag);
|
||||
|
||||
RenderChunksSpuDataIn* pDataIn = new RenderChunksSpuDataIn;
|
||||
RenderChunksSpuDataOut* pDataOut = new RenderChunksSpuDataOut;
|
||||
CellGcmContextData gcmContext;
|
||||
cellGcmSetupContextData(&gcmContext, pDataOut->m_commandBuffer, sizeof(pDataOut->m_commandBuffer), gcmReserveFailed);
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
// wait for the chunk rebuild thread to signal us
|
||||
uint16_t mask = 0x1;
|
||||
if(sc_verbose)
|
||||
spu_printf("[Task#%02u][SPU#%u] waiting for event flag#0, mask = 0x%04x\n", idTask, idSpu, mask);
|
||||
ret = eventFlag.wait(&mask, CELL_SPURS_EVENT_FLAG_AND);
|
||||
if (ret) {
|
||||
spu_printf("[Task#%02u][SPU#%u] eventFlag0.wait() failed : %x\n", idTask, idSpu, ret);
|
||||
abort();
|
||||
}
|
||||
|
||||
if(sc_verbose)
|
||||
spu_printf("[Task#%02u][SPU#%u] woken up\n", idTask, idSpu);
|
||||
eventFlag.clear(0x01);
|
||||
|
||||
DmaData_SPU::getAndWait(pDataIn, eaDataIn, sizeof(RenderChunksSpuDataIn));
|
||||
|
||||
for(int i=0;i<pDataIn->m_numLists; i++)
|
||||
{
|
||||
cellGcmSetCallCommand(&gcmContext, pDataIn->m_listArray[i]);
|
||||
}
|
||||
|
||||
pDataOut->m_commandBufferSize = ((unsigned int)gcmContext.current) - ((unsigned int)gcmContext.begin);
|
||||
|
||||
DmaData_SPU::putAndWait(pDataOut, eaDataOut, sizeof(RenderChunksSpuDataOut));
|
||||
|
||||
mask = 0x2;
|
||||
if(sc_verbose)
|
||||
spu_printf("[Task#%02u][SPU#%u] set event flag#1, mask = 0x%04x\n", idTask, idSpu, mask);
|
||||
ret = eventFlag.set(mask);
|
||||
if (ret) {
|
||||
spu_printf("[Task#%02u][SPU#%u] eventFlag1.set(mask) failed : %x\n", idTask, idSpu, ret);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
spu_printf("[Task#%02u][SPU#%u] exit\n", idTask, idSpu);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user